Command find and convert using ffmpeg

command-line, ffmpeg, macos, shell

Solution

With `find`'s `-exec` functionality:

find ./ -name '*.mp4' -exec bash -c 'ffmpeg -i $0 -vn -acodec libmp3lame -ac 2 \
-ab 160k -ar 48000 ${0/mp4/mp3}' {} \;

This should make `xyz.mp4` to `xyz.mp3`.

Problem

I would like to combine the two following commands to find mp4 files and convert them to mp3 and save them with same name. The two command line: ``` find ./ -name '*.mp4' ffmpeg -i video.mp4 -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 audio.mp3 ```

Original source