The following command will find all mkv files that are in the current directory and in all sub-folders and extract the audio to mp3 format.
find . -type f -name "*.mkv" -exec bash -c 'FILE="$1"; ffmpeg -i "${FILE}" -vn -c:a libmp3lame -y "${FILE%.mkv}.mp3";' _ '{}' \;
The filename of the audio file will be the same as the mkv video with the correct extension. The mkv extension will be removed and replaced by the mp3 extension e.g hi.mkv
will create a new file named hi.mp3
This post is also available in: Greek
Nice, works like a charm, thanks 😀
great!!!!!! thank you!!!!!!
Thank you
Excellent, perfect for what I needed to do!
Default options into lame gave me a 128kb mp3 which isn’t of good quality so I have to pass in the audio bitrate option after libmp3lame. -b:a 320k
Holy snacks. Yes!! This made my life so much easier.
Thank you very much.
this is amazing, thanks!
Thanks mate, copy-pasted this and it worked
Thanks mate
sooooo…there is no download!
Just copy-paste that one line to your terminal.
if you want it in a file, type your shell as follows in a text file
#! /bin/bash
Then paste the command below it.
Save the file as .sh (or similar).
You can grant it execution rights using
chmod +x yourFile.sh;
Worked out of the box, thanks for providing it!