Reputation: 33
Is it possible to extract the seekpoints/keyframes from a MP4 file in the following fashion:
Keyframe - Time Range (in seconds) - Offset (in bytes)
Example: 0 - 0s - 77262
1 - 0.5s - 144183
2 - 1s - 222965
3 - 1.5s - 293303
4 - 2s - 362199
5 - 2.5s - 431178
Thanks in advance.
Upvotes: 0
Views: 691
Reputation: 133703
You can use ffprobe
. Perhaps something like this:
ffprobe -show_frames -select_streams v:0 -show_entries frame=key_frame,coded_picture_number,pkt_pts_time,pkt_pos input.mp4 | grep -A 3 "key_frame=1"
Results in:
key_frame=1
pkt_pts_time=0.000000
pkt_pos=48
coded_picture_number=0
--
key_frame=1
pkt_pts_time=10.000000
pkt_pos=47130
coded_picture_number=250
--
key_frame=1
pkt_pts_time=20.000000
pkt_pos=92713
coded_picture_number=500
--
key_frame=1
pkt_pts_time=30.000000
pkt_pos=138159
coded_picture_number=750
key_frame=1
indicates that the particular frame is a key frame.
You may have to choose section_entries
if this example does not give you exactly what you want. See man ffprobe
.
See the -print_format
option to change the output printing format (default, compact, csv, flat, ini, json, xml). You may have to perform additional processing to get what you want.
Upvotes: 1