FFmpeg/avidemux: fix packed B-frames

9,861

B-frames are a frame type used in video compression to represent frames of a video. B-frames can use information from both previous and future frames to represent each video frame.

Older DivX-encoded videos commonly use an ugly method called packed bitstream which puts several video frames into a single AVI chunk. Packed bitstream isn't standard MPEG-4, uses more space, requires more CPU power to encode/decode, and (most importantly) may cause problems if copied into another container type. This is the main reason for the warning.

Since you're re-encoding the video instead of just copying it, you should be fine. If you wanted to keep the original video, but copy it into another type of container (say MP4 or MKV), it'd be best to unpack the B-frames first using the FFmpeg filter mpeg4_unpack_bframes.

You could unpack the B-frames with something simple like

ffmpeg -i INPUT.avi -codec copy -bsf:v mpeg4_unpack_bframes OUTPUT.avi
Share:
9,861

Related videos on Youtube

4ae1e1
Author by

4ae1e1

Updated on September 18, 2022

Comments

  • 4ae1e1
    4ae1e1 almost 2 years

    I'm transcoding some of my old mpeg4 videos (in avi containers) to h.264 with FFmpeg. Basically

    ffmpeg -i input.avi -c:v libx264 [x264 settings] -c:a libfdk_aac [aac settings] output.mp4
    

    When doing so, mpeg4 issues the following warning

    Video uses a non-standard and wasteful way to store B-frames ('packed B-frames'). Consider using a tool like VirtualDub or avidemux to fix it.

    I know I can still successfully transcode, but from the warning it is not clear to me whether the quality of the resulting h.264 video will be affected.

    So,

    • Given that I only care about the quality (and size, I want to minimize the size for my mobile devices, which is why I'm also using the veryslow preset) of the output h.264 video, should I care about the packed B-frames?

    • If I should, how do I fix them with avidemux? (I already tried skimming through the manual.)