Friday, November 28, 2014

Command to extract audio from video without conversion

ffmpeg -i video.mp4 -vn -acodec copy audio.m4a
 
Even better is to replace ffmpeg with avconv and then use a line that doesn't need inserting the actual name of the files:
 
avconv -i %f -map 0:1 -c:a copy %f.m4a 

%f stays for any selected files. Multiple file can be selected and processed at the same time. 

`-map 0:1 -c:a copy` is the command to extract without processing. 
 
`.m4a` is a variable to be used if the video contains aac audio. Change accordingly. Use mediainfo to find out.

Without`-map 0:1 -c:a copy`, a simple line like
 
avconv -i %f %f.m4a  
will convert to whatever variable format. But then it is recommendable to use more complex commands.


An updated better form (input extension is removed from output name):

bash -c 'avconv -i "$0" -map 0:1 -c:a copy "${0%%.*}".m4a' %f

For mp3:

avconv -i %f -c:a libmp3lame -ac 2 -b:a 190k %f.mp3

No comments:

Post a Comment