linux - Creating forks of `ffmpeg` in loop inside a shell script "loses" some iterations -
i have shell script takes directory input, reads mp4 files in , convert them mp3 ffmpeg:
#!/bin/bash dir=$1 while read -rd "" file base=$(basename "$file") filename=${base%(*}".mp3" ffmpeg -i "$file" -vn -ar 44100 -ac 2 -ab 192000 -f mp3 "$filename" & done < <(find $dir -maxdepth 1 -iname "*.mp4" -print0) wait exit 0 currently these calls ffmpeg forked because when leave out & @ end first file in converted , others ignored.
but problematic because somethings fails on files error messages following:
path/to/file/file name - spaces(info)(temp_information).mp4: no such file or directory
all file names contain spaces, maybe reason why fails files.
thus, have following questions:
- when don't fork
ffmpegcalls why first file executed? expected loop waits until process finished , continues next iteration. - why script unable find files (maybe problem of
ffmpeg)? - how solve these problems , make script work?
you not acknowledging stdin
ffmpeg -i "$file" -blah -blah -nostdin "$filename" & shell script ffmpeg stops after 2 jobs
to answer comment:
you should not forking anyway, ffmpeg runs in multiple threads maximize cpu, , might suffer from thrashing forking it.
Comments
Post a Comment