Difference between revisions of "Linux: "video to mp3""
Lukas Dzunko (talk | contribs) |
Lukas Dzunko (talk | contribs) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Problem: I have video file with concert or music show and I would like to play it in car or on phone. | Problem: I have video file with concert or music show and I would like to play it in car or on phone. | ||
− | + | In 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 <code>ffmpeg</code> but I prefer <code>lame</code> mp3 creator. Depending on source I normalize tracks before converting to mp3. This is also recommend only on lossless file formats. | Here are steps how to get sound track from video and store it as mp3. It is possible to do it directly via <code>ffmpeg</code> but I prefer <code>lame</code> 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 === | === Step 1 - extract audio from video file === | ||
− | <code>ffmpeg</code> is powerful video converter. With correct option it can "dump" audio or directly | + | <code>ffmpeg</code> is powerful video converter. With correct option it can "dump" audio track or directly encode it to mp3. I am using following way to extract audio: |
==== video with stereo audio track ==== | ==== video with stereo audio track ==== | ||
<pre> | <pre> | ||
Line 12: | Line 12: | ||
</pre> | </pre> | ||
'' -i == input file, -vn == no video processing '' | '' -i == input file, -vn == no video processing '' | ||
− | ==== video with DTS audio track (5.1 or all other X.Y combinations) | + | ==== video with DTS audio track (5.1 or all other X.Y combinations) ==== |
<pre> | <pre> | ||
ffmpeg -i input.mkv -vn -ac 2 output.wav | ffmpeg -i input.mkv -vn -ac 2 output.wav | ||
</pre> | </pre> | ||
'' -ac == number of output channels '' | '' -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 <code>-map</code> (for example: <code>-map 0:a:0</code>) or [http://trac.ffmpeg.org/wiki/AudioChannelManipulation AudioChannelManipulation]. If you are unsure what is content of file then simply run: | ||
+ | <pre> | ||
+ | ffmpeg -i input.mkv | ||
+ | </pre> | ||
+ | It will show technical details and ten quit due to missing output file. | ||
+ | |||
+ | === Step 2 - normalize tracks === | ||
+ | I am using <code>normalize</code> tool to correct volume levels. Reason is simple. Different produces use different volume configuration or it was simple precaution for clipping in club recording. | ||
+ | ==== unrelated files ==== | ||
+ | For longer recordings it is better to normalize files separately. I am using this approach for >30 minutes recordings. | ||
+ | <pre> | ||
+ | for a in *.wav | ||
+ | do | ||
+ | normalize "${a}" | ||
+ | done | ||
+ | </pre> | ||
+ | Another approach is "mix mode". This is suitable for shorter files but they should be similar (e.g. same genre) | ||
+ | <pre> | ||
+ | normalize -m *.wav | ||
+ | </pre> | ||
+ | |||
+ | ==== related files ==== | ||
+ | Related files are for example songs from one album. This mode retain relative volumes between songs and normalize all songs to maximum. | ||
+ | <pre> | ||
+ | normalize -b *.wav | ||
+ | </pre> | ||
+ | |||
+ | === Step 3 - create mp3 file === | ||
+ | Once all *.wav files are prepared it is time to compress them to mp3. I prefer <code>lame</code> mp3 creator. Build in <code>---preset</code>s are allready well configured to fulfill almost all needs. There are 4 possible options: | ||
+ | * medium - there is no much space saved compared to standard but quality is reduced | ||
+ | * '''standard''' - well balanced option. There is lot of noise in car anyway so this level should be good for listening in car. | ||
+ | * extreme - use this if you have really good equipment at home | ||
+ | * insane - best quality regardless of size | ||
+ | ''For more details check man page of lame(1)'' | ||
+ | |||
+ | Once I have all files prepared in directory I run: | ||
+ | <pre> | ||
+ | for a in * | ||
+ | do | ||
+ | lame --preset standard "${a}" | ||
+ | done | ||
+ | </pre> | ||
+ | |||
+ | === Step 4 - burn CD === | ||
+ | Can your car radio read memory card ? Then your are lucky. Just copy files to card and you are done. All others should use favorite burning program and burn CD-R(W). | ||
+ | |||
+ | Usually I am preparing all files on my media-pc via ssh. Final CD can be burn easily via [http://bashburn.dose.se/ bashburn] from command line. |
Latest revision as of 19:47, 13 February 2016
Problem: I have video file with concert or music show and I would like to play it in car or on phone.
In 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.
Contents
Step 1 - extract audio from video file
ffmpeg
is powerful video converter. With correct option it can "dump" audio track or directly encode it to 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
I am using normalize
tool to correct volume levels. Reason is simple. Different produces use different volume configuration or it was simple precaution for clipping in club recording.
For longer recordings it is better to normalize files separately. I am using this approach for >30 minutes recordings.
for a in *.wav do normalize "${a}" done
Another approach is "mix mode". This is suitable for shorter files but they should be similar (e.g. same genre)
normalize -m *.wav
Related files are for example songs from one album. This mode retain relative volumes between songs and normalize all songs to maximum.
normalize -b *.wav
Step 3 - create mp3 file
Once all *.wav files are prepared it is time to compress them to mp3. I prefer lame
mp3 creator. Build in ---preset
s are allready well configured to fulfill almost all needs. There are 4 possible options:
- medium - there is no much space saved compared to standard but quality is reduced
- standard - well balanced option. There is lot of noise in car anyway so this level should be good for listening in car.
- extreme - use this if you have really good equipment at home
- insane - best quality regardless of size
For more details check man page of lame(1)
Once I have all files prepared in directory I run:
for a in * do lame --preset standard "${a}" done
Step 4 - burn CD
Can your car radio read memory card ? Then your are lucky. Just copy files to card and you are done. All others should use favorite burning program and burn CD-R(W).
Usually I am preparing all files on my media-pc via ssh. Final CD can be burn easily via bashburn from command line.