LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Feed multiple files into ffmpeg? (https://www.linuxquestions.org/questions/linux-software-2/feed-multiple-files-into-ffmpeg-665064/)

Anithen 08-24-2008 02:03 PM

Feed multiple files into ffmpeg?
 
I've always done things, like

for i in *.mp3; do mpg321 -w `basename $i .mp3`.wav $i; done

but for ffmpeg how can I encode many videos at once?

for i in *.3gp; do ffmpeg $i -f avi -vcodec libxvid -acodec libmp3lame `date +%H%M%S%N`.avi; done

Does not work, because ffmpeg uses the 2nd match as the output file, and asks me if I want to write over it.

From within a directory full of 3gp files, I ran

find . -iname "*.3gp" -print -exec ~/nastiness/3gp2avi.sh {} \;

, and 3gp2avi.sh contains

#!/bin/bash ffmpeg $1 -f avi -vcodec libxvid -acodec libmp3lame `date +%H%M%S%N`cv.avi

This attempt also does not work. Strangely, even using 3gp2avi.sh by itself on 1 file ffmpeg tries using the filename as the output file filename. If I type the whole ffmpeg command one by one for each 3gp file it works, though.

If anyone can help me do something like "for i in *3gp; do..." with ffmpeg I'd greatly appreciate it. Thanks.

David the H. 08-24-2008 11:40 PM

The command should be 'ffmpeg -i "$i" etc..'. I'd also put the variable in quotes, especially if the filenames contain spaces or other illegal characters. Same goes for the output file string.

Anithen 08-25-2008 01:13 AM

Thanks, David the H. I can't believe I missed the -i. It's in my bash history. I must've weeded it out accidentally during testing. One thing I wouldn't have tried is using "$i" vs $i, so thank you for your help.

My final command is

for i in *.3gp; do ffmpeg -i "$i" -f avi -vcodec libxvid -acodec libfaac -ar 22050 `basename $i .3gp`-`date +%H%M%S%N`.avi; done


All times are GMT -5. The time now is 10:49 AM.