Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

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"

share|improve this answer
    
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 '13 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 '13 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 at 12:10
add comment

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
share|improve this answer
    
This still gives me the same error :/ –  nissemand May 26 at 22:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.