To test this, I've just created a fixed-frame-rate video at 24 fps: |---R----|G|---B----|
(1/3) seconds (8 frames) solid Red, followed by (1/24) seconds (1 frame) solid Green, followed by (1/3) seconds (8 frames) solid Blue. Per the FFmpeg Mailing List FAQ, I've uploaded the sample file to https://0x0.st/-yD3.mp4 I then tested the output of running commands like this, only changing the value for $STARTTIME : export STARTTIME=0.33 ; ffmpeg -r 24 -i color-frames.mp4 -r 24 -ss $STARTTIME "test-$STARTTIME.mp4" (Side note: I originally put the -ss value before the input specifier, but the times were very inaccurate: some clips dropped no frames - i.e. I saw 8 frames of red in some cases! Other times too many frames appeared to be dropped. If I'm reading the man page entry for -ss correctly, this seems like a bug.) Below are values for $STARTTIME, with the color of the first frame of the output: 0.3: Red 0.30: Red 0.31: Red 0.311: Red 0.312: Red 0.31249: Red 0.312499999: Red 0.3125: Green <-------- This is halfway between the start time of the last Red frame (7/24) and the start time of the first Green one (1/3). Calculation: ((7/24) + (((1/3)-(7/24))/2)) == (5/16). Note this output file starts with 2(!) green frames even though the input only contains 1. 0.31250000001: Green (still 2 frames of Green) 0.3125000001: Green (still 2 frames) 0.312500001: Green (still 2 frames) 0.31250001: Green (still 2 frames) 0.3125001: Green (still 2 frames) 0.312501: Green (back to only 1 frame of Green) 0.31251: Green 0.313: Green 0.315: Green 0.317: Green 0.32: Green 0.33: Green 0.33333333333: Green <-------------------- This is where the source video turns from Red to Green (1/3 == 0.333...) 0.33333333334: Green 0.334: Green 0.34: Green 0.35: Green 0.36: Blue 0.37: Blue 0.374: Blue 0.3749999: Blue 0.375: Blue <-------- This is where the source video turns from Green to Blue 0.37500000: Blue 0.3751: Blue 0.4: Blue 0.41: Blue 0.416: Blue 0.416666: Blue 0.4166667: Blue In summary, I'm more confused than when I started. It seems (though I haven't tried hairier time values, e.g. with frame rate 23.976) that seeking may compute the closest start frame - i.e. simply round. But then the output seems to be working in some other way: what's the distinction between time 0.312501 (1 frame of Green) and 0.3125001 (2 frames of Green)? I don't know. Any help here is much appreciated. Thanks! Tom On Wed, Aug 18, 2021 at 09:26:03PM -0600, amindfv--- via ffmpeg-user wrote: > How are frame numbers converted to and from decimal numbers of seconds in > ffmpeg and related tools? > > For example, given a file foo.mp4 at 24fps, when I run a command like: > > ffmpeg -i foo.mp4 -t 0.72 bar.mp4 > > 0.72 is a time between frame 18 (0.70833... seconds) and frame 19 (0.75 > seconds). > > In my tests, it seems that the number of seconds is rounded down, i.e. any > value less than 0.75 is equivalent to the earlier frame. > > Is this always true? Is this the best way to think about the decimal > seconds<->frame number conversion? Is there any difference (e.g. in audio > track duration) between saying 0.71 or 0.73 in the above? > > Thanks, > Tom > > _______________________________________________ > ffmpeg-user mailing list > ffmpeg-user@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-user > > To unsubscribe, visit link above, or email > ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe". _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".