« Multimedia/MencoderAudioOnly » : différence entre les versions

De TartareFR
Aller à la navigation Aller à la recherche
(Page créée avec « Category:Linux Whatever you can play with mplayer, whether it be an avi, mkv, mp4, ogm, etc it can be made into an MP3 or whatever other format is necessary easily. =... »)
 
Ligne 31 : Ligne 31 :
ffmpeg -i audio.ac3 -ab 128 audio.mp3
ffmpeg -i audio.ac3 -ab 128 audio.mp3
</pre>
</pre>
= Method 3: Using mplayer's PCM wav output then converting to MP3 =
= Méthode 3: Utiliser mplayer pour extraire la piste audio en PCM WAV et la convertir en MP3 =
This usually works with all files, including the silly matroska (MKV) or OGM files the never dump properly.


First we need to create a WAV with mplayer.
Cela fonctionne avec quasiment tous les types de videos, y compris avec les formats matroska (MKV) et OGG-VORBIS (OGM)
<pre>
mplayer -vc dummy -vo null -ao pcm:file=output.wav video.mkv
</pre>
If you find that mplayer is taking its sweet time in outputting the WAV you may have to append the ''fast'' option like so:
<pre>
mplayer -vc dummy -vo null -ao pcm:file=output.wav,fast video.mkv
</pre>


Then we create an MP3 from the WAV.
* Extraction de la piste audio en PCM WAV<pre>mplayer -vc dummy -vo null -ao pcm:file=output.wav,fast -af format=s16le video.mkv</pre>
<pre>
* Encodage du fichier WAV
lame -h -b128 output.wav output.mp3
** En MP3<pre>lame -h -b128 output.wav output.mp3</pre>
</pre>
** En flac<pre>flac --best metallica.wav</pre>
Again I like to make 128kbps for my bitrate.
* Suppression du fichier wav<pre>rm output.wav</pre>
 
Finally remove the temporary WAV.
<pre>
rm output.wav
</pre>
 
Or you can make a script out of the whole thing.  What I did was make a script that extracts the audio out of all video files in the current working directory:
<pre>
#!/bin/bash
 
extra_opt="-aid 0"
filetype=mkv
 
for file in *$filetype ; do
basename=`basename "$file" ".$filetype"`
        mplayer $extra_opt -vc dummy -vo null -ao pcm:file="$basename.wav",fast "$file"
        lame -h -b128 "$basename.wav" "$basename.mp3"
        rm -v "$basename.wav"
done
</pre>
The ''extra_opt'' I use to set the audio track when a file has multiple audio streams.  It helps when picking a language.

Version du 13 août 2013 à 07:15


Whatever you can play with mplayer, whether it be an avi, mkv, mp4, ogm, etc it can be made into an MP3 or whatever other format is necessary easily.

Method 1: Dumping the audio

Sometimes you get lucky and your encoded file has the audio encoded by MP3. Then you can just have mplayer dump the audio.

You can check and see if the video's audio encoding using file.

# file Ranma\ One-Half/Season\ 01/01.\ Here\'s\ Ranma.avi 
Ranma One-Half/Season 01/01. Here's Ranma.avi: RIFF (little-endian) data, AVI, 640 x 464, 29.97 fps,
video: DivX 3 Low-Motion, audio: MPEG-1 Layer 3 (stereo, 32000 Hz)

You can see in my example above the audio: MPEG-1 Layer 3 (stereo, 32000 Hz) portion. This means the movie's audio was encoded with MP3.

Now you can simply use

# mplayer -dumpaudio -dumpfile mp3name.mp3 moviefile.avi

To get your MP3 file.

Method 2: Dumping to ac3 then converting to mp3

Usually when trying to extract the audio off of DVDs you end up with an ac3 file. This is fine, but you'll have to convert it to an MP3 from here. This is where ffmpeg comes in handy.

First we need to dump the audio:

mplayer -dumpaudio -dumpfile audio.ac3 dvd://1

For more information on playing DVDs or to change chapters see the mplayer manual.

Note: This may take a while. It takes a least 5 minutes for me.

Now convert your ac3 file into an MP3.

ffmpeg -i audio.ac3 -ab 128 audio.mp3

Méthode 3: Utiliser mplayer pour extraire la piste audio en PCM WAV et la convertir en MP3

Cela fonctionne avec quasiment tous les types de videos, y compris avec les formats matroska (MKV) et OGG-VORBIS (OGM)

  • Extraction de la piste audio en PCM WAV
    mplayer -vc dummy -vo null -ao pcm:file=output.wav,fast -af format=s16le video.mkv
  • Encodage du fichier WAV
    • En MP3
      lame -h -b128 output.wav output.mp3
    • En flac
      flac --best metallica.wav
  • Suppression du fichier wav
    rm output.wav