[Libav-user] How to encode several audio tracks into one file ?

pehache pehache.7 at gmail.com
Sun Apr 22 14:16:45 CEST 2012


Le 22/04/12 13:00, pehache a écrit :
> Hi,
>
> I'm trying to convert a .mp4 file which contains 2 audio tracks to a
> .mkv file, keeping the 2 tracks. I thought that using -map would be
> enough, but clearly it isn't :
>
> =================================================================
> *****$ ffmpeg -i Good_Bye_Lenin.DVDRIP.HQ.deFR.mp4 -vcodec copy -acodec
> copy -map 0.0 -map 0.1 -map 0.2 toto.mkv
> ffmpeg version 0.7.11, Copyright (c) 2000-2011 the FFmpeg developers
> built on Mar 17 2012 12:11:52 with gcc 4.2.1 (Apple Inc. build 5666)
> (dot 3)
> configuration: --prefix=/opt/local --enable-gpl --enable-postproc
> --enable-swscale --enable-avfilter --enable-libmp3lame
> --enable-libvorbis --enable-libtheora --enable-libdirac
> --enable-libschroedinger --enable-libopenjpeg --enable-libxvid
> --enable-libx264 --enable-libvpx --enable-libspeex
> --mandir=/opt/local/share/man --enable-shared --enable-pthreads
> --cc=/usr/bin/gcc-4.2 --arch=x86_64 --enable-yasm
> libavutil 50. 43. 0 / 50. 43. 0
> libavcodec 52.123. 0 / 52.123. 0
> libavformat 52.111. 0 / 52.111. 0
> libavdevice 52. 5. 0 / 52. 5. 0
> libavfilter 1. 80. 0 / 1. 80. 0
> libswscale 0. 14. 1 / 0. 14. 1
> libpostproc 51. 2. 0 / 51. 2. 0
> [mov,mp4,m4a,3gp,3g2,mj2 @ 0x102052000] max_analyze_duration 5000000
> reached at 5013333
>
> Seems stream 0 codec frame rate differs from container frame rate:
> 180000.00 (180000/1) -> 25.00 (25/1)
> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from
> 'Good_Bye_Lenin.DVDRIP.HQ.deFR.mp4':
> Metadata:
> major_brand : mp42
> minor_version : 0
> compatible_brands: mp42isomavc1
> creation_time : 2012-04-07 09:59:01
> encoder : HandBrake 0.9.6 2012022800
> Duration: 01:52:41.32, start: 0.000000, bitrate: 1274 kb/s
> ...
> Stream #0.0(und): Video: h264 (High), yuv420p, 704x384, 999 kb/s, 25
> fps, 25 tbr, 90k tbn, 180k tbc
> Metadata:
> creation_time : 2012-04-07 09:59:01
> Stream #0.1(fra): Audio: aac, 48000 Hz, stereo, s16, 131 kb/s
> Metadata:
> creation_time : 2012-04-07 09:59:01
> Stream #0.2(deu): Audio: aac, 48000 Hz, stereo, s16, 131 kb/s
> Metadata:
> creation_time : 2012-04-07 09:59:01
> Stream #0.3(fra): Subtitle: dvdsub, 4 kb/s
> Metadata:
> creation_time : 2012-04-07 09:59:01
> Stream #0.4(und): Subtitle: text / 0x74786574
> Metadata:
> creation_time : 2012-04-07 09:59:01
> File 'toto.mkv' already exists. Overwrite ? [y/N] y
> Output #0, matroska, to 'toto.mkv':
> Stream #0.0: Video: [0][0][0][0] / 0x0000, q=2-31, 64 kb/s, 90k tbn
> Stream #0.1: Audio: [0][0][0][0] / 0x0000, 0 channels, 64 kb/s
> Stream #0.2: Subtitle: [0][0][0][0] / 0x0000, 64 kb/s
> Codec type mismatch for mapping #0.2 -> #0.2
> =================================================================
>
> It seems it expects a subtitle track for the #0.2 output stream. I
> didn't see how to change that. I tried to use the "-newaudio" parameter
> but without any success.
>
> My problem is also that my version of ffmpeg seems a bit outdated
> compared to the online doc.
>
> Thanks for any help.

Oops, I got it...

I had to disable the subtitle track with -sn , else ffmpeg expects a 
subtitle track for the #0.2 output stream, regardless what the -map says

I had also to put -newaudio at the end the command line (why ?). Hence 
the right command is :
*****$ ffmpeg -i Good_Bye_Lenin.DVDRIP.HQ.deFR.mp4 -vcodec copy -acodec
 > copy -sn -map 0.0 -map 0.1 -map 0.2 toto.mkv -newaudio




More information about the Libav-user mailing list