开发者

Problem with FFMPEG and PHP

I know this isn't exactly a programming question per se, but rather a settings question, but still:

I'm trying to convert video with FFMPEG with a PHP script, following this tutorial:

http://vexxhost.com/blog/2007/05/20/how-to-convertencode-files-to-flv-using-ffmpeg-php/

FFMPEG works perfectly and I've used it from the command line a number of 开发者_开发百科times. PHP also seems to work fine. I've also installed ffmpeg-php and it seems to be loading file.

The problem lies when I try to do the following in PHP:

$srcFile = "p1.avi";

$ffmpegObj = new ffmpeg_movie($srcFile);

No matter what, PHP will return this:

Warning: can't open movie file p1.avi in /var/www/converter.php on line xx

Obviously, whatever call I do afterwards with $ffmpegObj will throw a fatal error. I'm absolutely stuck and extensive googling hasn't helped much.

If you must know, I'm using Ubuntu 9.04 with the default LAMP server packages as well as php5-ffmpeg, and I've compiled ffmpeg following a tutorial I found on Ubuntuforums (I'd link to it but stackoverflow won't let me)

Thanks!


Does the user you run the script as have permission to open the file? Check with ls -l /var/www/flashvideo/p1.avi


FINALLY! As some of you suggested, neither the directory nor the file had the proper permissions to be modified by my script. I changed them and everything works now =) . I'm such an idiot for not noticing this for hours :P

Thank you guys!


Try to specify full path to you movie like following:

$srcFile = "/home/path/something/p1.avi";
$ffmpegObj = new ffmpeg_movie($srcFile);


I know this is an old thread, but since I just ran into this... If ffmpeg_movie is passed a corrupt movie, it seems it'll also throw a warning. There's no way to tell until you actually try to create the object. Best solution I had was to suppress the warning, and then check for the resource before interacting with it:

$movie = @new ffmpeg_movie($path_to_file,false);
$duration = isset($movie->ffmpeg_movie)?intval($movie->getDuration()):'Bad File?';


I have the same issue. It's neither wrong path nor a corrupt movie related. Path is absolute, file exists and readable and permissions are 0777. Sadly, I have no idea what to do with this.

UPD: The problem was an outdated (from repos) ffmpeg version with a lot of bugs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