[FFmpeg-trac] #5152(ffmpeg:new): Broken B frames while copying MPEG-2 ibp without recompression from some point

FFmpeg trac at avcodec.org
Tue Jan 12 11:48:14 CET 2016

#5152: Broken B frames while copying MPEG-2 ibp without recompression from some
             Reporter:               |                     Type:  defect
  Aleksandr_Slobodeniuk              |                 Priority:  normal
               Status:  new          |                  Version:  git-
            Component:  ffmpeg       |  master
             Keywords:  Opened Gop,  |               Blocked By:
  keyframes                          |  Reproduced by developer:  0
             Blocking:               |
Analyzed by developer:  0            |
 Copying ibp video without recompression from start point to the end point
 generates video with several broken frames in the start and in the end of
 the result file.

 '''How to reproduce:'''
 % ffmpeg -i opengop.mov -ss 3 -t 1 -c copy result.mov
 (the container does not matter)
 % ffmpeg -i result.mov %d.png
 opengop.mov is stored here [https://yadi.sk/d/z5RvZNremqCxN]

 ffmpeg version is the last from zeranoe:
 ffmpeg-latest-win32-static.7z                          10-Jan-2016 01:39


 "Opened GOP" - is MPEG-2 with B-frames, that depend on previous and next
 key frames. And this B frames are going before I frame in the decoded
 video stream.

 In decoded video stream it is going like b-b-b-I-..
 In the file it is layed like I-b-b-b , because it's impossible to decode
 "b"s without the "next going" I.

 So, the problem of "opened gop" begins when you export video from some
 point, because there is no point (in the file) from where you can start
 copying frames without leaving first and last frames without the frames
 they depend on. So you can't just step to the previous or next I frame in
 the file, because you will get I-b-b-b that's decoding like b-b-b-I , and
 this b frames depend on the previous key frame.

 Maybe you need to force recompression of the "half-of-the-gop" in the
 beginning and in the end of the file, but I'm not sure this will work,
 because the next going b-frames after the I-frames will still have their
 dependencies, but at least they'll have an actual picture before.

Ticket URL: <https://trac.ffmpeg.org/ticket/5152>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker

More information about the FFmpeg-trac mailing list