11

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?

3 Answers 3

8

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"

4
  • 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
    – RoboJ1M
    May 10, 2013 at 8:00
  • 1
    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.
    – rmsr
    Jun 26, 2013 at 0:20
  • 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.
    – Sparhawk
    Apr 8, 2014 at 12:10
  • This solution works also for ffmpeg
    – c97
    Jan 23, 2015 at 22:11
8

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
4
  • 1
    This still gives me the same error :/
    – Felix
    May 26, 2014 at 22:31
  • works for me with avconv version 0.8.16, until it displayed an odd Can't write packet with unknown timestamp at the end of the file. Weird.
    – malat
    Jan 31, 2015 at 13:40
  • 2
    Make sure -fflags is used as an input option: it has to go before your -i input. But probably it wouldn't have worked at all if you hadn't put +genpts in the right place. Feb 5, 2015 at 1:51
  • This works fine with avconv 9.18-6:9.18-0ubuntu0.14.04.1 as well
    – Elder Geek
    Nov 18, 2015 at 1:33
2

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .