Tuesday, October 18, 2011

extracting audio content from video files with open source tools

These days, I have downloaded many music videos and I have enjoyed them but I don't only want to watch them but also listen them. I looked in Internet and found this interesting link which give many tips about how to transform and extract information from multimedia files using ffmpeg.

Then, I created this bash script which extracts audio content from music videos.

#!/bin/bash
OUTPUT=""
if [ $# = 1 ] ; then
    OUTPUT=${1%.*}.mp3
elif [ $# = 2 ] ; then
    OUTPUT=${2}
else
    echo "Usage:"
    echo "     ${0} video_filename output.mp3"
    exit
fi
/usr/bin/ffmpeg -i "${1}" -vn -ar 44100 -ac 2 -ab 192 -f mp3 "${OUTPUT}"

Cut and paste it into your preferred editor (VI). This link explains how to retrieve just the file name without its extension.


No comments: