Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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
Did you find any parameter for using multi processors?! – Mr.Hyde Aug 19 '15 at 4:45
what do you mean by "get stopped" here? bash shows them as paused? – rogerdpack Jan 31 at 4:33

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
What is this: 2>&1 – Mr.Hyde Aug 10 '15 at 6:12

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:

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
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
@NublaII What is > /dev/null 2>&1 !? – Mr.Hyde Aug 23 '15 at 11:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .