[SOLVED] Why is ffmpeg stopping after the first encode when using my bash script?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Why is ffmpeg stopping after the first encode when using my bash script?
I'm trying to create a script that will trawl through a directory structure looking for VOB files, convert them to AVI and place them in a ./converted/ sub-directory of the the original source folder. I've knocked up the script below which appears to work fine when I place an "echo" in front of the actual ffmpeg encode line, I get the output on the screen with ffmpeg finding all the VOB files in the directories and looking to convert them to the correct sub-directory. Yet, when I remove the echo and run the script for real, ffmpeg converts the first file and then stops. No errors. Is this something to do with ffmpeg or a problem with my script below?
Code:
#!/bin/bash
#
# Define the starting search point:
#
start="/mnt/disk1/toconvert"
#
# Loop over directories looking for VOB files
#
while read file
do
DIR=$(dirname "$file")
if [ ! -d "$DIR/converted" ]
then
mkdir "$DIR/converted"
fi
ORIGINAL=`basename "$file" .VOB`
NEWNAME=${ORIGINAL}.avi
ffmpeg -i "$file" -f avi -vcodec mpeg4 -b 5000k -g 300 -bf 2 -ab 192k "$DIR/converted/$NEWNAME"
done < <(find $start \( -iname \*.VOB \))
I hit this problem yesterday. ffmpeg reads from stdin and therefore reads what the loop is supposed to get, so the loop gets nothing more. There's a site that explains it all, but I can't post it because it's my first post. I'll try with a followup.
---------- Post added 07-06-11 at 09:28 AM ----------
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.