Linux: "video to mp3"

From Luky-Wiki
Revision as of 19:26, 14 March 2014 by Lukas Dzunko (talk | contribs) (video with DTS audio track (5.1 or all other X.Y combinations))

Jump to: navigation, search

Problem: I have video file with concert or music show and I would like to play it in car or on phone.

I both cases it is enough to have audio track and it is necessary to have correct format. My car radio can play only mp3 files (and of course regular cdda).

Here are steps how to get sound track from video and store it as mp3. It is possible to do it directly via ffmpeg but I prefer lame mp3 creator. Depending on source I normalize tracks before converting to mp3. This is also recommend only on lossless file formats.

Step 1 - extract audio from video file

ffmpeg is powerful video converter. With correct option it can "dump" audio or directly create mp3. I am using following way to extract audio:

video with stereo audio track

ffmpeg -i input.mkv -vn output.wav

-i == input file, -vn == no video processing

video with DTS audio track (5.1 or all other X.Y combinations)

ffmpeg -i input.mkv -vn -ac 2 output.wav

-ac == number of output channels

video with more audio tracks

If source file contain more that one audio track (I don't mean channels). Then it is necessary to specify which one will be saved to output file. See man page and option -map (for example: -map 0:a:0) or AudioChannelManipulation. If you are unsure what is content of file then simply run:

ffmpeg -i input.mkv

It will show technical details and ten quit due to missing output file.

Step 2 - normalize tracks