Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I had a ffmpeg command that would successfully remux an mkv to a iTunes compatible mp4. However it only took the first audio stream regardless of language. I want to remux all audio streams, or at the very least the english stream. I also need to retain 5.1.

Here's what I have so far:

ffmpeg -i "input.mkv" -y -f mp4 -vcodec copy -acodec libvo_aacenc -ac 6 "output.mp4"

Which throws the following error:

Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height

Here's the complete output:

C:\Program Files\ffmpeg\bin>"C:\Program Files\ffmpeg\bin\ffmpeg.exe" -i "E:\movies\A film.mkv" -y -f mp4 -vcodec copy -acodec libvo_aacenc -ac 6 "E:\iTunes\Automatically Add to iTunes\A film.mp4"
ffmpeg version N-47062-g26c531c Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 25 2012 12:21:26 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runtime-cpudetect --enab
le-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libop
encore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libop
enjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheo
ra --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-lib
vpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52.  9.100 / 52.  9.100
  libavcodec     54. 77.100 / 54. 77.100
  libavformat    54. 37.100 / 54. 37.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 23.102 /  3. 23.102
  libswscale      2.  1.102 /  2.  1.102
  libswresample   0. 17.101 /  0. 17.101
  libpostproc    52.  2.100 / 52.  2.100
Input #0, matroska,webm, from 'E:\movies\Pitch Perfect.mkv':
  Duration: 01:52:07.11, start: 0.000000, bitrate: 9765 kb/s
    Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x1040, SAR 1:1 DAR 24:13, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
    Stream #0:2(eng): Subtitle: subrip
[libvo_aacenc @ 037dfb00] Unable to set encoding parameters
Output #0, mp4, to 'E:\iTunes\Automatically Add to iTunes\Pitch Perfect.mp4':
    Stream #0:0(eng): Video: h264, yuv420p, 1920x1040 [SAR 1:1 DAR 24:13], q=2-31, 23.98fps, 90k tbn, 1k tbc (default)
    Stream #0:1(eng): Audio: aac, 48000 Hz, 5.1, s16, 128 kb/s (default)
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (dca -> libvo_aacenc)
Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height
share|improve this question
Yeah, try libfaac instead of libvo_aacenc and see if that works. If not, please edit your question and add that code as well. Please include the code here on-site if possible. Don't worry if it's a little long. – slhck Jan 1 '13 at 14:27
Hi there, thanks for the tips. You can find the full uncut command here I don't actually have an example file with multiple streams, I was just hoping to get this working until I happen upon one to test with. – Simon Stevens Jan 1 '13 at 14:28
Did you try libfaac instead? As for mapping multiple streams to one output, FFmpeg should do that automatically, if not try adding -map 0 to the options. – slhck Jan 1 '13 at 19:57
up vote 4 down vote accepted

[libvo_aacenc @ 037dfb00] Unable to set encoding parameters

libvo_aacenc probably can not encode 5.1 channels and is a poor encoder in general. You can use aac (with -strict experimental), libfaac, or libfdk_aac (if your ffmpeg were configured to support it) to preserve your channels. If you must use libvo_aacenc you can add -ac 2 or use an audio filter to change the output to two channels.

Declaring a "quality" for your audio is probably easiest, such as -q:a 100 for libfaac or -vbr 5 for libfdk_aac, otherwise you can choose the audio bitrate with -b:a, but note that the bitrate will be shared among all channels so give it a higher value than you would for a stereo output. libvo_aacenc only accepts -b:a.

By default ffmpeg will choose the "best" video, audio, and subtitle stream from your input resulting in an output with potentially one video, one audio stream, and one subtitle stream. Add -map 0, as slhck mentioned, to override this default and include all streams from input 0 (the first input). See stream selection in the ffmpeg documentation for more info and an explanation of "best".

Also see:

share|improve this answer

You must log in to answer this question.

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