Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to name the output file same as input file but different extension after video conversion? [duplicate]

I am using this line to batch convert mp4 files to webm files. For all mp4 files i need the output files to be of same name but .webm extension. For example if i have video1.mp4 and video2.mp4 then after conversion i need two files i.e video1.webm and video2.webm. How can i achieve this using bash script?

for f in *.mp4; do ffmpeg -i "$f" -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis "$f".webm;  done

The above code will change the output file to video1.mp4.webm. Thanks!

like image 364
kofhearts Avatar asked Mar 04 '18 04:03

kofhearts


1 Answers

Try this ...

for f in *.mp4; 
do 
    ffmpeg -i "$f" -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis "${f%.mp4}".webm;  
done
like image 86
hch Avatar answered Nov 10 '22 22:11

hch