Forum Moderators: coopster

Message Too Old, No Replies

Getting FFMPEG to work through PHP

Issues getting any video type to convert to FLV through FFMPEG inside PHP

         

Caliber Mengsk

12:30 am on Nov 5, 2007 (gmt 0)

10+ Year Member



Hello,

I'm a newbie to this site, but not really PHP, HTML, ETC. I've gone through 2 years of college for web development, so I know a fair amount of stuff. (As well as growing up programming html since the age of 8)

Anyway, My issue is I have been trying to convert videos to flv's to try to create my own version of youtube, just to see if I can. I can do all the PHP kind of programming, and that's not the issue. Problem is FFMPEG and using the EXEC command in php.

If I run the cmd string from windows, it has no issues converting the video, but as soon as it's run through the exec, system, or any other similar command in PHP, it does nothing but shows the rest of the webpage.

I don't have PHP in safe mode, and I have the exe in the same folder. (my personal server is windows XP with current updates, the newest apache, newest mysql, and newest PHP5.

At one point, I had it working to making 1kb flvs, but that was it. Here is my current running exec line in php:

exec("ffmpeg -i test.avi -acodec mp3 -ar 22050 -ab 32 -f flv test.flv");

Also, is there a way to place it in an if statement or something so I know if it is done converting or not?

eelixduppy

7:25 am on Nov 7, 2007 (gmt 0)



It might be that your script is timing out if you can convert small files but not larger files. You might want to take a look at the max_execution_time directive in your php.ini file. Also, in order to find out if it was correctly converted you can check the output from the exe call by specifying the output variable in the exec [us2.php.net] function.

...and Welcome to WebmasterWorld :)

Caliber Mengsk

1:50 am on Nov 11, 2007 (gmt 0)

10+ Year Member



Thanks, I did have it set to 30 seconds... But that wasn't my main problem XD I don't use the long php initialization(<?php), so I had to turn on the short PHP initialization(<?) to get the command to even run.

Problem is, It's just sitting there now... Not converting video, not even making the file... I know that the video is able to be converted, and I know it takes less then a second to do it. (small and short video file.)

I've run the FFmpeg command from dos and it works fine... But it just sits at the webpage loading.

(Also, is there a way to run this PHP command to where it's not dependant on the user's webpage to be open? I'd like to make it to where they can log back on to see if the video file has been converted or not, but not require the webpage to be uploaded. The only way that this "could" be possible that I can think of off hand may be AJAX, but I don't know for sure if ajax runs without the page being open or not...)