windows - FFmpeg MKV to MP4 remux whilst converting all audio tracks to AAC
2013-08
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
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 -afterburner 1
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".
I'm trying to convert the file type of a movie file so I could burn it on a DVD disc.
Here's the command and output:
$ ffmpeg -i "/path/to/movie.mkv" -target dvd "movie.mkv"
FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1.2, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --extra-version=4:0.5.1-1ubuntu1.2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 1 / 52.20. 1
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libavfilter 0. 4. 0 / 0. 4. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Sep 16 2011 17:08:44, gcc: 4.4.3
Seems stream 0 codec frame rate differs from container frame rate: 47.95 (48000/1001) -> 23.98 (24000/1001)
Input #0, matroska, from '/path/to/movie.mkv':
Duration: 02:10:21.27, start: 0.000000, bitrate: N/A
Stream #0.0(eng): Video: h264, yuv420p, 1280x544, PAR 1:1 DAR 40:17, 23.98 tbr, 1k tbn, 47.95 tbc
Stream #0.1(eng): Audio: dca, 48000 Hz, 5.1, s16
Assuming NTSC for target.
Output #0, dvd, to 'movie.mkv':
Stream #0.0(eng): Video: mpeg2video, yuv420p, 720x480 [PAR 80:51 DAR 40:17], q=2-31, 6000 kb/s, 90k tbn, 29.97 tbc
Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
[dvd @ 0x193a690]buffer underflow i=1 bufi=1203 size=1792rate=5595.1kbits/s
av_interleaved_write_frame(): Error while opening file bitrate=4752.2kbits/s
$
My OS:
$ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04.3 LTS"
$ uname -a
Linux my-desktop 2.6.32-34-generic #77-Ubuntu SMP <omitted> x86_64 GNU/Linux
As can be seen from the output, ffmpeg stopped converting the file on the last error line. I've searched google for this and there's a similar problem that is a bug, but I'm not sure if this is a bug? If it's a bug - how can I perform the conversion?
Apparently the error happened due to lack of space in the HDD...