I have this bash script for converting .mp4 video to .mp3 audio. It runs, but does the loop only once, though there are more mp4 files in /home/myname/mp4dir. The script converts the first .mp4 file it finds to .mp3, unless there is already an .mp3 file. This should be done in a loop, but after the first call to ffmpeg the script stops. Why?
#!/bin/bash
find /home/myname/mp4dir -name "*.mp4" | while read f
do
fOut=`echo $f | sed s/mp4/mp3/`
echo "convert $f => $fOut"
if ! test -f $fOut
then
ffmpeg -i $f -vn -f mp3 $fOut
fi
done
try this in terminal
create bash nohup.sh and paste in this
in terminal type where nohup.sh is located
nohup, will execute every 60 seconds, you can grep service check like this
The answer is to add '-nostdin' to ffmpeg (wouldn't answer to an old question like this, but still tops on related Google searches).
From the comments we got that there actually are input files you are looping over (of what kind soever) and that
ffmpeg
at least starts once. Then, you are stuck.Add
to your
ffmpeg
command and monitor the fileffmpeg.outerr
while your "loop", i.e. ffmpeg, executes. It will tell you what the problem is. Either you can solve this problem yourself, or you come back to stackoverflow with this ffmpeg-specific problem using the tagffmpeg
.