mirror of
https://github.com/vichan-devel/vichan.git
synced 2025-02-19 20:23:17 +01:00
Merge pull request #331 from marktaiwan/better-webm-thumbnail
Better webm thumbnail
This commit is contained in:
commit
fd7620bddf
@ -19,6 +19,7 @@ function get_webm_info($filename) {
|
|||||||
if(empty($webminfo['error'])) {
|
if(empty($webminfo['error'])) {
|
||||||
$webminfo['width'] = $ffprobe_out['streams'][0]['width'];
|
$webminfo['width'] = $ffprobe_out['streams'][0]['width'];
|
||||||
$webminfo['height'] = $ffprobe_out['streams'][0]['height'];
|
$webminfo['height'] = $ffprobe_out['streams'][0]['height'];
|
||||||
|
$webminfo['duration'] = $ffprobe_out['format']['duration'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $webminfo;
|
return $webminfo;
|
||||||
@ -52,7 +53,7 @@ function is_valid_webm($ffprobe_out) {
|
|||||||
return array('code' => 4, 'msg' => $config['error']['webmtoolong']);
|
return array('code' => 4, 'msg' => $config['error']['webmtoolong']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_webm_thumbnail($filename, $thumbnail, $width, $height) {
|
function make_webm_thumbnail($filename, $thumbnail, $width, $height, $duration) {
|
||||||
global $board, $config;
|
global $board, $config;
|
||||||
|
|
||||||
$filename = escapeshellarg($filename);
|
$filename = escapeshellarg($filename);
|
||||||
@ -62,7 +63,7 @@ function make_webm_thumbnail($filename, $thumbnail, $width, $height) {
|
|||||||
|
|
||||||
$ret = 0;
|
$ret = 0;
|
||||||
$ffmpeg_out = array();
|
$ffmpeg_out = array();
|
||||||
exec("$ffmpeg -strict -2 -i $filename -v quiet -ss 00:00:00 -an -vframes 1 -f mjpeg -vf scale=$width:$height $thumbnail 2>&1", $ffmpeg_out, $ret);
|
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);
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ function postHandler($post) {
|
|||||||
$file = set_thumbnail_dimensions($post, $file);
|
$file = set_thumbnail_dimensions($post, $file);
|
||||||
$tn_path = $board['dir'] . $config['dir']['thumb'] . $file->file_id . '.jpg';
|
$tn_path = $board['dir'] . $config['dir']['thumb'] . $file->file_id . '.jpg';
|
||||||
|
|
||||||
if(0 == make_webm_thumbnail($file->file_path, $tn_path, $file->thumbwidth, $file->thumbheight)) {
|
if(0 == make_webm_thumbnail($file->file_path, $tn_path, $file->thumbwidth, $file->thumbheight, $webminfo['duration'])) {
|
||||||
$file->thumb = $file->file_id . '.jpg';
|
$file->thumb = $file->file_id . '.jpg';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user