Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I know really little about encoding and using avconv / ffmpeg. I am trying to downsample a video as follows:

avconv -i blah_in.avi -s 640x360 -pass 1 blah.avi
avconv -i blah_in.avi -s 640x360 -pass 2 blah.avi

I am aware that this is very simplistic, yet I can't figure out what the problem is. Here is the error message from pass 1:

avconv version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
  built on Jun 12 2012 16:37:58 with gcc 4.6.3
[avi @ 0x9fdd240] non-interleaved AVI
Input #0, avi, from 'blah_in.avi':
  Metadata:
    encoder         : MEncoder svn r34540 (Ubuntu), built with gcc-4.6
  Duration: 01:21:59.24, start: 0.000000, bitrate: 8996 kb/s
    Stream #0.0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 23.98 tbr, 23.98 tbn, 23.98 tbc
    Stream #0.1: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s
File 'blah.avi' already exists. Overwrite ? [y/N] y
[buffer @ 0x9fe1e00] w:1920 h:1080 pixfmt:yuv420p
[scale @ 0x9fdcfa0] w:1920 h:1080 fmt:yuv420p -> w:640 h:360 fmt:yuv420p flags:0x4
Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'
[ac3 @ 0x9fdc740] invalid bit rate
Output #0, avi, to 'blah.avi':
  Metadata:
    encoder         : MEncoder svn r34540 (Ubuntu), built with gcc-4.6
    Stream #0.0: Video: mpeg4, yuv420p, 640x360 [PAR 1:1 DAR 16:9], q=2-31, pass 1, 200 kb/s, 90k tbn, 23.98 tbc
    Stream #0.1: Audio: ac3, 44100 Hz, stereo, flt, 200 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 -> mpeg4)
  Stream #0:1 -> #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 have tried a number of things, but either they end up with a similar error message, or the quality is extremely poor; not so much due to low resolution, but full of compression artifacts.

Now, what I would like to achieve is the same resolution / encoding as the following avi file, which plays fine on my kids video device:

Stream #0.0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 624x352 [PAR 1:1 DAR 39:22], 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 128 kb/s
share|improve this question
1  
I'm not sure it is the root cause of the problem, but you really should specify bitrate - 200 kb/s for audio is quite a lot (especially when the input has lower bitrate) whereas for video it's way too little. You can also copy the stream unchanged (-acodec copy iirc). –  peterph Dec 1 '12 at 19:28
add comment

2 Answers

The final line in the output log is too generic — you'll have to look up further. The error is this:

[ac3 @ 0x9fdc740] invalid bit rate

The problem is that for some reason avconv wants to encode your MP3 audio to AC3. In fact, when you're only resizing video, you can leave the audio bitstream alone.


Note that resizing and re-encoding will lower your quality drastically. So, unless you really need to, don't do it. Your video will suffer from generation loss.

If you can, avoid using MPEG-4 Part 2 codecs (Xvid, or the libavcodec-native mpeg4), and use MPEG-4 Part 10 / H.264 codecs instead (e.g., x264). Since H.264 isn't properly supported in AVI containers, we'll use MP4 instead, which should be your container of choice instead of AVI most of the time.

ffmpeg -i in.avi -c:a copy -c:v libx264 -crf 23 -s:v 640x360 output.mp4

This will copy the audio stream (-c:a copy), encode the video to x264 (-c:v libx264) with a constant quality of 23 (-crf). Use a lower value here for better quality (with sane values from 18–28). The size will be changed with -s:v.

I'm using FFmpeg synonymously with Libav here, since the syntax should be the same. I would however recommend you to ditch the default Libav version that ships with Ubuntu and compile FFmpeg from source or use a recent Linux static build.

share|improve this answer
    
... in particular, the AC-3 encode fails because 200 kbit is not a valid bit rate listed in the AC-3 spec, Annex A, Table 4. The closest are 192 and 224. –  derobert Jun 10 '13 at 17:38
add comment

the video bitrate specified is very low 200kpbs. try this command

ffmpeg -i input_video -b 800 -s 640x360 -vcodec xvid -acodec copy output_video

As suggested in comments if the device supports h.264 it would be a better choice.

share|improve this answer
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.