0
votes

ffmpeg -i instagram.mp4 -vf fps=29.97 thumb%06d.jpg -hide_banner

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'instagram.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf55.19.104 Duration: 00:00:13.61, start: 0.000000, bitrate: 1163 kb/s Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x640 [SAR 1:1 DAR 1:1], 1099 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 59.94 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 64 kb/s (default) Metadata: handler_name : SoundHandler Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native)) Press [q] to stop, [?] for help [swscaler @ 0x55b2b53cf440] deprecated pixel format used, make sure you did set range correctly Output #0, image2, to 'thumb%06d.jpg':
Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf57.83.100 Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 640x640 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc (default) Metadata: handler_name : VideoHandler encoder : Lavc57.107.100 mjpeg Side data: cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1 frame= 405 fps=231 q=24.8 Lsize=N/A time=00:00:13.51 bitrate=N/A speed=7.72x video:5961kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

The video duration is 13.61 seconds and frame rate is 29.97. So I was expecting 13.61 * 29.97 = 407.8917 i.e. 407 frames. But have got 405 frames. I am new to ffmpeg, need help to correctly get all 407 frames.

I had also tried following command,

ffmpeg -i instagram.mp4 thumb%06d.jpg -hide_banner

but the output was same 405 frames.

Possibly the start 2 frames are missing.

I need to display the frames generated in the base video timeline. And on clicking on the frame I need to exactly seek the video to the frame position using HTML5 currentTime. Since the first 2 frames are not getting available, exact mapping is not getting possible.

Please guide.

1
Does the input video start with a keyframe?Eugen Rieck
@EugenRieck Thanks for reply. How to recognize whether it starts with keyframe?Vrajesh Doshi
The file duration shown is the duration for the longest stream. Check the duration for the video stream using ffmpeg -i instagram.mp4 -an -f null -Gyan
@oguz ismail on executing the command no output got printed. i.e. the output was blank instead of 1. Is there a way to explicitly get all 407 frames of the video?Vrajesh Doshi
@Gyan on executing your command I got the same duration. i.e. 13.61 sec. So right number of frames that I should get is 407 right? as per fps = 29.97.Vrajesh Doshi

1 Answers

0
votes

have you try to use -vsync vfr or -vsync 0 disables the frame drop/dup behaviour? @Gyan Please refer to this question.

https://superuser.com/questions/1374584/why-does-ffmpeg-extracts-a-lot-more-frames-than-the-actual