I'm starting up a Debian web server which will host a website where users can upload video files and play them.

Hence, the video files need to be converted into the proper format (mp4, ogg, webm) for compatibility with the different browsers out there.

So far, I've written a bash script which does the trick using FFmpeg. The problem is, when a lot of users upload a video at the same time, my web server will get very slow.

I'm looking for a short and easy solution which queues different calls to the conversion script, so only one instance can run at the same time. I've tried using the batch command, but I can't find very much information on how to use it. I've also considered creating a named pipe, also without success.

Any help much appreciated

  • Slightly off-topic, but you probably don't need to bother with ogg for HTML5 video - mp4 and webm will cover all major web browsers (and most minor ones too).
    – evilsoup
    Jan 31, 2013 at 21:05

2 Answers 2


Put all the completed uploaded files in one directory, with whatever web language you are using.

Then you can schedule a cronjob with your script, to run for example every hour and convert the videos that are in the pending/ directory.

You might want to use flock so that only one instance of this script can run at the same moment, even if it takes longer than expected and cron launches another script.

Within the script you can use nice to reduce it's priority so the web server will have higher priority.


I've created a python3 video encode server for my internal use. With a few mods it should do the trick for you. With my python server, all you have to do is create a symlink in a special queue directory and it handles it from there, it also handles commercial skipping (of which I'm the Linux porter) which you could comment out if you're not interested in that.



You must log in to answer this question.

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