Reputation: 12107
I am trying to find the fastest way to get a list of all I-frames in a movie.
So far, I tried ffprobe, but it is quite slow and I have been looking for a faster solution.
The other option I found is using the mp4parser tool; it outputs a file with this sectio, the SSTS info:
-------------------------------------------------------------------------
/moov/trak/mdia/minf/stbl/stss @ 0x1c152d8
Box size: 0x44 version: 0x0 flags: 0x0
entry_count: 0xd
sample_number:
0x1 0x12d 0x259 0x385 ....
I can see that I have 13 I frames and they're spaced 300 frames apart (from the 4 values displayed)
Is the spacing of I frames constant through movies? or do I need to write my own SSTS parser to get the whole list?
Upvotes: 1
Views: 799
Reputation: 93038
The command below will quickly provide the timestamp for video keyframes along with other info.
ffmpeg -skip_frame nokey -i in.mp4 -an -vf showinfo -f null -
Output looks like
[Parsed_showinfo_0 @ 00000000032903a0] n: 55 pts:5748224 pts_time:449.08 pos: 17288779 fmt:yuv420p sar:1/1 s:960x720 i:P iskey:1 type:I checksum:361866A6 plane_checksum:[BA2DCCBF A8E937B3 BD006225] mean:[220 117 133] stdev:[57.8 4.1 5.3]
The pts_time
gets you the time index. The n
is not accurate for absolute frame index, but it is an accurate count for keyframe index i.e. n: 55
is the 56th keyframe in the video.
Upvotes: 1