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
Best Answer
libvo_aacenc
probably can not encode 5.1 channels and is a poor encoder in general. You can useaac
(with-strict experimental
),libfaac
, orlibfdk_aac
(if your ffmpeg were configured to support it) to preserve your channels. If you must uselibvo_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
forlibfaac
or-vbr 5
forlibfdk_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 input0
(the first input). See stream selection in the ffmpeg documentation for more info and an explanation of "best".Also see: