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:

  1. when don't fork ffmpeg calls why first file executed? expected loop waits until process finished , continues next iteration.
  2. why script unable find files (maybe problem of ffmpeg)?
  3. 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

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -