MP4 To MP3 Converter FFMPEG Linux

Go down

MP4 To MP3 Converter FFMPEG Linux

Post by jamied_uk on 8th April 2018, 17:02

Vid


Code

#!/bin/bash
#needs ffmpeg installed
# sudo apt install -y ffmpeg
#
# Usage:
#
# ./mp4tomp3_all.sh test (folder for mp4 sourcefiles).
#
#
# cp -a /$1/. /$2/ #copy the whole dir from src to dest if required!
cd test
#cd $2 #change dir to dest
#cd $2
#convert *.mp4 to *.mp3
#find . -name "*.mp4" -exec bash -c 'var=${1%.mp4}; var=${var#*/};ffmpeg -i "${1#*/}" -vn -acodec libmp3lame -ac 2 -qscale:a 4 -ar 48000 "$dest/$var".mp3' - '{}' \;
#
find . -name "*.mp4" -exec bash -c 'ffmpeg -i "$1" -vn -acodec libmp3lame -ac 2 -qscale:a 4 -ar 48000 "${1%.mp4}".mp3' - '{}' \;
#
echo "Cleaning up"
#
find . -name "*.mp4" -exec bash -c 'var=${1%.mp4}; var=${var#*/}; rm "${1#*/}"' - '{}' \;
cd test
mv *.mp3 ../output
#
# mv -b *.mp3 output
echo "Checking for files in Output Files"
if [ ! "$(ls -A ../output)" ]
then
echo "Failed!!"
else
echo "Mission Complete Check Output folder!"
cd ../output
ls
fi
echo "Task Finished All MP4 Should Now Be MP3."

avatar
jamied_uk
Admin

Posts : 2439
Join date : 2010-05-09
Age : 35
Location : UK

http://address-shortner.co.uk

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum