I'm trying to script-cut a 24 fps video and it gets close to the right thing, except for two missing frames at the beginning of every segment I cut with seeking.

I've found out that index-frames (keyframes) could become an issue for seeking, so I first create an intermediate file with every frame as a index frame using this line:

ffmpeg -i input.mov -c:v libx264 -g 1 -c:a copy intermediate.mp4

Then I proceed to make a cut with this line. Notice I'm drawing some text on top of it:

ffmpeg -hide_banner -y -i intermediate.mp4 -ss 00:00:02.083333333333 -to 00:00:02.875000000000 -vf drawtext=fontfile=DroidSans.ttf:fontsize=48:text="segment2":fontcolor=yellow:box=1:boxborderw=16:boxcolor=black@0.5:x=w/32:y=h/18 output.mp4

No matter the length of the segment, the first two frames get dropped.

I'm using python do control ffmpeg.

Any ideas?


Running ffprobe on one of the generated segments with ffprobe -hide_banner Nixing_0010_0010.mp4 says the following:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Nixing_0010_0010.mp4':

Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf57.82.101 Duration: 00:00:02.11, start: 0.000000, bitrate: 4717 kb/s Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4751 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default) Metadata: handler_name : VideoHandler timecode : 00:00:00:00 Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 2 kb/s (default) Metadata: handler_name : SoundHandler Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s Metadata: handler_name : TimeCodeHandler timecode : 00:00:00:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.