Last active
February 17, 2016 09:50
-
-
Save romanlv/2495704 to your computer and use it in GitHub Desktop.
extract audio from mp4 files and convert it to mp3 format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# extracts audio from all videos in current folder and saves in mp3 | |
# based on http://ubuntuforums.org/showthread.php?t=1411144 | |
# | |
SAVEIFS=$IFS | |
IFS=$(echo -en "\n\b") | |
for i in `find . -type f -iname "*.avi" -print`; do | |
echo $i | |
NAME=`echo $i | sed -e 's/\.\///' -e 's/\.avi//g' ` | |
echo "doing '$NAME'" | |
vout=mp3s/${NAME}.mp3 | |
if [ ! -f $vout ]; then | |
echo 'converting to mp3' | |
mencoder -of rawaudio -ovc copy -oac mp3lame -o "${vout}" "${NAME}".avi | |
fi | |
done | |
IFS=$SAVEIFS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#extracts audio from mp4 files | |
#assumes that audio is in acc (m4a) format and converts it to mp3 | |
#mp4 audio format can be checked with ffmpeg -i fss1.mp4 | |
mkdir -p mp3s | |
mkdir -p m4a | |
SAVEIFS=$IFS | |
IFS=$(echo -en "\n\b") | |
for i in `find . -type f -iname "*.mp4" -print`; do | |
echo $i | |
NAME=`echo $i | sed -e 's/\.\///' -e 's/\.mp4//g' ` | |
echo "doing '$NAME'" | |
if [ ! -f m4a/${NAME}.m4a ]; then | |
ffmpeg -i $i -vn -acodec copy m4a/${NAME}.m4a | |
fi | |
if [ ! -f mp3s/${NAME}.mp3 ]; then | |
echo 'converting to mp3' | |
faad --stdio m4a/${NAME}.m4a | lame --preset standard - "mp3s/${NAME}.mp3" | |
fi | |
done | |
IFS=$SAVEIFS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment