改善内容: 1. NAL单元duration累积bug修复 - 修改video_track.rs和unified_video_track.rs - 只有帧内最后一个NAL获得frame_duration,其他为ZERO - 确保同一帧的所有NAL共享相同的RTP时间戳 2. 修复VP8/VP9固定1秒duration错误 - 将Duration::from_secs(1)改为正确的frame_duration计算 3. PTS计算优化(shared_video_pipeline.rs) - 将pipeline_start_time从Mutex<Option<Instant>>改为AtomicI64 - 消除每帧一次的async mutex lock - 使用compare_exchange实现无锁的首帧时间设置 4. 避免重复读取config - 在encode_frame中缓存fps,避免末尾再次获取config锁 5. 编码器零拷贝优化 - H264/H265/VP8/VP9编码器使用drain()替代clone() - 减少内存分配和拷贝开销 6. MJPEG处理器优化 - 无客户端时跳过JPEG编码(WebRTC-only模式优化) 7. RKMPP YUYV直接输入支持 - hwcodec C++层添加YUYV422格式支持 - H264编码器添加Yuyv422输入格式选项
A real-time hardware codec library for RustDesk based on FFmpeg
Codec
Windows
| GPU | FFmpeg ram | FFmpeg vram | sdk vram |
|---|---|---|---|
| intel encode | qsv | qsv | Y |
| intel decode | d3d11 | d3d11 | Y |
| nvidia encode | nvenc(nv12->d3d11) | nvenc(d3d11) | Y |
| nvidia decode | d3d11 | d3d11 | N |
| amd encode | amf | amf | Y |
| amd decode | d3d11 | d3d11 | Y |
Notes
-
The reason for discarding the codecs using Cucontext is discussed in the following forum thread: https://forums.developer.nvidia.com/t/cuctxdestroy-causing-system-freeze-and-black-screen/290542/1. Based on the information above, there are several optimizations and changes made to the codec:
- FFmpeg encoding AV_PIX_FMT_NV12 directly: The codec is modified to transfer AV_PIX_FMT_NV12 to AV_PIX_FMT_D3D11. This is done because FFmpeg doesn't use Cucontext if the device type is AV_HWDEVICE_TYPE_D3D11VA.
- FFmpeg decoding with AV_HWDEVICE_TYPE_CUDA acceleration: This functionality is disabled and replaced with AV_HWDEVICE_TYPE_D3D11VA. The decoding process now utilizes D3D11VA acceleration instead of CUDA.
- SDK decoding with CUDA acceleration: The CUDA acceleration support is disabled.
-
amd sdk remove h265 support, https://github.com/GPUOpen-LibrariesAndSDKs/AMF/issues/432
Linux
| GPU | FFmpeg ram |
|---|---|
| intel encode | vaapi |
| intel decode | vaapi |
| nvidia encode | vaapi, nvnec |
| nvidia decode | vaapi, nvdec |
| amd encode | vaapi, amf |
| amd decode | vaapi |
Issue
- vaapi: only tested on intel with
va-driver-all, and hevc_vaapi encoding not supported on my pc - remove hevc_vaapi because of possible poor quality
- amf: not tested, https://github.com/GPUOpen-LibrariesAndSDKs/AMF/issues/378
MacOS
| FFmpeg ram encode | FFmpeg ram decode |
|---|---|
| h265 only | Y |
Android
| FFmpeg ram encode |
|---|
| Y |
System requirements
-
intel
Windows Intel(r) graphics driver since 27.20.100.8935 version.
Hardware Platforms Supported by the Intel(R) Media SDK GPU Runtime
-
AMD
AMD Radeon Software Adrenalin Edition 23.1.2 (22.40.01.34) or newer
-
nvidia
Windows: Driver version 471.41 or higher
https://docs.nvidia.com/video-technologies/video-codec-sdk/11.1/read-me/index.html
https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new?ncid=em-prod-816193