|
|
@ -1,8 +1,8 @@ |
|
|
|
<?php |
|
|
|
/* |
|
|
|
* ffmpeg.php |
|
|
|
* A barebones ffmpeg based webm implementation for vichan. |
|
|
|
*/ |
|
|
|
* ffmpeg.php |
|
|
|
* A barebones ffmpeg based webm implementation for vichan. |
|
|
|
*/ |
|
|
|
function get_webm_info($filename) { |
|
|
|
global $board, $config; |
|
|
|
$filename = escapeshellarg($filename); |
|
|
@ -24,21 +24,21 @@ function is_valid_webm($ffprobe_out) { |
|
|
|
if (empty($ffprobe_out)) |
|
|
|
return array('code' => 1, 'msg' => $config['error']['genwebmerror']); |
|
|
|
$extension = pathinfo($ffprobe_out['format']['filename'], PATHINFO_EXTENSION); |
|
|
|
if ($extension === 'webm') { |
|
|
|
if ($extension === 'webm' && !stristr($ffprobe_out['format']['format_name'], 'mp4')) { |
|
|
|
if ($ffprobe_out['format']['format_name'] != 'matroska,webm') |
|
|
|
return array('code' => 2, 'msg' => $config['error']['invalidwebm']); |
|
|
|
return array('code' => 2, 'msg' => $config['error']['invalidwebm']."error 1"); |
|
|
|
} elseif ($extension === 'mp4') { |
|
|
|
if ($ffprobe_out['streams'][0]['codec_name'] != 'h264' && $ffprobe_out['streams'][1]['codec_name'] != 'aac') |
|
|
|
return array('code' => 2, 'msg' => $config['error']['invalidwebm']); |
|
|
|
return array('code' => 2, 'msg' => $config['error']['invalidwebm']."error 2"); |
|
|
|
} else { |
|
|
|
return array('code' => 1, 'msg' => $config['error']['genwebmerror']); |
|
|
|
return array('code' => 1, 'msg' => $config['error']['genwebmerror']."error 3"); |
|
|
|
} |
|
|
|
if ((count($ffprobe_out['streams']) > 1) && (!$config['webm']['allow_audio'])) |
|
|
|
return array('code' => 3, 'msg' => $config['error']['webmhasaudio']); |
|
|
|
return array('code' => 3, 'msg' => $config['error']['webmhasaudio']."error 4"); |
|
|
|
if (empty($ffprobe_out['streams'][0]['width']) || (empty($ffprobe_out['streams'][0]['height']))) |
|
|
|
return array('code' => 2, 'msg' => $config['error']['invalidwebm']); |
|
|
|
return array('code' => 2, 'msg' => $config['error']['invalidwebm']."error 5"); |
|
|
|
if ($ffprobe_out['format']['duration'] > $config['webm']['max_length']) |
|
|
|
return array('code' => 4, 'msg' => sprintf($config['error']['webmtoolong'], $config['webm']['max_length'])); |
|
|
|
return array('code' => 4, 'msg' => sprintf($config['error']['webmtoolong'], $config['webm']['max_length'])."error 6"); |
|
|
|
} |
|
|
|
function make_webm_thumbnail($filename, $thumbnail, $width, $height, $duration) { |
|
|
|
global $board, $config; |
|
|
|