Using avconv, when remuxing to MKV, is there a way to fix packed AVI input files?

10,578

Solution 1

A workaround is to convert to .mp4 first:

avconv -i input.avi -c copy temp.mp4
avconv -i temp.mp4 -c copy output.mkv
rm temp.mp4

Sadly, one cannot simply pipe the mp4 format between avconv instances: "[mp4 @ 0x80846c0] muxer does not support non seekable output"

Solution 2

As of this ticket #1979 at ffmpeg bugtracker the simplest solution is to have this bug fixed or to manually add -fflags +genpts to the command line.

I.e. change

ffmpeg -i inputfile_that_cant_be_muxed_into_mkv.ext -c copy out.mkv

to

ffmpeg -fflags +genpts -i inputfile_that_cant_be_muxed_into_mkv.ext -c copy out.mkv

Solution 3

Thanks to Andreas Cadhalpun ffmpeg now has new filter: mpeg4_unpack_bframes (see ref). This will allow you to get rid of the message: Invalid and inefficient vfw-avi packed B frames detected.

Usage is as simple as:

ffmpeg -i INPUT.avi -codec copy -bsf:v mpeg4_unpack_bframes OUTPUT.avi
Share:
10,578

Related videos on Youtube

RoboJ1M
Author by

RoboJ1M

@RoboJ1M

Updated on September 18, 2022

Comments

  • RoboJ1M
    RoboJ1M almost 2 years

    Due to compatibility bugs between Plex server and Panasonic TVs, the only way to get it to work well is remux everything to MKV, straight copy all streams (video, audio, subtitle)

    Seems simple enough:

    avconv -i "input.avi" -c copy "output.mkv"
    

    Except:

    avconv version 0.8.6-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
      built on Apr  2 2013 17:00:59 with gcc 4.6.3
    [mpeg4 @ 0x8422140] Invalid and inefficient vfw-avi packed B frames detected
    Input #0, avi, from 'input.avi':
      Metadata:
        encoder         : VirtualDubMod 1.5.4.1 (build 2117/release)
      Duration: 00:27:38.52, start: 0.000000, bitrate: 1173 kb/s
        Stream #0.0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 640x352 [PAR 1:1 DAR 20:11], 25 tbr, 25 tbn, 25 tbc
        Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 132 kb/s
    File 'output.mkv' already exists. Overwrite ? [y/N] y
    Output #0, matroska, to 'output.mkv':
      Metadata:
        encoder         : Lavf53.21.1
        Stream #0.0: Video: mpeg4, yuv420p, 640x352 [PAR 1:1 DAR 20:11], q=2-31, 1k tbn, 25 tbc
        Stream #0.1: Audio: libmp3lame, 48000 Hz, stereo, 132 kb/s
    Stream mapping:
      Stream #0:0 -> #0:0 (copy)
      Stream #0:1 -> #0:1 (copy)
    Press ctrl-c to stop encoding
    [matroska @ 0x8422cc0] Can't write packet with unknown timestamp
    av_interleaved_write_frame(): Invalid argument
    

    With the relevant gotcha lines being:

    [mpeg4 @ 0x8422140] Invalid and inefficient vfw-avi packed B frames detected#
    <snip>
    [matroska @ 0x8422cc0] Can't write packet with unknown timestamp
    av_interleaved_write_frame(): Invalid argument
    

    I can't see an option to unpack the B frames (or build a VBR timemap? do we need those in avconv?)

    Is there a way to do this, like in avidemux?

  • RoboJ1M
    RoboJ1M about 11 years
    Thanks, I shall try it out this evening. I wonder if there is a command that acts like a buffer? Waits for the command writing to stdin to complete before passing it all to stdout. With seek on stdout. That would be handy. avconv -i xxx | buf | avconv -i stdin xxx
  • rmsr
    rmsr about 11 years
    The error message I appended is specifically related to trying to use pipes with avconv, as pipes are inherently non-seekable. The best one can do is to locate temp.mp4 on a tmpfs or similar in-memory filesystem. /dev/shm/ is a good candidate for this, if one has enough RAM.
  • Sparhawk
    Sparhawk about 10 years
    Regarding piping, you can probably do it with named pipes aka fifo. Have a search for mkfifo. Essentially, you use a file as a temporary storage for stout.
  • Felix
    Felix about 10 years
    This still gives me the same error :/
  • c97
    c97 over 9 years
    This solution works also for ffmpeg
  • Elder Geek
    Elder Geek over 8 years
    This works fine with avconv 9.18-6:9.18-0ubuntu0.14.04.1 as well