Quelle1)
hi, ich hab hier eine mpeg2 Datei mit drei Tonspuren (spanisch, englisch und deutsch)! Nun möchte ich die deutsche Tonspur mittels ffmpeg von ac3 in mp2 umkonvertieren! sowohl
ffmpeg -i my_movie/mov -vn -ab 224 -ac 1 -y audio.mp2 ffmpeg -i my_movie/mov -vn -ab 224 -ac 2 -y audio.mp2
und
ffmpeg -i my_movie/mov -vn -ab 224 -ac 3 -y audio.mp2
bringen mir jedoch immer nur die englische Tonspur! Was mache ich falsch??
Lösung:
Hallo,
das kannst Du mit dem -map Switch festlegen, welche Tonspur kodiert werden soll. Laut Man-Page:
-map file:stream
Beispiel mit Deinen Angaben:
ffmpeg -i my_movie/mov -vn -ab 224 -map 0:1 -y audio.mp2
Der erste Audiostream wird nach MP2 umgewandelt. Wenn der benötigte Stream der zweite Audiostream ist, statt 1 nur 2 eingeben, usw.
Bei Deinen Beispielen wurde mit -ac die Anzahl der Audio-Kanäle festgelegt.
Hoff es hilft Dir weiter.
Um z.B. den 2. (deutschen) Audiostream aus einem mpeg2 zu nehmen (0. Stream ist der Videostream) und ein mp4 draus zu machen:
ffmpeg -i Fellinis\ Casanova\[remux\].m2p -vcodec mpeg4 -b 1400kb -acodec mp3 -ab 112kb -ar 44100 -map 0:0 -map 0:2 Fellinis\ Casanova2.mp4
Quelle2)
Coming back to the .vob file ripped from a DVD with tccat, it's commonplace for such multimedia files to have multiple audio streams embedded in them. Indeed, the DVD standard provides for up to 8 audio streams. Unless instructed otherwise, ffmpeg will operate on the first available sound track.
It so happens that I have such a .vob file on-disk, so let's see what ffmpeg thinks of it:
$ ffmpeg -i mr.vob FFmpeg version SVN-r9607, Copyright (c) 2000-2007 Fabrice Bellard, et al. {snipped} Seems that stream 0 comes from film source: 25.00 (25025/1001) -> 25.00 (25/1) Input #0, mpeg, from 'mr.vob': Duration: 00:03:16.2, start: 620.890956, bitrate: 7704 kb/s Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x576, 6799 kb/s, 25.00 fps(r) Stream #0.1[0x89]: Audio: dts, 48000 Hz, stereo, 768 kb/s Stream #0.2[0x80]: Audio: ac3, 48000 Hz, 5:1, 384 kb/s Stream #0.3[0x83]: Audio: ac3, 48000 Hz, stereo, 96 kb/s Stream #0.4[0x82]: Audio: ac3, 48000 Hz, stereo, 96 kb/s Stream #0.5[0x84]: Audio: ac3, 48000 Hz, stereo, 192 kb/s Stream #0.6[0x2d]: Subtitle: dvdsub Stream #0.7[0x2c]: Subtitle: dvdsub Stream #0.8[0x2b]: Subtitle: dvdsub Stream #0.9[0x2a]: Subtitle: dvdsub Stream #0.10[0x29]: Subtitle: dvdsub Stream #0.11[0x28]: Subtitle: dvdsub Stream #0.12[0x27]: Subtitle: dvdsub Stream #0.13[0x26]: Subtitle: dvdsub Stream #0.14[0x25]: Subtitle: dvdsub Stream #0.15[0x24]: Subtitle: dvdsub Stream #0.16[0x23]: Subtitle: dvdsub Stream #0.17[0x22]: Subtitle: dvdsub Stream #0.18[0x21]: Subtitle: dvdsub Stream #0.19[0x20]: Subtitle: dvdsub
The first stream, #0.0, is the video stream. Stream #0.1 is the DTS-encoded sound track and #0.2 is its AC3-encoded Dolby 5:1 equivalent. Stereo audio streams #0.3 through #0.5 are soundtracks with commentaries. Say I want to create a mono MP3 from this with the commentary from the third audio stream, #0.3. If I don't tell ffmpeg which one to use, it'll go ahead and transcode the first one it finds, the DTS stream in this case. I don't want that. This is where the „-map“ option comes in handy:
$ ffmpeg -i mr.vob -map 0:3 -vn -acodec mp3 -ar 22050 -ab 96k -ac 1 mr.mp3
„-map input:stream“ tells ffmpeg to process the given stream. As we'll see later on, ffmpeg can process input from several files. „input“ is the zero-based index of the input file we want to use − 0 for the first, 1 for the second etc. „stream“ is the number of the stream within this file that we want to use, also zero-based. „-map 0:3“ therefore means that we want to use the fourth stream in the first (and only, in this case) input file.
„-map“ can also be used to create a new movie from this .vob file using, for example stream #0.0 for the video and #0.5 for the audio. If any streams in a video file are mapped with „-map“ then they must all be specified explicitly. In this case the first „-map“ option specifies the stream to use for the video and the second one specifies which stream to use for the audio:
$ ffmpeg -i mr.vob -map 0:0 -map 0:5 -vcodec mpeg4 -b 1000k \ -s 640x360 -acodec mp3 -ar 22050 -ab 64k -ac 1 -f avi mr.avi
One of the pieces of equipment adorning my video rig here at home is a DVD recorder. Almost invariably, I record direct onto a DVD+RW so that I can take the program I'm recording apart, rework the audio track (boost the volume level among other things), put it back together again, archive the modified program onto a DVD±R and put the DVD+RW back into circulation for the next recording.
Once the audio track has been extracted and reworked, I can reassemble the movie in either of two manners:
Also extract the mpeg2video data from the .vob file and then multiplex it and the reworked audio (duly converted to MP2 or AC3) with mplex, or Ask ffmpeg to pull the video in from the original .vob file and the audio from the reworked .wav audio file and transcode it on-the-fly. Solution 1 is already the object of another howto page (which needs finishing now that I think of it). This is how we use solution 2:
$ ffmpeg -i oldmovie.vob -i altered_audio.wav -map 0:0 -map 1:0 -target ntsc-dvd \
-b required_video_bit_rate -aspect 16:9 newmovie.mpg
Or, if you'd rather use MP2 audio and a lower audio bit rate:
$ ffmpeg -i oldmovie.vob -i altered_audio.wav -map 0:0 -map 1:0 -target ntsc-dvd \ -b required_video_bit_rate -acodec mp2 -ab audio_bit_rate -aspect 16:9 newmovie.mpg
Obviously replace „16:9“ with „4:3“ if you're reworking a 4:3 aspect ratio movie. Also, this assumes that the first stream in the .vob file is the video stream, so you'll need to adjust the „-map 0:0“ accordingly if, for example the video stream is the second stream as is the case with my DVD recorder, in which case you'll need „-map 0:1“ instead. Either way round, this is the stream that'll be used for the video in the output file. The audio stream is mapped to „-map 1:0“. The „1“ means „second file“ (remember, the list is zero-based) and the „:0“ means „first stream“.