惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
MyScale Blog
MyScale Blog
Microsoft Security Blog
Microsoft Security Blog
量子位
B
Blog
aimingoo的专栏
aimingoo的专栏
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog
T
The Exploit Database - CXSecurity.com
N
News | PayPal Newsroom
Cloudbric
Cloudbric
A
About on SuperTechFans
AI
AI
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LINUX DO - 最新话题
T
The Blog of Author Tim Ferriss
Simon Willison's Weblog
Simon Willison's Weblog
有赞技术团队
有赞技术团队
H
Heimdal Security Blog
J
Java Code Geeks
大猫的无限游戏
大猫的无限游戏
D
Docker
Security Archives - TechRepublic
Security Archives - TechRepublic
N
News and Events Feed by Topic
IT之家
IT之家
Know Your Adversary
Know Your Adversary
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
C
Cisco Blogs
博客园 - 叶小钗
美团技术团队
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
LangChain Blog
The Hacker News
The Hacker News
Y
Y Combinator Blog
I
Intezer
The Register - Security
The Register - Security
F
Full Disclosure
V
V2EX
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Last Week in AI
Last Week in AI
Martin Fowler
Martin Fowler

kkocdko's blog

极限压缩文档扫描件 - kkocdko's blog Bypass the Blank Chars Detection crknob - Chrome portable patch 我如何将博客首页体积降至 3 KB - kkocdko's blog 如何极限优化压缩文件体积 - kkocdko's blog EmEditor 精简版 - kkocdko's blog Backup Data from VSCode Web 优雅地游玩 Minecraft - kkocdko's blog 让程序以管理员权限运行的 PE 清单 - kkocdko's blog 注销 ZEIT 账号之后遇到的坑 - kkocdko's blog 本博客的协议已更改为 CC0 - kkocdko's blog mobp - 使 MSOffice 后台常驻 在安装 VS 生成工具时规避 .NET 安装错误 各种格式的占位空文件 - kkocdko's blog 优雅地游玩 Flash 游戏 - kkocdko's blog WPS 2016 极限精简版 - kkocdko's blog Convert Const to Let by Terser 规避 Visual Studio 许可证过期的 Bug 方便地使用 iPod - kkocdko's blog 用 UserJS 注入 UserCSS - kkocdko's blog 注册表修改文件关联(默认程序) - kkocdko's blog 周期精准的太阳系模型 - kkocdko's blog 关闭屏幕的 WinAPI - kkocdko's blog 重置 Windows 图标缓存 - kkocdko's blog AIDA64 极限精简单文件版 - kkocdko's blog 几何画板单文件精简版 - kkocdko's blog 世界之窗浏览器单文件版 - kkocdko's blog 在 MBR + Legacy 下用 Bootmgr 引导 Ubuntu 简洁的 Markdown 预览工具 - kkocdko's blog 修复 MSOffice 墨迹不可用问题 - kkocdko's blog 使用 VBA 批量转换 Office 文档格式 不便携的有道词典便携版 - kkocdko's blog 关于清华同方还原卡的一个坑 - kkocdko's blog 也许是最简洁的搜狗输入法皮肤 - kkocdko's blog 用批处理弄个 U 盘复制器 - kkocdko's blog 美化版 TRIXX - kkocdko's blog Windows 默认蓝色代码 - kkocdko's blog A4 大小的普通英文稿纸 - kkocdko's blog 在批处理中延时(等待) - kkocdko's blog 让批处理隐藏窗口运行 - kkocdko's blog 让批处理以管理员权限运行 - kkocdko's blog 批量修改 PPT 字体样式 - kkocdko's blog New Post - kkocdko's blog Block Android dex2oat on demand Disable “insecure download blocked” warning on Chrome and Edge Reduce memory usage of FreeCAD and OrcaSlicer 用 GDB + Python 获取 Linux 端微信本地数据库密钥 Android bug prevents exfat readonly USB drive Cons of IronRDP today, compare to FreeRDP Multi call binary for existing projects WPS Android modified and stripped Disadvantages of APE - kkocdko's blog Change Linux UKI cmdline without regeneration Disk duplicator is considered deprecated 请弃用网易邮箱 - kkocdko's blog Summary of window state restore on desktop Draft of Mono Client Project Right path to use new glibc on old Linux Linux 笔电的所谓省电技巧 - kkocdko's blog Android 腾讯 TIM 迁移 QQ 指北 消费级 Android on Windows 是没有前途的 请停止滥用新 Web 标准特性 - kkocdko's blog Rescuing data from offline sites Differences in AMD P-State modes after kernel 6.3 Fix Docker 'input device is not a TTY' elegantly 在 2023 年评测前端静态资源公共 CDN - kkocdko's blog kk 对耳机主动降噪功能的体验与评价 - kkocdko's blog Node.js native addon without node-gyp Standalone and portable MSVC - kkocdko's blog 腾讯云安装 Fedora - kkocdko's blog 优化 Git 仓库的额外提示 - kkocdko's blog Using hwmoncat, a tiny alternative to lm_sensors Build Fedora ISO in 3 Commands 简陋的 Win on Linux 兼容方案 Tradition and Modernity in Async Rust Change ZSTD Level in QCOW2 无损转换 PDF 到 Word 是不可能的 Dump PDF from HEP Website Fedora for Termux - kkocdko's blog Using VSCode Web Server Variant Tricks for C++ Simple App Development Tweak CPU Power Elegantly on Windows Fix Windows Power Options Ineffective 优雅地使用联想电脑管家 - kkocdko's blog Restone Image's Alpha Channel - kkocdko's blog 成立 hal-drv 组织,维护一些 Rust embedded-hal 外设驱动 PotPlayer 图标包:爱奇艺播放器 - kkocdko's blog 爱奇艺万能播放器调教指南 - kkocdko's blog Draft - kkocdko's blog
Recording + streaming on Wayland
2026-04-11 · via kkocdko's blog
With gnome:45.2, libwayland:1.22.0, kernel:6.6.4-200.fc39.x86_64, cpu:amd-r5-5600u-and-built-in-gpu

