[FFmpeg-user] Audio Desynchronization When Utilizing Segmentation

Gabriel Balaich roderrooder at gmail.com
Mon Mar 26 04:30:23 EEST 2018


On Sat, Mar 24, 2018 at 4:05 PM, Gabriel Balaich <roderrooder at gmail.com>
wrote:

> Hey all, I was hoping I could a get  a bit of help on a problem I'm having.
>
> Here is my code:
> ffmpeg -y -thread_queue_size 5096 -f dshow -video_size 3440x1440
> -rtbufsize 2147.48M -framerate 100 -pixel_format nv12 ^
> -itsoffset 00:00:00.015 -i video="Video (00 Pro Capture HDMI 4K+)"
> -thread_queue_size 5096 -guess_layout_max 0 -f dshow ^
> -rtbufsize 2147.48M -i audio="SPDIF/ADAT (1+2) (RME Fireface UC)" -map
> 0:0,1:0 -map 1:0 -c:v h264_nvenc -preset: llhp ^
> -pix_fmt nv12 -b:v 250M -minrate 250M -maxrate 250M -bufsize 250M -b:a
> 384k -ac 2 -r 100 -async 1 -vsync 1 ^
> -max_muxing_queue_size 5096 -segment_time 300 -segment_wrap 9 -f segment
> C:\Users\djcim\Videos\PC\PC\PC%02d.mp4
>
> My goal is to continuously record without filling up my hard drive keeping
> the last hour and 30 minutes of footage at all times.
> I'd like to have the ability to edit a group or even just a single segment
> without any dependencies. As in be able to drag one
> or more clips into a video editing program like adobe premiere regardless
> of how long I have been recording and have
> everything line up perfectly, including desirable audio to video
> synchronization.Segmentation seemed perfect for this... but
> when I drag the segments into a video editing program like Adobe premiere
> the audio slowly drifts from the video after each
> break. If I remove segmentation and record one continuous clip this does
> not seem to be a problem, video and audio stay
> synchronized. Is there anyway to force the beginning of each segment to
> pick up exactly where the last one left off?
>
> Apologies if any part of my code is redundant, and thank you for any help.
>
>
After further testing I found that if I use concat to rejoin the segments
back together in ffmpeg everything is back in-sync.
While this wouldn't be horrible to do every time it relies on stitching the
segments back together in the order they were
written. Basically I need all of the segments for this to work, but the
problem is once I record for over 1 hour and 30
minutes the segments start to be overwritten. Keeping all segments would
defeat the purpose (for me) as eventually
they would fill up my hard drive.

Further-more it seems that the audio gets ahead of the video, could this
have something to do with segment
segmenting on key frames only in video? Perhaps audio can't be segmented
down to a single sample or something?
It almost seems like I need to force key frames or maybe mess with time
stamps but I just don't even know where to
begin.

Perhaps what I am looking to do is impossible.


More information about the ffmpeg-user mailing list