Scripts to extract audio from video clips or convert other audio formats to mp3

This is a great thing because I can put all these MP3 clips onto my phone and play this music wherever I go.
https://bytefreaks.net/gnulinux/bash/ffmpeg-extract-audio-from-mkv-to-mp3
find . -type f -name "*.mkv" -exec bash -c 'FILE="$1"; ffmpeg -i "${FILE}" -vn -c:a libmp3lame -y "${FILE%.mkv}.mp3";' _ '{}' ;
The script goes through the current folder and all subfolders to find mkv files and extract the audio from them and save it into a mp3 file.
You can change the extensions in two places to find other types of video to extract from (it works with mp4 as well).

I set the MP3 tags with Puddletag but I found my Windows phone will not recognise m4a and wma files so the next step needed is to batch these files out to mp3 using ffmpeg.

Here is a script I tried to convert the wma files:

find . -iname "*.wma" -execdir bash -c 'NAME="{}" && ffmpeg -y -i "$NAME" -ab 192k "${NAME/.wma/.mp3}" ' ;
This does the trick with the wma files, producing mp3 files in the same directory as the original. The wma files were then backed up to another computer so that the media computer only has the mp3 files. 

Apart from whichever format the phone can read, Groove music player appears to suffer from the same technical limitation as Windows Media Player, in that the ID3 tags have to be just so right in order for it to properly classify music by albums and artists. Apparently if your tags do not set a genre it will just ignore the rest of the tags and classify the track as “Unknown Album” and “Unknown Artist” even though these tags are set to specific album and artist. So I have spent quite a bit of time playing with the tags to try to get Groove to recognise them and have managed to get it to finally start recognising all the albums I am trying to load onto it, which is a lot.

Posted

in

by

Tags: