Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command find and convert using ffmpeg

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
like image 245
molwiko Avatar asked Sep 05 '26 01:09

molwiko


1 Answers

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.

like image 148
chaos Avatar answered Sep 07 '26 20:09

chaos