【问题标题】:Audio/Video out of sync when recording录制时音频/视频不同步
【发布时间】:2020-10-04 03:20:10
【问题描述】:

我正在用 gdigrab 录制桌面,用 dshow 录制音频,但它们不同步。

这是我尝试的第一件事,总是有大约相同的延迟(大约 20-30 帧):

// Command
ffmpeg -f dshow -i audio="Microphone (NVIDIA RTX Voice)" -f gdigrab -framerate 60 -offset_x 0 -offset_y 0 -video_size 1920x1080 -i desktop -c:v h264 -preset ultrafast -qp 0 C:\Videos\test2.mp4

// Bottom of debug log
Input file #0 (audio=Microphone (NVIDIA RTX Voice)):
  Input stream #0:0 (audio): 15 packets read (1323000 bytes); 15 frames decoded (330750 samples);
  Total: 15 packets (1323000 bytes) demuxed
Input file #1 (desktop):
  Input stream #1:0 (video): 223 packets read (1849663242 bytes); 223 frames decoded;
  Total: 223 packets (1849663242 bytes) demuxed
Output file #0 (C:\Videos\test2.mp4):
  Output stream #0:0 (video): 243 frames encoded; 243 packets muxed (211227447 bytes);
  Output stream #0:1 (audio): 322 frames encoded (329728 samples); 323 packets muxed (120103 bytes);
  Total: 566 packets (211347550 bytes) muxed
238 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0000028163c9c040] Statistics: 2 seeks, 810 writeouts

我尝试的第二件事我相信解决了音频同步问题,但我真的可以说出来,因为它使录音非常滞后:

// Command
ffmpeg -f gdigrab -framerate 60 -offset_x 0 -offset_y 0 -video_size 1920x1080 -i desktop -f dshow -i audio="Microphone (NVIDIA RTX Voice)" -c:v h264 -preset ultrafast -qp 0 C:\Videos\test2.mp4

// Bottom of debug log
Input file #0 (desktop):
  Input stream #0:0 (video): 112 packets read (928978848 bytes); 112 frames decoded;
  Total: 112 packets (928978848 bytes) demuxed
Input file #1 (audio=Microphone (NVIDIA RTX Voice)):
  Input stream #1:0 (audio): 12 packets read (1058400 bytes); 12 frames decoded (264600 samples);
  Total: 12 packets (1058400 bytes) demuxed
Output file #0 (C:\Videos\test2.mp4):
  Output stream #0:0 (video): 388 frames encoded; 388 packets muxed (109408287 bytes);
  Output stream #0:1 (audio): 258 frames encoded (264192 samples); 259 packets muxed (96404 bytes);
  Total: 647 packets (109504691 bytes) muxed
124 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0000019da713c040] Statistics: 2 seeks, 421 writeouts

如何同步音频和视频?

原来只有麦克风有延迟,我尝试使用virtual-audio-capturer 设备并且音频完美同步,但这只是桌面音频而不是麦克风。

【问题讨论】:

    标签: ffmpeg


    【解决方案1】:

    尝试将设备从 RTX 更改为您的实际设备。

    【讨论】:

    • 我做到了,延迟仍然存在。
    【解决方案2】:

    有两种可能的解决方案:

    1. 使用 dshow screen-capture-recorder 代替 gdigrab

    ffmpeg -f dshow -i video="screen-capture-recorder":audio="Your-Microphone" output.mkv

    1. 或为视频或音频设置一个偏移值,以加快速度

    将 -itoffset 00:00:0.6(例如 600 毫秒)放在更快的后面

    【讨论】:

      猜你喜欢
      • 2012-03-16
      • 1970-01-01
      • 1970-01-01
      • 2014-12-18
      • 2019-05-19
      • 2015-05-16
      • 1970-01-01
      • 1970-01-01
      • 2012-12-16
      相关资源
      最近更新 更多