简体   繁体   English

FFmpeg-音频链接dshow输入的仅延迟视频流

[英]FFmpeg - Delay Only Video Stream Of Audio Linked dshow Input

I'm having a slight issue trying to sync my audio and video up with an acceptable margin of error. 我在尝试以可接受的误差范围同步音频和视频时遇到一个小问题。 Here is my command: 这是我的命令:

ffmpeg -y -thread_queue_size 9999 -indexmem 9999 -guess_layout_max 0 -f dshow -video_size 3440x1440 -rtbufsize 2147.48M ^
-framerate 100 -pixel_format nv12 -i video="Video (00 Pro Capture HDMI 4K+)":audio="SPDIF/ADAT (1+2) (RME Fireface UC)" ^
-map 0:0,0:1 -map 0:1 -flags +cgop -force_key_frames expr:gte(t,n_forced*2) -c:v h264_nvenc -preset: llhp -pix_fmt nv12 ^
-b:v 250M -minrate 250M -maxrate 250M -bufsize 250M -c:a aac -ar 44100 -b:a 384k -ac 2 -r 100 -af "aresample=async=250" ^
-vsync 1 -max_muxing_queue_size 9999 -f segment -segment_time 600 -segment_wrap 9 -reset_timestamps 1 ^
C:\Users\djcim\Videos\PC\PC\PC%02d.ts

My problem is the video comes in slightly ahead of the audio, I can use -itsoffset but then I have to call the video and audio as separate inputs as -itsoffset offsets both audio and video. 我的问题是视频先于音频出现,我可以使用-itsoffset,但随后我必须将视频和音频作为单独的输入调用,因为-itsoffset会同时偏移音频和视频。 While this may seem the obvious solution it causes inconsistent audio synchronization if the audio isn't called with the video. 尽管这似乎是显而易见的解决方案,但如果未随视频调用音频,则会导致音频同步不一致。 Basically if both audio and video aren't called at the same time the video can now be ahead or behind with a 2-3 frame margin. 基本上,如果没有同时调用音频和视频,则视频现在可以以2-3帧的余量向前或向后。 When I call them at the same time the video consistently comes in 2 frames ahead of the audio, every time. 当我同时打电话给他们时,视频始终比音频早2帧。 I just need a way to delay only the video stream without delaying the audio while keeping both audio and video linked from the beginning. 我只需要一种只延迟视频流而又不延迟音频,同时从一开始就保持音频和视频链接的方法。 I've tried this with no luck: 我没有运气尝试过这个:

ffmpeg -y -thread_queue_size 9999 -indexmem 9999 -guess_layout_max 0 -f dshow -video_size 3440x1440 -rtbufsize 2147.48M ^
-framerate 200 -pixel_format nv12 -i video="Video (00 Pro Capture HDMI 4K+)":audio="SPDIF/ADAT (1+2) (RME Fireface UC)" ^
-flags +cgop -force_key_frames expr:gte(t,n_forced*2) -c:v h264_nvenc -preset: llhp -pix_fmt nv12 -b:v 250M ^
-minrate 250M -maxrate 250M -bufsize 250M -c:a aac -ar 44100 -b:a 384k -ac 2 -r 100 ^
-filter_complex "[0:v] setpts=PTS-STARTPTS+.032/TB [v]; [0:a] asetpts=PTS-STARTPTS, aresample=async=250 [a]" -map [v] ^
-map [a] -vsync 1 -max_muxing_queue_size 9999 -f segment -segment_time 600 -segment_wrap 9 -reset_timestamps 1 ^
C:\Users\djcim\Videos\PC\PC\PC%02d.ts

Just like -itsoffset both video and audio are being delayed. 就像-itsoffset一样,视频和音频都被延迟了。 You can delay solely audio with adelay, but there doesn't seem to be a video delaying equivalent. 您可以使用adelay仅延迟音频,但是似乎没有视频延迟等效项。

Any help or advice would be greatly appreciated. 任何帮助或建议,将不胜感激。

As stated by Gyan in the comments, atrim worked. 正如Gyan在评论中所述,atrim工作了。 While it isn't delaying the video it is still lining everything up by ditching part of the audio stream. 尽管它不会延迟视频,但它仍然通过放弃部分音频流来使所有内容排列整齐。

ffmpeg - y -thread_queue_size 9999 -indexmem 9999 -guess_layout_max 0 -f dshow -video_size 3440x1440 -rtbufsize 2147.48M ^
-framerate 200 -pixel_format nv12 -i video="Video (00 Pro Capture HDMI 4K+)":audio="SPDIF/ADAT (1+2) (RME Fireface UC)" ^
-map 0:0,0:1 -map 0:1 -flags +cgop -force_key_frames expr:gte(t,n_forced*2) -c:v h264_nvenc -preset: llhp -pix_fmt nv12 ^
-b:v 250M -minrate 250M -maxrate 250M -bufsize 250M -c:a aac -ar 44100 -b:a 384k -ac 2 -r 100 ^
-af "atrim=0.038, asetpts=PTS-STARTPTS, aresample=async=250" -vsync 1 -ss 00:00:01.096 -max_muxing_queue_size 9999 ^
-f segment -segment_time 600 -segment_wrap 9 -reset_timestamps 1 C:\Users\djcim\Videos\PC\PC\PC%02d.ts

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM