MP4 support
This commit is contained in:
parent
428dfaf264
commit
57becb0fe2
|
@ -472,6 +472,7 @@ INSERT INTO `PREFIX_filetypes`
|
|||
( 'mp3', '', 'mp3.png', 36, 48, 1),
|
||||
( 'ogg', '', 'ogg.png', 36, 48, 1),
|
||||
( 'webm', 'video/webm', '', 0, 0, 0),
|
||||
( 'mp4', 'video/mp4', '', 0, 0, 0),
|
||||
( 'css', '', 'css.png', 36, 48, 1),
|
||||
( 'swf', 'application/x-shockwave-flash', 'flash.png', 36, 48, 1);
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
INSERT INTO `filetypes` (`filetype`, `mime`, `force_thumb`) VALUES ('mp4', 'video/mp4', '0');
|
|
@ -315,7 +315,7 @@ if (isset($_POST['makepost'])) { // A more evident way to identify post action,
|
|||
|
||||
foreach($upload_class->attachments as $attachment) {
|
||||
if ($attachment['attachmenttype'] == 'file') {
|
||||
$thumbfiletype = ($attachment['filetype_withoutdot'] == 'webm') ? '.jpg' : $attachment['file_type'];
|
||||
$thumbfiletype = ($attachment['filetype_withoutdot'] == 'webm' || $attachment['filetype_withoutdot'] == 'mp4') ? '.jpg' : $attachment['file_type'];
|
||||
if ($attachment['emoji_candidate']) {
|
||||
$emoji_candidates []= $attachment;
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@
|
|||
</a>
|
||||
{elseif $embed.nonstandard_file neq ''}
|
||||
<a
|
||||
{if $embed.file_type eq 'webm'} class="movie" data-id="{$post.id}" data-thumb="{$embed.nonstandard_file}" data-width="{$embed.image_w}" data-height="{$embed.image_h}"{/if}
|
||||
{if $embed.file_type eq 'webm' or $embed.file_type eq 'mp4'} class="movie" data-id="{$post.id}" data-thumb="{$embed.nonstandard_file}" data-width="{$embed.image_w}" data-height="{$embed.image_h}"{/if}
|
||||
{if $embed.file_type eq 'mp3' or $embed.file_type eq 'ogg'} class="audiowrap" {/if}
|
||||
{if $embed.file_type eq 'css'} class="csswrap" {/if}
|
||||
{if %KU_NEWWINDOW}target="_blank"{/if}
|
||||
|
|
|
@ -377,7 +377,7 @@ class Board {
|
|||
$file_found = false;
|
||||
foreach ($thread['embeds'] as $embed) {
|
||||
if ($embed['file'] != 'removed') {
|
||||
if (in_array($embed['file_type'], array('jpg', 'png', 'gif', 'webm'))) {
|
||||
if (in_array($embed['file_type'], array('jpg', 'png', 'gif', 'webm', 'mp4'))) {
|
||||
$file_found = $embed;
|
||||
break;
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ class Board {
|
|||
|
||||
if ($file_found) {
|
||||
if ($file_found['file'] !== 'removed') {
|
||||
if ($file_found['file_type'] == 'webm')
|
||||
if ($file_found['file_type'] == 'webm' || $file_found['file_type'] == 'mp4')
|
||||
$file_found['file_type'] = 'jpg';
|
||||
if (in_array($file_found['file_type'], array('jpg', 'png', 'gif'))) {
|
||||
$file_path = getCLBoardPath($this->board['name'], $this->board['loadbalanceurl_formatted'], $this->archive_dir);
|
||||
|
|
|
@ -240,19 +240,19 @@ class Upload {
|
|||
$this->exitWithUploadErrorPage(sprintf(_gettext('Please make sure your file is smaller than %d KB'), round($board_class->board['maximagesize']) / 1024), $atype, $i, $filename);
|
||||
}
|
||||
}
|
||||
|
||||
$pass = true;
|
||||
if (!is_file($attachment['tmp_name']) || !is_readable($attachment['tmp_name'])) {
|
||||
$pass = false;
|
||||
}
|
||||
else {
|
||||
$attachment['is_video'] = ($attachment['file_type'] == '.webm' || $attachment['file_type'] == '.mp4');
|
||||
if(in_array($attachment['file_type'], array('.jpg', '.gif', '.png'))) {
|
||||
if (!@getimagesize($attachment['tmp_name'])) {
|
||||
$pass = false;
|
||||
}
|
||||
}
|
||||
elseif($attachment['file_type'] == '.webm') {
|
||||
$pass = $this->webmCheck($attachment['tmp_name']);
|
||||
elseif($attachment['is_video']) {
|
||||
$pass = $this->ffProbe($attachment['tmp_name']);
|
||||
}
|
||||
}
|
||||
if (!$pass) {
|
||||
|
@ -284,10 +284,10 @@ class Upload {
|
|||
$attachment['imgWidth'] = $svg->width;
|
||||
$attachment['imgHeight'] = $svg->height;
|
||||
}
|
||||
elseif($attachment['file_type'] == '.webm') {
|
||||
$webminfo = $pass;
|
||||
$attachment['imgWidth'] = $webminfo['width'];
|
||||
$attachment['imgHeight'] = $webminfo['height'];
|
||||
elseif($attachment['is_video']) {
|
||||
$videoinfo = $pass;
|
||||
$attachment['imgWidth'] = $videoinfo['width'];
|
||||
$attachment['imgHeight'] = $videoinfo['height'];
|
||||
}
|
||||
else {
|
||||
$imageDim = getimagesize($attachment['tmp_name']);
|
||||
|
@ -328,8 +328,8 @@ class Upload {
|
|||
} else {
|
||||
$attachment['file_location'] = KU_BOARDSDIR . $board_class->board['name'] . '/src/' . $attachment['file_name'] . $attachment['file_type'];
|
||||
|
||||
if($attachment['file_type'] == '.webm') {
|
||||
$thumbs = $this->webmThumb($attachment['tmp_name'], KU_BOARDSDIR . $board_class->board['name'] . '/thumb/', $attachment['file_name'], $webminfo['midtime']);
|
||||
if($attachment['is_video']) {
|
||||
$thumbs = $this->ffThumb($attachment['tmp_name'], KU_BOARDSDIR . $board_class->board['name'] . '/thumb/', $attachment['file_name'], $videoinfo['midtime']);
|
||||
if($thumbs) {
|
||||
$attachment['imgWidth_thumb'] = $thumbs['thumbwidth'];
|
||||
$attachment['imgHeight_thumb'] = $thumbs['thumbheight'];
|
||||
|
@ -467,7 +467,8 @@ class Upload {
|
|||
/* Check if the filetype provided comes with a MIME restriction */
|
||||
if ($filetype_required_mime != '') {
|
||||
/* Check if the MIMEs don't match up */
|
||||
if (finfo_file( finfo_open( FILEINFO_MIME_TYPE ), $attachment['file_location']) != $filetype_required_mime) {
|
||||
$finfo = finfo_open( FILEINFO_MIME_TYPE );
|
||||
if (finfo_file($finfo, $attachment['file_location']) != $filetype_required_mime) {
|
||||
/* Delete the file we just uploaded and kill the script */
|
||||
unlink($attachment['file_location']);
|
||||
$this->exitWithUploadErrorPage(_gettext('Invalid MIME type for this filetype.'), $atype, $i, $filename);
|
||||
|
@ -577,23 +578,21 @@ class Upload {
|
|||
} unset($i);
|
||||
}
|
||||
|
||||
function webmCheck($filepath) {
|
||||
function ffProbe($filepath) {
|
||||
if(KU_FFMPEGPATH) putenv('PATH=' . KU_FFMPEGPATH . PATH_SEPARATOR . getenv('PATH'));
|
||||
exec("ffprobe -i ".$filepath." 2>&1", $finfo, $x);
|
||||
if($x !== 0) return false;
|
||||
$finfo = implode('<br>', $finfo);
|
||||
preg_match('/Duration: (\d\d\:\d\d\:\d\d\.\d\d)/', $finfo, $duration);
|
||||
preg_match('/(\d+)x(\d+)/', $finfo, $dimensions);
|
||||
$hhmmss = explode(':', $duration[1]);
|
||||
if(count($duration) == 2 && count($dimensions) == 3) return array(
|
||||
'width' => $dimensions[1],
|
||||
'height' => $dimensions[2],
|
||||
'midtime' => gmdate("H:i:s", ($hhmmss[0]*3600 + $hhmmss[1]*60+ round($hhmmss[2]))/2)
|
||||
exec("ffprobe -v error -show_entries format=duration:stream=width,height -of default=noprint_wrappers=1:nokey=1 ".$filepath." 2>&1", $finfo, $x);
|
||||
if($x !== 0 || count($finfo) !== 3) return false;
|
||||
$w = (int)$finfo[0];
|
||||
$h = (int)$finfo[1];
|
||||
$s = (float)$finfo[2];
|
||||
return array(
|
||||
'width' => $w,
|
||||
'height' => $h,
|
||||
'midtime' => gmdate("H:i:s", $s/2)
|
||||
);
|
||||
else return false;
|
||||
}
|
||||
|
||||
function webmThumb($filepath, $thumbpath, $filename, $midtime) {
|
||||
function ffThumb($filepath, $thumbpath, $filename, $midtime) {
|
||||
if(KU_FFMPEGPATH) putenv('PATH=' . KU_FFMPEGPATH . PATH_SEPARATOR . getenv('PATH'));
|
||||
$scale = "w=".KU_THUMBWIDTH.":h=".KU_THUMBHEIGHT;
|
||||
$scalecat = "w=".KU_CATTHUMBWIDTH.":h=".KU_CATTHUMBHEIGHT;
|
||||
|
|
|
@ -182,7 +182,7 @@ function GetFileAndThumbs($file) {
|
|||
$res []= '/thumb/'.$file['file'].'c.png';
|
||||
$res []= '/thumb/'.$file['file'].'c.gif';
|
||||
}
|
||||
if ($file['file_type'] == 'webm') {
|
||||
if ($file['file_type'] == 'webm' || $file['file_type'] == 'mp4') {
|
||||
$res []= '/thumb/'.$file['file'].'s.jpg';
|
||||
$res []= '/thumb/'.$file['file'].'c.jpg';
|
||||
}
|
||||
|
|
|
@ -2332,8 +2332,8 @@ function readyset() {
|
|||
});
|
||||
return false;
|
||||
})
|
||||
//Webm expanding
|
||||
.on('click', '.movie', function(event) {expandwebm($(this), event)})
|
||||
//Video expanding
|
||||
.on('click', '.movie', function(event) {expandVideo($(this), event)})
|
||||
//new quick reply
|
||||
.on('click', '.qrl', quickreply)
|
||||
// ID highlighting
|
||||
|
@ -3144,7 +3144,7 @@ else {
|
|||
}
|
||||
}
|
||||
|
||||
function expandwebm($mov, ev) {
|
||||
function expandVideo($mov, ev) {
|
||||
//good luck understanding this shitcode :^)
|
||||
let $reply = $mov.parents('.reply')
|
||||
if($mov.data('expanded') !== '1') {
|
||||
|
@ -4598,7 +4598,7 @@ var catalog = {
|
|||
},
|
||||
fileTypes: {
|
||||
image: ['jpg', 'gif', 'png'],
|
||||
jpgThumb: ['webm', 'cob', 'vim', 'you'],
|
||||
jpgThumb: ['webm', 'mp4', 'cob', 'vim', 'you'],
|
||||
iconsAvailable: ['swf', 'mp3', 'ogg', 'css', 'flv'],
|
||||
audio: ['mp3', 'ogg'],
|
||||
embed: ['cob', 'vim', 'you']
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue