php and ffmpeg 500 internal server error

i'm trying to extract a single frame from a video file using the following php code:

$cmd = 'ffmpeg -i "d:\webs\beta\test\sample2.mp4" -vframes 1 -s 146x82 -f image2 "d:\webs\beta\test.jpg"';
exec($cmd, $rc);    

the problem is that i'm getting an 500 internal server error the first time i'm trying to execute the script, but when reloading it works. so it means when reloading: works / doesn't work / works ..

any ideas what could be wrong?

Answers


Try this script.

<?php

$ffmpeg = "/full/path/to/ffmpeg";

$videoFile = "/full/path/to/video.mp4";

$imgOut = "/full/path/to/frame.jpg";

$second = 0;

$cmd = $ffmpeg." -i \"".$videoFile."\" -an -ss ".$second.".001 -y -f mjpeg \"".$imgOut."\" 2>&1";

$feedback = `$cmd`;


?>

i had the same problem exactly.

using proc_open instead of exec and its variants fixed it.

Roey


Need Your Help

Coldfusion query and assign rows to a session

oracle coldfusion

I have come across a strange requirement, and really haven't a clue where to begin