1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-02-21 21:19:36 +01:00
This commit is contained in:
8chan 2015-03-09 22:11:29 -07:00
parent 7005a2d473
commit e43764a158

View File

@ -57,13 +57,22 @@ function make_webm_thumbnail($filename, $thumbnail, $width, $height, $duration)
global $board, $config;
$filename = escapeshellarg($filename);
$thumbnail = escapeshellarg($thumbnail); // Should be safe by default but you
//$thumbnail = escapeshellarg($thumbnail); // Should be safe by default but you
// can never be too safe.
$ffmpeg = $config['webm']['ffmpeg_path'];
$ret = 0;
$ffmpeg_out = array();
exec("$ffmpeg -strict -2 -ss " . floor($duration / 2) . " -i $filename -v quiet -an -vframes 1 -f mjpeg -vf scale=$width:$height $thumbnail 2>&1", $ffmpeg_out, $ret);
// Work around for https://trac.ffmpeg.org/ticket/4362
if (filesize($thumbnail) === 0) {
// try again with first frame
exec("$ffmpeg -y -strict -2 -ss 0 -i $filename -v quiet -an -vframes 1 -f mjpeg -vf scale=$width:$height $thumbnail 2>&1", $ffmpeg_out, $ret);
clearstatcache();
// failed if no thumbnail size even if ret code 0, ffmpeg is buggy
if (filesize($thumbnail) === 0) {
$ret = 1;
}
}
return $ret;
}