Re: using PHP - how to convert video (avi, mp4, mkv) or even extract audio/video/subt
I'm going to try to strongly discourage you from trying this at all. Video conversion (decoding, then encoding) requires a lot of processing cycles and a large memory space, and getting conversion speeds significantly faster than real-time (one second of video takes one second to convert) takes a lot of horsepower. It's not even close to practical in a shared environment -- even if the timesharing and memory management were perfect and never allowed your code more than its share of resources, the processing time would increase to the point that burning a disc and hand-delivering it would be a practical alternative.
Even the typical VPS would be underpowered for the task, and it's not something where you can just spawn a new instance to share the load (as you can with a request/reponse web server). That means a dedicated or co-located server with above-average specs. And that means money with a capital M. And you still won't be able to do it fast enough for a browser to wait for the results.
It's far more practical to do the conversion on your local machine/network without the PHP layer, even if the object of the game is to move the files to a web server for download.
“Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
"It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)