Search code examples
ffmpegduplicatessynchronizationframe-ratetimecodes

ffmpeg - Timecode & Fractional Frame Rate (Duplicating Frames)


I record two different frame rates using ffmpeg, 60 and 100. Or at least I thought I was recording 60 and 100, now it seems it's actually 59.94 and 99.98.

Here is the command I was using:

ffmpeg -y -thread_queue_size 9999 -guess_layout_max 0 -f dshow -video_size 1920x1080 -rtbufsize 2147.48M -framerate 60 ^
-pixel_format yuyv422 -i video="Game Capture HD60 S (Video) (#01)":audio="ADAT (5+6) (RME Fireface UC)" -map 0:0,0:1 ^
-map 0:1 -c:v h264_nvenc -preset: llhp -pix_fmt yuv420p -b:v 40M -minrate 40M -maxrate 40M -bufsize 40M -b:a 384k -ac 2 ^
-r 60 -af "pan=mono|c0=c0, adelay=84" -vsync 1 -max_muxing_queue_size 9999 -f segment -segment_time 600 ^
-segment_wrap 9 -reset_timestamps 1 C:\Users\djcim\Videos\PC\Camera\CPC%02d.ts ^
-thread_queue_size 9999 -f dshow -video_size 3440x1440 -rtbufsize 2147.48M -framerate 100 -pixel_format nv12 ^
-itsoffset 00:00:00.215 -i video="Video (00 Pro Capture HDMI 4K+)" -thread_queue_size 9999 -guess_layout_max 0 -f dshow ^
-rtbufsize 2147.48M -i audio="SPDIF/ADAT (1+2) (RME Fireface UC)" -map 1:0,2:0 -map 6: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 -af "adelay=141|141" -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

I thought all was well with my frame rates, sure ffmpeg was duplicating frames every once in a while, but I thought it was just a random occurrence caused by ffmpeg dropping a frame during processing and therefore needed to duplicate one to make it up. I didn't think duplicating a few frames would be noticeable in the footage... until I was reviewing some from the first output, which is actually a camera, and noticed very slight stutters consistently 3 times a minute. This began to bug me, it was very noticeable and I wanted smooth footage. A bit confused I decided to try the first output by itself and watch ffmpeg to see when frames were being duplicated and found that it was duplicating frames every 17 second (16.66 to be more precise).

After doing the math (1/16.66=.06) I realized that the frame rate of that first capture card was actually 59.94. Doing the same thing for the other output I found that my "100fps" footage is actually 99.98. But what does that really entail?

Should I change the fps to 59.94 and 99.98? Wont that cause synchronization issues as 99.98 (100*.0002=99.98) isn't the same standard as 59.94 (60*.001=59.94)? Or does that mean I just need to set the second output to 99.9 (100*.001=99.9) to match the standard of the first output and drop frames? If that is the case does this mean in my editing program, Adobe Premiere, I would need to export the final video as 59.94fps not 60fps to avoid duplication of frames? Or is there some method within timecode that remedies this issue?

I guess I just really don't understand drop frame and non-drop frame timecode / timecode in general. Up until yesterday when something said 60fps I thought it meant literally 60fps but I guess 99% of the time it actually means 59.94. I'd really like to just avoid the duplication of frames as it ruins what would be a smooth experience but don't know if I can while trying to keep everything synchronized.

Any help or insight would be appreciated, sorry if my question is a bit confusing I am undoubtedly confused.


Solution

  • FFmpeg does not support drop-frame timecode for anything but 59.94 and 29.97. If anyone else is ever facing this problem, odd frame rates like 99.98 (or more common 23.98) should be recorded at a real-time constant FPS, 100FPS in this case.

    With -framerate 100 and -vsync 1 a frame will eventually be duplicated to keep the frame rate real time, you will ultimately have to just deal with slight stutters. Or potentially you could set the FPS to match the lower FPS but then you'd be missing out on a lot of FPS.