[SOLVED] ffmpeg 0.11.1: how do I set the audio to English?
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi: 'mplayer -alang eng The_Fountainhead.mkv' plays the movie with the English audio. I did 'ffmpeg -i The_Fountainhead.mkv -target ntsc-dvd ffmpeg/1.mpg' and then 'mplayer -alang eng 1.mpg' no longer played it in English but in Spanish. From the ffmpeg man page:
Code:
-metadata[:metadata_specifier] key=value (output,per-metadata)
Set a metadata key/value pair.
An optional metadata_specifier may be given to set metadata on
streams or chapters. See "-map_metadata" documentation for details.
This option overrides metadata set with "-map_metadata". It is also
possible to delete metadata by using an empty value.
For example, for setting the title in the output file:
ffmpeg -i in.avi -metadata title="my title" out.flv
To set the language of the first audio stream:
ffmpeg -i INPUT -metadata:s:a:1 language=eng OUTPUT
But I'm not sure about this. Can I tell ffmpeg to choose the English language for audio? Or even better, to preserve both languages so I can choose among them in the output file?
If there is more than one audio track, ffmpeg usually uses the first one it finds by default. If you just input, say
Code:
ffmpeg -i MyVideo.flv
then it should list all the tracks available. One of them should be identified as English. You need to make sure that this is the one mapped to your output file.
I've had this problem in the past with "off-air" recordings, where a narrative track (for the visually impaired) is often track 1, whilst the "proper" track may be 15 or similar! Ffmpeg by default only transfers the narrative track, and I have to use the "map" function to get the right audio.
I've always used the numeric form of map - never tried the metadata way of doing it - but you need to identify which track contains which language to do it this way. It does mean that you can preserve both language tracks though, once you've identified which is which.
For example, if track 15 contains the English track, and track 8 is Spanish (and assuming track 0 is the video), you should be able to do something like
Code:
-map 0:0 -map 0:15 -map 0:8
This should put the English track on track 1 of the output video and Spanish on track 2. Note that you have to specify the video track, even if to humans that is obvious!
To determine what tracks are available in the container, you don't need to specify an output file - simply
Code:
ffmpeg -i MyFile.flv
should do the trick. It will produce an error "no output specified", but that doesn't matter. This just saves time coding the file to find out what's in it!
It should give you a list of tracks, with some indication of what each one is. This is missing in your case, because you've told it to produce an output file, so its told you how its mapping them instead!
If a simple "ffmpeg -i MyFile.flv" doesn't help, then you have to be a bit more devious. You have two files with ac3 soundtracks. I would guess one is Spanish, the other English. From what happened when you tried it the first time, I would guess that 0:1 is Spanish and 0:2 is English, but to confirm this, just do a test:
and quit via the "q" key once it has converted enough for you to tell. Play back the "test.mpg" file and see which you have. Then you can map accordingly.
Yes, you can map subtitle tracks, but this is a bit more complex, as different containers use different subtitle formats. Ffmpeg can do the translations from one format to another, but you need to know which format your destination container supports. I have done this, but it was a while back, and I usually just omit the subtitles when I do this anyway. Maybe someone else can give you some more detailed help here, but the documentation does cover this, although you have to wade through quite a bit to find it!
However, it looks as if your English subtitles are on track 5 (according to the listing you've got), so assuming track 2 is English and track one Spanish, then:
should give you a NTSC mpeg file with English on track1, Spanish on track2 and English subtitles on track3.
Don't be surprised if this throws up an error about incompatible formats, though since it worked after a fashion on your original attempt, you might be lucky!
discarding all other streams (I don't remember now if I put -map 0:5, the English subtitles, too; I'll see when it finishes transcoding). I guess ffmpeg guesses the output format from the extension, .mpg, and so it formats an MPEG-1 file. What I finally want to do is to get a DVD-Video compliant file, and so I was told to use the output from ffmpeg as input to dvdauthor. But can't ffmpeg produce DVD-Video directly? Reading the ffmpeg man page it says nothing about it.
-target ntsc-dvd tells it to make a dvd compliant mpeg file. But that does not "author" it onto a dvd. You could just burn the file onto a dvd, and most modern dvd players - and certainly blu-ray players - should play it. However, if you want to make a "proper" dvd, you will need to use dvdauthor to create it. Dvdauthor is a command-line program, and something of a pain to use at anything more than a very simple level. However, that may suffice for your needs. There are a couple of graphical front ends that help. Qdvdauthor is the most comprehensive, but not the simplest to use. For most stuff, I find devede a simpler option.
You will still need dvdauthor, mplayer, mencoder, ffmpeg and their dependencies, but devede will take a lot of the pain of actually authoring a dvd away!
P.S. You can stop ffmpeg at any time with the "q" key (quit) and it will stop and leave you with a playable file. Handy for doing short test runs to see if you have the syntax right!
Thanks. I already have the output from the cli line in post #5, but I am missing the division into chapters the original .mkv had. Is there a way that ffmpeg preserves the chapters? I have just submited this same question in the ffmpeg.gusari.org forum.
'Fraid I don't know the answer to that one! I'm not a ffmpeg guru, I just know the commands I use on a semi-regular basis. For in-depth ffmpeg help, you really need to talk to the ffmpeg forum guys.
The original .mkv file had 28 chapters. Now, neither MPEG-1 nor MPEG-2 supports chapters. So I forced chapters at 15m intervals in the XML file for dvdauthor. I guess the original marks were cleverly chosen (i.e., making them mark transitions from one scene to the following one, but it doesn't matter. I now have the DVD-Video DVD and am happy with it. I used ffmpeg, dvdauthor, mkisofs and growisofs. Thanks for your help, pchristy.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.