I need to get the frame type (I/B/P) of a specific frame number for an x264 encoded movie.
How do I do this using ffmpeg/ffprobe? I'm open to other solutions as well.
I need to get the frame type (I/B/P) of a specific frame number for an x264 encoded movie.
How do I do this using ffmpeg/ffprobe? I'm open to other solutions as well.
You can use ffmpeg directly
ffmpeg -i input.mp4 -vf select='eq(n,334)',showinfo -f null -
The above will produce an output for the 335th frame of the video
n: 0 pts: 171008 pts_time:11.1333 pos: 1090471 fmt:yuv420p sar:1/1 s:1280x720 i:P iskey:0 type:B checksum:A72D197D plane_checksum:[9008E835 680AC49A 6CD66C90] mean:[136 122 134] stdev:[65.4 7.0 9.5]
You can skip the select filter and get output for all frames and then grep like @incBrain does. Note that you want the display picture number
, not coded.
ffmpeg -i input.mkv -vf "select=eq(n\,100),showinfo -f null - 2>&1 | grep type: | awk '{split($16,a,":"); print a[2]}'
–
Uracil I found the way how to do it using ffprobe
and grep
:
$ ffprobe video.mp4 -show_frames | grep -E 'pict_type|coded_picture_number'
This produces an output like this:
pict_type=I
coded_picture_number=0
pict_type=B
coded_picture_number=3
pict_type=B
coded_picture_number=2
pict_type=P
coded_picture_number=1
pict_type=B
coded_picture_number=6
...
To get the frame type for specific frame (e.g. frame 8) you can extend it to this:
$ ffprobe video.mp4 -show_frames | grep -w -E 'coded_picture_number=8' -B 1
pict_type=P
coded_picture_number=8
ffprobe video.mp4 -show_frames | findstr "pict_type"
. –
Tazza You can use ffmpeg directly
ffmpeg -i input.mp4 -vf select='eq(n,334)',showinfo -f null -
The above will produce an output for the 335th frame of the video
n: 0 pts: 171008 pts_time:11.1333 pos: 1090471 fmt:yuv420p sar:1/1 s:1280x720 i:P iskey:0 type:B checksum:A72D197D plane_checksum:[9008E835 680AC49A 6CD66C90] mean:[136 122 134] stdev:[65.4 7.0 9.5]
You can skip the select filter and get output for all frames and then grep like @incBrain does. Note that you want the display picture number
, not coded.
ffmpeg -i input.mkv -vf "select=eq(n\,100),showinfo -f null - 2>&1 | grep type: | awk '{split($16,a,":"); print a[2]}'
–
Uracil © 2022 - 2024 — McMap. All rights reserved.
-debug vis_mb_type
. This should print nal unit types to stdout – Martinmasffplay video.mp4 -vf showinfo
, this prints all pic types to screen. Previous command worked only for hevc for some reason – Martinmas