tags:

views:

34

answers:

1

Let's say that I created a video with something like Camtasia and saved it as .avi. How would I go about programmatically extracting a subclip let's say from minute 1:00 to 1:50. Is this something PHP can handle?

Edit: I don't mind using libraries, including ffmpeg if PHP can't handle it alone. But I'm not looking forward to something through the command-line. Ideally it would through PHP.

P.S. I think some video capture programs like Camtasia may have their own codecs (I think Camtiasia calls it TechSmith). Not sure if this makes any difference to the PHP script.

+5  A: 

I highly discourage you from using PHP to do this directly. There are plenty of video manipulation tools that you can run from the command-line (ffmpeg, for instance) that would do it far more efficiently. If you want to get somewhat fancy (and want to dramatically increase your site's responsiveness), you could pop the job into a database and have a constantly-running service do the clip extraction, updating the database with the relevant information when it's done.

Just an idea, of course. There may be a module out there with PHP bindings that processes video, but you'd still have the problem of making the user wait (and occupying webserver resources) while the video is chopped up.

Faisal
+1. I was thinking that this was a bad use-case for PHP.
Kalium
@Faisal, I have ffmpeg on the server, so I don't mind using it if it will help the job, but I'm looking for a script solution, not through command-line
cooper
PHP can invoke command-line-based tools, if that's what you mean -- check out http://us3.php.net/manual/en/function.popen.php, for instance. One question: is it ok for your site not return the sliced video immediately (e.g. put it on a queue and have the user check back later), or is the user willing to wait while it's processed? If they're willing to wait, set_time_limit(0) and then popen() may be the way to go.
Faisal