<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
I'm trying to find the number of reference frames used by a video using the avcodec/format API. From the API description it seems that all I have to do is to use:<br>
<br>
AVCodecContext::refs</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
... but that value is always at 1. I know for sure (both since I encoded the file and for the mediainfo output) that the ref frames of my sample video files are different.<br>
<br>
I'm quite sure it's a bug of ffmpeg since also if I check the reference frame number using ffmpeg/ffprobe (master, compiled 10 minutes before writing this post) it returns 1 for the given video file (that should have 5).<br>
<br>
Further digging in the net about this problem I found also a ticket about this: <br>
<br>
<a href="https://trac.ffmpeg.org/ticket/6001" id="LPlnk">https://trac.ffmpeg.org/ticket/6001</a><br>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview _EReadonly_1">
<div id="LPBorder_GTaHR0cHM6Ly90cmFjLmZmbXBlZy5vcmcvdGlja2V0LzYwMDE." class="LPBorder293676" style="width: 100%; margin-top: 16px; margin-bottom: 16px; position: relative; max-width: 800px; min-width: 424px;">
<table id="LPContainer293676" role="presentation" style="padding: 12px 36px 12px 12px; width: 100%; border-width: 1px; border-style: solid; border-color: rgb(200, 200, 200); border-radius: 2px;">
<tbody>
<tr style="border-spacing: 0px;" valign="top">
<td style="width: 100%;">
<div id="LPTitle293676" style="font-size: 21px; font-weight: 300; margin-right: 8px; font-family: "wf_segoe-ui_light", "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; margin-bottom: 12px;">
<a target="_blank" id="LPUrlAnchor293676" href="https://trac.ffmpeg.org/ticket/6001" style="text-decoration: none; color:var(--themePrimary);">#6001 (ffprobe: incorrect determination of the number of reference frames) – FFmpeg</a></div>
<div id="LPDescription293676" style="font-size: 14px; max-height: 100px; color: rgb(102, 102, 102); font-family: "wf_segoe-ui_normal", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; margin-bottom: 12px; margin-right: 8px; overflow: hidden;">
Hi! ffprobe incorrect determinates of the number of reference frames. ffprobe for all video returns refs=1, which does not coincide with the values returned by MediaInfo?. The attached txt file contains information returned by ffprobe and MediaInfo?.</div>
<div id="LPMetadata293676" style="font-size: 14px; font-weight: 400; color: rgb(166, 166, 166); font-family: "wf_segoe-ui_normal", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif;">
trac.ffmpeg.org</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
... that is opened since 5 years <span id="🙁">🙁</span> <br>
<br>
If someone wants to take a look at this problem, here is the test file I used <br>
<a href="http://cdn5.wyscout.com/get/" id="LPlnk526311"><br>
http://cdn5.wyscout.com/get/</a>video.mp4<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
Here is the mediainfo report of that file:<br>
<br>
iMac-2 $ mediainfo ~/Desktop/video.mp4
<div>General</div>
<div>Complete name : video.mp4</div>
<div>Format : MPEG-4</div>
<div>Format profile : Base Media</div>
<div>Codec ID : isom (isom/iso2/avc1/mp41)</div>
<div>File size : 8.30 MiB</div>
<div>Duration : 29 s 143 ms</div>
<div>Overall bit rate mode : Variable</div>
<div>Overall bit rate : 2 388 kb/s</div>
<div>Performer : Q2xpcHBlciAzODQgKGlwLTEwLTUtMy04NCk=}</div>
<div>Writing application : Lavf58.20.100</div>
<div><br>
</div>
<div>Video</div>
<div>ID : 1</div>
<div>Format : AVC</div>
<div>Format/Info : Advanced Video Codec</div>
<div>Format profile : Baseline@L3.1</div>
<div>Format settings : <b>5 Ref Frames</b></div>
<div>Format settings, CABAC : No</div>
<div>Format settings, Reference frames : 5 frames</div>
<div>Format settings, GOP : M=1, N=25</div>
<div>Codec ID : avc1</div>
<div>Codec ID/Info : Advanced Video Coding</div>
<div>Duration : 29 s 120 ms</div>
<div>Bit rate : 2 200 kb/s</div>
<div>Width : 1 280 pixels</div>
<div>Height : 720 pixels</div>
<div>Display aspect ratio : 16:9</div>
<div>Frame rate mode : Constant</div>
<div>Frame rate : 25.000 FPS</div>
<div>Color space : YUV</div>
Chroma subsampling : 4:2:0<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
[...]<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
... and here is what ffmpeg/ffprobe says of the file (master, but also 4.2.x has the same results) :<br>
<br>
iMac-2 $ ./ffmpeg -loglevel verbose -i ~/Desktop/video.mp4
<div>ffmpeg version N-101901-gb593abda6c Copyright (c) 2000-2021 the FFmpeg developers</div>
<div> built with Apple clang version 12.0.0 (clang-1200.0.32.29)</div>
<div> configuration: --disable-lzma --prefix=/usr/local/sdk/darwin-x64 --enable-libx264 --enable-libfdk-aac --enable-nonfree --enable-gpl --enable-libopus --enable-libvpx --enable-libvorbis --enable-pic --disable-sdl2</div>
<div> libavutil 56. 72.100 / 56. 72.100</div>
<div> libavcodec 58.135.100 / 58.135.100</div>
<div> libavformat 58. 78.100 / 58. 78.100</div>
<div> libavdevice 58. 14.100 / 58. 14.100</div>
<div> libavfilter 7.111.100 / 7.111.100</div>
<div> libswscale 5. 10.100 / 5. 10.100</div>
<div> libswresample 3. 10.100 / 3. 10.100</div>
<div> libpostproc 55. 10.100 / 55. 10.100</div>
<div>[h264 @ 0x7faec700b000] Reinit context to 1280x720, pix_fmt: yuv420p</div>
<div>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/gabry/Desktop/video.mp4':</div>
<div> Metadata:</div>
<div> major_brand : isom</div>
<div> minor_version : 512</div>
<div> compatible_brands: isomiso2avc1mp41</div>
<div> artist : Q2xpcHBlciAzODQgKGlwLTEwLTUtMy04NCk=}</div>
<div> encoder : Lavf58.20.100</div>
<div> Duration: 00:00:29.14, start: 0.000000, bitrate: 2388 kb/s</div>
<div> Stream #0:0(und): Video: h264 (Constrained Baseline), <b>1 reference frame</b> (avc1 / 0x31637661), yuv420p(left), 1280x720 [SAR 1:1 DAR 16:9], 2296 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)</div>
<div> Metadata:</div>
<div> handler_name : VideoHandler</div>
<div> vendor_id : [0][0][0][0]</div>
<div> Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 87 kb/s (default)</div>
<div> Metadata:</div>
<div> handler_name : SoundHandler</div>
<div> vendor_id : [0][0][0][0]</div>
<br>
<br>
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
<br>
</div>
</body>
</html>