Delay Only Video Stream Of Audio Linked dshow Input

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Delay Only Video Stream Of Audio Linked dshow Input

Gabriel Balaich
Hello everyone,

I'm have 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. 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. When I call them at the
same time the video consistently comes in 2 frames
ahead of the audio, every time. 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. You can delay
solely audio with adelay, but there doesn't seem to be
a video delaying equivalent.

Any help or advice would be greatly appreciated.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Delay Only Video Stream Of Audio Linked dshow Input

Gabriel Balaich
While I wasn't able to find a way to delay only the video (still seems
pretty strange there isn't an option for that...) I was able to cut
the audio using atrim and then move it back with asetpts:

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 -c:v h264_nvenc -r 100 -rc-lookahead 200 -forced-idr
1 -strict_gop 1 -sc_threshold 0 -flags +cgop ^
-force_key_frames expr:gte(t,n_forced*2) -preset: llhp -pix_fmt nv12 -b:v
250M -minrate 250M -maxrate 250M -bufsize 250M ^
-c:a aac -ar 44100 -b:a 384k -ac 2 -af "atrim=0.035, 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

I was informed of these options by a very nice user on stack exchange:
https://stackoverflow.com/questions/49805691/ffmpeg-delay-only-video-stream-of-audio-linked-dshow-input

On Thu, Apr 12, 2018 at 10:50 AM, Gabriel Balaich <[hidden email]>
wrote:

> Hello everyone,
>
> I'm have 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. 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. When I call them at
> the same time the video consistently comes in 2 frames
> ahead of the audio, every time. 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. You can delay
> solely audio with adelay, but there doesn't seem to be
> a video delaying equivalent.
>
> Any help or advice would be greatly appreciated.
>
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".