If you choose to do screen recording/streaming on Linux, it's certainly that you'll get more trouble than under Windows/macOS. Here are three ways:

OBS Studio

OBS Studio. It provides a PipeWire capture source for Wayland.

Pros: it's the fact standard on recording/streaming with every platform.

Cons: you need to install many dependencies, and it's painful to custom deeply like VAAPI (GPU acceleration).

Use mediamtx and through Chromium browser's WebRTC screen capture functions. You can find my profile here.

Pros: easy, high performance, low latency (thanks to WebRTC).

Cons: limited, if you want more custom.

Video Capture Card

You can use an HDMI capture card, it needs extra money but not so much (39 chinese yuan currently, please choose the ms2130 chipset). It can be used for SBC(Single Board Computer) also which has poor performance to run video capture inside.

FFMpeg kmsgrab

Pros: maybe fastest if you deal with it properly.

Cons: mouse cursor is not able to be captured, and you need to run ffmpeg with root privileges.

The main idea here, use FFMpeg kmsgrab. First, ensure your environment has VAAPI support. For Fedora Linux with AMD GPU, follow this guide.

The awesome BtbN/FFmpeg-Builds is statically built and many useful features are enabled. Choose ffmpeg-master-latest-linux64-gpl.tar.xz, extract the tarball, and keep only ffmpeg binary.

Then, use these commands:

Details (click to show)
# set an alias
alias ffmpeg="/home/kkocdko/misc/apps/ffmpeg -hide_banner" # please always use latest master branch

# show encoder help
ffmpeg -h encoder=h264_vaapi

# list all avaliable mode in capture card or usb camera
ffmpeg -f video4linux2 -list_formats all -i /dev/video2

# repack file, from flv, to mp4
ffmpeg -i i.flv -c copy o.mp4

# recording, from capture card, through x264, to flv file
ffmpeg \
  -f video4linux2 -input_format yuyv422 -video_size 1920x1080 -framerate 10 -i /dev/video2 \
  -an -c:v libx264 -crf 22 -preset:v veryfast -threads 4 \
  -y rec_$(date +%s).flv

# streaming, from kmsgrab, through x264, to local udp, other environments may use card0 or card2
ffmpeg \
  -f kmsgrab -device /dev/dri/card1 -framerate 30 -i - -vf 'hwmap=derive_device=vaapi,hwdownload,format=bgr0' \
  -an -c:v libx264 -pix_fmt yuv420p -bf 0 -crf 22 -preset:v veryfast -threads 4 \
  -f mpegts 'udp://127.0.0.1:9254?pkt_size=1316'

# streaming, from kmsgrab, through h264_vaapi, to remote srt
ffmpeg \
  -f kmsgrab -device /dev/dri/card1 -framerate 30 -i - -vf 'hwmap=derive_device=vaapi,scale_vaapi=format=nv12' \
  -an -c:v h264_vaapi -profile:v high -qp 24 -compression_level 32 \
  -f mpegts 'srt://127.0.0.1:9254?streamid=publish:s0'

# encoding, through h264_vaapi
ffmpeg \
  -i i.mp4 \
  -vaapi_device /dev/dri/renderD128 -vf 'format=nv12,hwupload' \
  -c:v h264_vaapi -profile:v high -qp 24 -compression_level 32 \
  -c:a copy \
  o.h264_vaapi.mp4

