title: Setting B frames in a video with ffmpeg
body: <p>According to ffmpeg manual, setting <code>-g</code> is to define space between "I" frames, and setting <code>-bf</code> to use "B" frames. The former I got, but the latter not.</p>
  
  <p>The goal: I'm trying to have a video with a GOP 3,12 (M= 3, N=12).
  That means: 2 "B" frames separating each "P" frames, and "I" frames with 12 frames of distance. Or simply: "IBBPBBPBBPBBI"</p>
  
  <p>I think that I got only the N=12, using the commands below:</p>
  
  <ol>
  <li><code>ffmpeg -s cif -r 30 -b 64000 -bt 3200 -g 12 -y -i video.yuv -vcodec mpeg4 video.m4v</code></li>
  <li><code>MP4Box -hint -mtu 1460 -fps 30 -add video.m4v video.mp4</code></li>
  <li><code>ffmpeg -y -i video.mp4 video_ref.yuv</code></li>
  <li><code>../cmd/psnr 352 288 420 video.yuv video_ref.yuv &gt; psnr_ref.txt</code></li>
  <li><code>../cmd/mp4trace -f -s 192.168.0.2 12346 video.mp4 &gt; trace</code></li>
  <li><code>head -n 20 trace</code></li>
  </ol>
  
  <p>Result:</p>
  
  <pre><code>[robert@10-2Fontes]$ head -n 20 trace
  1   H   12002   9   0.000
  2   P   11479   8   0.034
  3   P   12021   9   0.066
  4   P   11239   8   0.099
  5   P   5407    4   0.134
  6   P   2735    2   0.166
  7   P   1014    1   0.199
  8   P   850 1   0.232
  9   P   619 1   0.265
  10  P   979 1   0.298
  11  P   813 1   0.331
  12  P   806 1   0.364
  13  H   5109    4   0.396
  </code></pre>
  
  <p>*Note, the most important is the command <code>-g 12</code> in ffmpeg, but I writing all the commands. The video that I'm using is the "highway", from cif page videos: <a href="http://www2.tkn.tu-berlin.de/research/evalvid/cif.html" rel="noreferrer">http://www2.tkn.tu-berlin.de/research/evalvid/cif.html</a></p>
  
  <p>I don't know why the result trace is using "H" instead of "I".</p>
  
  <p>I tried to put <code>-bf 2</code> in ffmpeg command, but did not worked (I think because I saw no "B" indications in the result)</p>
  
  <p>List item</p>
  
  <pre><code>ffmpeg -s cif -r 30 -b 64000 -bt 3200 -g 12 -bf 2 -y -i video.yuv -vcodec mpeg4 video.m4v
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>[robert@10-2Fontes]$ head -n 20 trace
  1   H   12002   9   0.001
  2   P   11479   8   0.034
  3   P   12021   9   0.067
  4   P   11239   8   0.100
  5   P   5407    4   0.132
  6   P   2735    2   0.166
  7   P   1014    1   0.199
  8   P   850 1   0.232
  9   P   619 1   0.265
  10  P   979 1   0.298
  11  P   813 1   0.331
  12  P   806 1   0.363
  13  H   5109    4   0.400
  </code></pre>