Reputation: 195
I'm kind of new with FFmpeg but as a project to learn some mysql databasing I'm trying to create a video upload site.
When I try to make a thumbnail with this code:
shell_exec("/usr/local/bin/ffmpeg -i anim.flv -an -ss 00:00:03 -an -r 1 -vframes 1 -y test.jpg");
nothing happens, no image appear in the same directory as the anim.flv, is there something wrong with the code or what could the problem be?
Upvotes: 2
Views: 2331
Reputation: 10469
This works for me: ffmpeg -ss 00:00:10 -i $file -y -an -vframes 1 $dir/$name.png
Upvotes: 1
Reputation: 875
Try this code
$flvfile = 'clock.flv';
$imagefile = 'test.jpg';
exec('ffmpeg -i ' . $flvfile . ' -f mjpeg -vframes 1 -s 150x150 -an ' . $imagefile . '');
Upvotes: 0
Reputation: 12815
Try this command:
$infile = 'anim.flv';
$outfile = 'test.jpg';
exec("/usr/local/bin/ffmpeg -i " . escapeshellarg($infile) . " -an -ss 00:00:03 -an -r 1 -vframes 1 -y " . escapeshellarg($outfile) . " 2>&1", $output, $returnValue);
if (!file_exists($outfile)) {
die("Could not generate thumbnail. ffmpeg output: \n\n" . implode("\n", $output));
}
This way you will get some detailed output from ffmpeg when it doesn't work (the "2>&1" redirects ffmpeg's error output to stdout; otherwise you would not be able to retrieve it).
I have 2 suggestions that might fix your command; first, add the arguments "-vcodec mjpeg -f rawvideo" before specifying the output file, and second, use absolute paths for the input and output, so you don't have to worry about where your script's current working directory is.
Upvotes: 0