# - - # # - - # # - Convert Mp4 to Mp3 - # https://www.unixmen.com/linux-basics-convert-mp4-mp3/ https://askubuntu.com/questions/84584/converting-mp4-to-mp3 https://linuxize.com/post/bash-check-if-file-exists/ # - - # # - - # # - ffmpeg - # :A # - - # # - Install ffmpeg and libs - # sudo apt update && sudo apt install ffmpeg libavcodec-extra -y; :B # - - # # - Run ffmpeg command (working) - # :a # - - # # - One single .mp4 file - # ffmpeg -i filename.mp4 filename.mp3; ffmpeg -i 'Caballo viejo.mp4' 'Caballo viejo.mp3' -y; :b # - - # # - Bash file *.mp4 in a folder - # #!/bin/bash # - - # # - File name - # # - ConvertMp4ToMp3.sh - # # - - # # - To run script - # # - - # # - a: Open terminal - # # - b: Go to Mp4 music folder - # # - c: Run script - # # - bash ConvertMp4ToMp3.sh - # # - bash Convert_Mp4_to_Mp3/ConvertMp4ToMp3.sh - # # - - # clear for cFileName in *.mp4; do mp3FileName="${cFileName%.*}".mp3 echo $cFileName if [ -f "$mp3FileName" ]; then echo "$mp3FileName exists ..." echo '' else echo $mp3FileName echo '' ffmpeg -i "$cFileName" "$mp3FileName" -y; echo '' fi #exit done # - eof - # :C # - - # # - Run ffmpeg command (To test) - # :a # - - # # - A stream specifier can match several streams, - # # - the option is then applied to all of them. E.g. - # # - the stream specifier in “-b:a 128k” matches all audio streams - # ffmpeg -i filename.mp4 -b:a 192K -vn filename.mp3 :b # - - # # - Convert all .mp4 files in folder Music to .mp3 - # #!/bin/bash MP4FILE=$(ls ~/Music/ |grep .mp4) for filename in $MP4FILE do name=`echo "$filename" | sed -e "s/.mp4$//g"` ffmpeg -i ~/Music/$filename -b:a 192K -vn ~/Music/$name.mp3 done :c # - - # # - FFmpeg with constant bitrate encoding (CBR) - # ffmpeg -i video.mp4 -vn \ -acodec libmp3lame -ac 2 -ab 160k -ar 48000 \ audio.mp3 :d # - - # # - Use variable Bitrate Encoding (VBR) - # ffmpeg -i video.mp4 -vn \ -acodec libmp3lame -ac 2 -qscale:a 4 -ar 48000 \ audio.mp3 #for f in *.mp4 #do # avconv -i "$f" -vn -c:a copy "${f/mp4/m4a}" #done #ffmpeg -i video.mp4 -vn \ # -acodec libmp3lame -ac 2 -qscale:a 4 -ar 48000 \ # audio.mp3 #!/bin/bash #local o=$IFS #IFS=$(echo -en "\n\b") #MP4FILE=$(ls . |grep .mp4) #for filename in $MP4FILE #do # name="${filename%.*}" # ffmpeg -i ./$filename -b:a 192K -vn ./$name.mp3 #done #IFS=o #!/bin/bash #for i in *.m4a; do # avconv -i "$i" -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 "`basename "$i" .m4a`.mp3" # avconv -i "$i" -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 "`basename "$i" .m4a`.mp3" # avconv -i "Alizee - Jen Ai Marre (Tubes) Remastered.mp4" -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 "`basename "Alizee - Jen Ai Marre (Tubes) Remastered.mp4" .m4a`.mp3" #done