Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I tired running 8 commands in parallel to fully utilize the CPU and speed up Video conversions, something like this:

ffmpeg -i input.mp4 -t 60 -f mp4 /mnt/a.mp4 > /dev/null 2>&1 &
ffmpeg -i input.mp4 -t 60 -f mp4 /mnt/b.mp4 > /dev/null 2>&1 &
ffmpeg -i input.mp4 -t 60 -f mp4 /mnt/c.mp4 > /dev/null 2>&1  &
ffmpeg -i input.mp4 -t 60 -f mp4 /mnt/d.mp4 > /dev/null 2>&1 &
ffmpeg -i input.mp4 -t 60 -f mp4 /mnt/e.mp4 > /dev/null 2>&1 &
ffmpeg -i input.mp4 -t 60 -f mp4 /mnt/f.mp4 > /dev/null 2>&1 &
ffmpeg -i input.mp4 -t 60  -f mp4 /mnt/g.mp4 > /dev/null 2>&1 &
ffmpeg -i input.mp4 -t 60 -f mp4  /mnt/h.mp4 > /dev/null 2>&1 &

2 to 3 of them get stopped. Why does this happen? Is this a FFmpeg limitation? I have tried this on 16 core and 4 core machines, EC2 c1.xlarge and cc2.8xlarge. Same behavior. I have tried complicated commands and simple ones, still same, 2 or 3 get stopped.

share|improve this question
3  
To my knowledge there shouldn't be anything in FFmpeg itself stopping you from doing so. Could be a shell issue? –  slhck Jan 18 '13 at 11:28
    
What if I have different inputs for each command? How can I make them independent, because if one stops they all stop. –  Samson Aug 9 '13 at 9:39
add comment

2 Answers

In answering the original question, as to why some of the jobs stop, ffmpeg on the command line is interactive. It's constantly reading input on the command line. In order for you to run all of them in the background you should change this:

ffmpeg -i input.mp4 -t 60 -f mp4 /mnt/a.mp4 > /dev/null 2>&1 &

to this:

ffmpeg -i input.mp4 -t 60 -f mp4 /mnt/a.mp4 </dev/null > /dev/null 2>&1 &

the addition of </dev/null tells ffmpeg to not look for input, and all of your jobs should run in the background.

share|improve this answer
add comment

Just a thought on your command: a much easier way of hammering the machine with a single command is concatenating everything into a single line:

ffmpeg -i input.mp4 -t 60 -f mp4 /mnt/a.mp4 \
 -f mp4 /mnt/b.mp4 \
 -f mp4 /mnt/c.mp4 \
 -f mp4 /mnt/d.mp4 \
 -f mp4 /mnt/e.mp4 \
 -f mp4 /mnt/f.mp4 \
 -f mp4 /mnt/g.mp4 \
 -f mp4  /mnt/h.mp4 > /dev/null 2>&1

You might want to add (depending on your ffmpeg version) a flag to tell the server to use all available processors

-threads 0

For reference: http://ffmpeg.org/trac/ffmpeg/wiki/Creating%20multiple%20outputs

share|improve this answer
    
I have tried this, it does not use all the processors efficiently. The load remains at 20-30%, the hyper threads don't get used at all. –  d33pika Feb 7 '13 at 1:25
1  
Maybe it has something to do with EC2 machines? I just run the above command on a 16 xeon core machine with 16 outputs and this is what I get: htop screenshot –  NublaII Feb 8 '13 at 16:09
    
Are you on the latest version of FFmpeg? –  d33pika Apr 3 '13 at 2:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.