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.

So to start out with, I having figured out how to animate a number of still frames into a video, like this:

avconv -f image2 -i %06d.png -r 24 -qscale 1 aniron.avi

I have a bunch of files in the directory named 000000.png, 000001.png, 000002.png. I am able to make a video of sufficiently high quality this way. However, efforts to add an audio track by putting "-i aniron.mp3" and a few other options have failed thus far. I always get this:

avconv version 0.8.5-4:0.8.5-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav 
  built on Jan 24 2013 18:03:14 with gcc 4.6.3
[mp3 @ 0x8623aa0] max_analyze_duration reached
[mp3 @ 0x8623aa0] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'aniron.mp3':
    encoder         : Lavf52.64.2
    TDTG            : 2012-07-28T18:05:36
  Duration: 00:07:11.46, start: 0.000000, bitrate: 191 kb/s
    Stream #0.0: Audio: mp3, 44100 Hz, stereo, s16, 192 kb/s
Input #1, image2, from '%06d.png':
  Duration: 00:07:09.88, start: 0.000000, bitrate: N/A
    Stream #1.0: Video: png, rgb24, 1920x1080, 25 fps, 25 tbr, 25 tbn, 25 tbc
File 'aniron.avi' already exists. Overwrite ? [y/N] y
Incompatible pixel format 'rgb24' for codec 'mpeg4', auto-selecting format 'yuv420p'
[buffer @ 0x8629500] w:1920 h:1080 pixfmt:rgb24
[avsink @ 0x8657d60] auto-inserting filter 'auto-inserted scaler 0' between the
filter 'src' and the filter 'out'
[scale @ 0x8634940] w:1920 h:1080 fmt:rgb24 -> w:1920 h:1080 fmt:yuv420p flags:0x4
Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'
[ac3 @ 0x86438e0] invalid bit rate
Output #0, avi, to 'aniron.avi':
    encoder         : Lavf52.64.2
    TDTG            : 2012-07-28T18:05:36
    Stream #0.0: Video: mpeg4, yuv420p, 1920x1080, q=2-31, 200 kb/s, 90k tbn, 24 tbc
    Stream #0.1: Audio: ac3, 44100 Hz, stereo, flt, 200 kb/s
Stream mapping:
  Stream #1:0 -> #0:0 (png -> mpeg4)
  Stream #0:0 -> #0:1 (mp3 -> ac3)
Error while opening encoder for output stream #0:1 - maybe incorrect parameters such
as bit_rate, rate, width or height

I may just end up doing this in Kdenvlive but this is bugging me.

share|improve this question
The problem appears to be that by default it is trying to re-encode your input MP3 into AC3 format. This is causing an error since the AC3 encoder apparently doesn't like 16bit samples (I suspect it prefers more). By adding -c:a copy after -i somefile.mp3 it should re-use the MP3 input rather than transcoding it. –  chronitis Feb 5 '13 at 10:46
add comment

3 Answers

avconv -f image2 -i %06d.png -r 24 -qscale 1 -i audiofile.mp3 -c:a copy aniron.avi

Things to note:

  • -c:a determines the output audio codec - we just copy the one from the input file here
  • The avi container is quite lacking, for example, you might get sync problems if your mp3 file is VBR. A better alternative would be MP4 or MKV.
  • You might specify the output video codec (-c:v) if you don't like the default one
  • As for ffmpeg vs. avconv: ffmpeg is far from deprecated - this is deliberately misleading. If you're interested read this
share|improve this answer
for the record: I dont't see anyone in this thread suggesting ffmpeg was deprecated: Sadiq asked if it might be. I answered that is wasnt. If that was the reason the other was downvoted, please read more carefull. Cheers. –  matv1 Feb 5 '13 at 18:38
Yes I know, but I didn't downvote your answer ;D –  phoibos Feb 5 '13 at 18:51
Alright phoibos, I had sucess with your answer ... after a fashion. It worked after I permuted the arguments. I'm going to submit what worked, upvote your answer, but accept mine. –  Sadiq Feb 6 '13 at 13:02
add comment

How about using ffmpeg on the avi you created? Syntax would be something like:

ffmpeg -i sound.wav -i input.avi output.mpg

I an not sure if it will take mp3 as audio import so you might have to do a conversion of your soundfile.

Gd luck

share|improve this answer
I'll consider it but isn't ffmpeg deprecated? That means it might disappear soon. I'm sort of uncomfortable with using it then. Anyway, right now I'm wrestling with kdenlive, sigh... –  Sadiq Feb 5 '13 at 8:50
I don't think its deprecated. There has been a Libav fork off ffmpeg but the latter is still being developped. –  matv1 Feb 5 '13 at 9:05
I think I figured out the voodoo I need to get the ugly black bars out of the kdenlive video. Thanks for the help anyway. I'll let you know whether it works shortly. –  Sadiq Feb 5 '13 at 9:08
Sorry it didn't work. Virtually same error as before. And I hate to say it but I do get the message "This program is only provided for compatibility and will be removed in a future release. Please use avconv instead." –  Sadiq Feb 5 '13 at 9:14
ffmpeg and avconv are the results of a rather acrimonious splitting of the original ffmpeg project. At this time the syntax and capabilities of the two are very similar. Debian (upon which Ubuntu is based) has chosen in theory to follow the avconv rather than ffmpeg fork, but it is unlikely that the latter will cease to be available. –  chronitis Feb 5 '13 at 10:43
add comment

This worked in that all arguments were respected; the output was what I wanted, in great quality:

avconv -f image2 -i %06d.png -i aniron.mp3 -c:a copy -r 24 -qscale 1 test.avi

Order of arguments is a subtle annoyance in avconv and ffmpeg.

share|improve this answer
add comment

Your Answer


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.