to handle individual downloads, you want to use something like ffmpeg to move metadata (the MOOV atom) to the front of the video:
./ffmpeg -y -i SourceFile.mp4 -s 1280x720 -c:v libx264 -b 3M -strict -2 -movflags faststart DestFile.mp4
The above result will give you an output of 1280x720 at a speed of 3 Mbps, using h264 in the mp4 container, and also make a second pass to move the moov element to the front of the file, which allows it to start the stream faster. It will not transcode audio, so it will retain the quality that you started with
You might want to play around with freesis and bitrate to get a file size that matches what you like / needs.
to do this in the background, you'll want to look at something like this to call ffmpeg with PHP, or use http://ffmpeg-php.sourceforge.net/ , or if it's easier to use a remote transcode service like http: / /ffmpegasaservice.com/
source share