I'm writing a bash script to automatically extract audio track from a video file using avconv
. This script should handle any video format and only extract the audio track without keeping the original codec conversion. For example:
extract_audio name.flv
where the audio track of the flv file is an mp3 should produce a file named name.mp3
, but if it contains and aac track it should produce aumatically name.aac
For now my script looks like this:
#!/bin/bash
dryname=${1%.*} #get remove video extention
avconv -i "$1" -vn -acodec copy "${dryname}.${audio_extension}"
The only part that I miss is how to get the codec used in the audio track of the video file. I'm sure it's possible to do it with an avconv
command but I can't figure it out from the help page.