Fuxi
Fuxi

Reputation: 7599

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?

Upvotes: 0

Views: 795

Answers (2)

Roey
Roey

Reputation: 1725

i had the same problem exactly.

using proc_open instead of exec and its variants fixed it.

Roey

Upvotes: 0

soniccool
soniccool

Reputation: 6058

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`;


?>

Upvotes: 1

Related Questions