[FFmpeg-user] Faster ffprobe-based detection of open GOP h264 ?
Andrew Randrianasulu
randrianasulu at gmail.com
Thu Jan 11 02:13:20 EET 2024
I was looking at videohelp forum
https://web.archive.org/web/20201125203546/https://forum.videohelp.com/threads/398119-Cutting-Open-GOP-H264-videos-properly
(web archive link because it hopefully will stay active for some time even
if forum software will be upgraded and ruin old links in the future)
It provides this ffprobe-based method of seeing if given h264 video stream
is Open GOP or not :
echo entry,pkt_pts_time,pict_type,coded_picture_number > "%~n1.csv"
ffprobe -v 32 -stats -y -hide_banner -i %1 -select_streams v -print_format
csv -of csv -show_entries
"frame=pkt_pts_time,pict_type,coded_picture_number" >> "%~n1.csv"
=== quote ====
You can see that the last frame of the first GOP is a B frame -- so that's
an open GOP. Also, the coded picture number is higher than that of the I
frame after it -- indicating that the I frame had to be decoded before the
B frame, another indication of an open GOP.
=== quote ends ===
I checked one of my videos:
ffprobe -v 32 -stats -y -hide_banner -i
~/Sea_of_life_plus_Mikura_dolphins_test.mp4 -select_streams v -print_format
csv -of csv -show_entries
"frame=pkt_pts_time,pict_type,coded_picture_number" >> "Sea_of_life-n1.csv"
and it seems resulting cvs file show it as open GOP consistently with
mediainfo:
frame,8.308300,B,250
frame,8.341667,I,249
frame,8.375033,B,253
mediainfo (v23.11) snip:
=== snip ===
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High at L4.1
Format settings : 4 Ref Frames
Format settings, CABAC : No
Format settings, Reference frames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 5 min 4 s
Bit rate : 16.0 Mb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 (30000/1001) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.257
Stream size : 575 MiB (99%)
Writing library : x264 core 148
Encoding settings : cabac=0 / ref=3 / deblock=1:0:0
/ analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 /
mixed_ref=1 / me_range=16 / chroma_me=0 / trellis=1 / 8x8dct=1 / cqm=0 /
deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=3 /
lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 /
bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=0
/ b_bias=0 / direct=1 / weightb=1 / open_gop=1 / weightp=2 / keyint=250 /
keyint_min=25 / scenecut=0 / intra_refresh=0 / rc_lookahead=40 / rc=abr /
mbtree=1 / bitrate=16000 / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=51 /
qpstep=4 / ip_ratio=1.41 / aq=1:1.00
Codec configuration box : avcC
==== snip ends ===
So, at least I may try to cut this video at various intervals and see if
cutting breaks on specifically open-gop h264 stream.
But as it was said in forum post above - ffprobe a bit slow, few minutes
for whole video, eating one cpu core completely.
Is there faster way to get this info ?
More information about the ffmpeg-user
mailing list