# ===== other notes =====

# encoding, through svt-av1, crf 35 is enough for me, preset 0 is slowest, always tune=0
ffmpeg \
  -i i.mp4 \
  -c:v libsvtav1 -crf 35 -preset 0 -svtav1-params tune=0 \
  -c:a copy \
  o.svtav1.mp4

# concat use ffconcat file, remove metadata, use audio filter to ensure sync
ffmpeg \
  -f concat -i list.txt -map_metadata -1 \
  -c:v copy \
  -af aresample=async=1000 -c:a libopus -b:a 128k -compression_level 10 \
  o.concat.mp4

# combine video and audio
ffmpeg -i v.mp4 -i a.m4a -c:v copy -c:a copy -map 0:v:0 -map 1:a:0 o.combine.mp4

# maybe useful
-tune stillimage
# less latency but no recommended
-tune zerolatency
# move mp4 moov to front, recommended, no size punishment
-movflags faststart
# down to 30 fps
-vf fps=30
# using rtsp with tcp
-f rtsp -rtsp_transport tcp 'rtsp://127.0.0.1:9254/s0'
# output one frame
-ss 00:00:09.000 -frames:v 1 o.png
# good for old devices
-c:v libx264 -preset:v veryslow -crf 28 o.x264.mp4
# streaming use loop video
-re -stream_loop -1 -i i.mp4 -c copy
# never use vp8 please!
-c:v libvpx
# list pixel fmts
-pix_fmts
# use pixel fmts
-an -c:v h264 -pix_fmt yuv420p -profile:v high -level 4.1

# -progress pipe:1
# bd iso: dnf install mkvtoolnix mkvtoolnix-gui
# -bf 0
# -color_range 2
# pactl list short sources
# ~/misc/apps/ffmpeg -f pulse -ac 2 -i - -y ../o.mp3
# -qp 40
# -vaapi_device /dev/dri/renderD128
# -vf 'hwmap=derive_device=vaapi,scale_vaapi=format=nv12'
# -vf 'hwmap=derive_device=vaapi,scale_vaapi=w=1920:h=1080:format=nv12'
# -f flv rtmp://127.0.0.1:9658/live/home
# crop=960:540:480:270 -vf 'hwdownload,format=bgr0'
# -maxrate 9M
# -f alsa -ac 2 -thread_queue_size 1024 -i hw:0 \
# ffmpeg -i i.mp4 -y -c:v h264 -pix_fmt yuv420p -profile:v high -level 4.1 -vf scale=-1:720 o.mp4
  • Something like Chrome and QEMU-KVM will interrupte kmsgrab after entering/exiting full-screen.

Other Choices

  • GNOME's built-in recorder. Certainly the simplest but: 1. Recording only, not streaming. 3. Force WebM (libvp8 soft-encoding), terrible for HDPI monitor and needed to be re-encoded before sending file to other people using various machines. So I drop it finally.

Reference

https://mkvtoolnix.download/downloads.html#fedora

https://stackoverflow.com/a/35520705

https://ffmpeg.org/ffmpeg-codecs.html#VAAPI-encoders

https://ffmpeg.org/ffmpeg-protocols.html

https://trac.ffmpeg.org/wiki/Capture/PulseAudio

https://trac.ffmpeg.org/wiki/Encode/H.264

https://trac.ffmpeg.org/wiki/Hardware/VAAPI

https://trac.ffmpeg.org/wiki/StreamingGuide

https://trac.ffmpeg.org/wiki/colorspace

https://github.com/BtbN/FFmpeg-Builds

https://github.com/YuzukiHD/YuzukiLOHCC-PRO

https://github.com/bluenviron/mediamtx/

https://github.com/bluenviron/mediamtx/issues/1329#issuecomment-1364853707

https://github.com/bluenviron/mediamtx/issues/1317

https://github.com/bluenviron/mediamtx/issues/2424

https://github.com/xqq/mpegts.js

https://srtlab.github.io/srt-cookbook/apps/ffmpeg.html

https://stackoverflow.com/q/58754385/

https://stackoverflow.com/q/62977448/

https://superuser.com/a/1777079

https://wiki.tonytascioglu.com/scripts/ffmpeg/kmsgrab_screen_capture

https://write.corbpie.com/ffmpeg-list-all-codecs-encoders-decoders-and-formats/

https://zhuanlan.zhihu.com/p/634052876

https://www.bilibili.com/read/cv17341923/

https://www.reddit.com/r/Fedora/comments/137e194/comment/jivq2ne/?utm_source=share&utm_medium=web2x&context=3