mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Add experimental support for GIF->MP4 conversion
This commit is contained in:
parent
61a4400e1f
commit
65c8c6e9c1
7 changed files with 48 additions and 5 deletions
|
|
@ -74,7 +74,9 @@ class fileAdminController extends file
|
|||
$config->image_autoconv['bmp2jpg'] = Context::get('image_autoconv_bmp2jpg') === 'Y' ? true : false;
|
||||
$config->image_autoconv['png2jpg'] = Context::get('image_autoconv_png2jpg') === 'Y' ? true : false;
|
||||
$config->image_autoconv['webp2jpg'] = Context::get('image_autoconv_webp2jpg') === 'Y' ? true : false;
|
||||
$config->image_autoconv['gif2mp4'] = Context::get('image_autoconv_gif2mp4') === 'Y' ? true : false;
|
||||
$config->image_autoconv_quality = max(50, min(100, intval(Context::get('image_autoconv_quality'))));
|
||||
$config->ffmpeg_command = escape(utf8_trim(Context::get('ffmpeg_command'))) ?: '/usr/bin/ffmpeg';
|
||||
$config->image_autorotate = Context::get('image_autorotate') === 'Y' ? true : false;
|
||||
$config->image_autorotate_quality = max(50, min(100, intval(Context::get('image_autorotate_quality'))));
|
||||
|
||||
|
|
@ -161,7 +163,9 @@ class fileAdminController extends file
|
|||
$file_config->image_autoconv['bmp2jpg'] = Context::get('image_autoconv_bmp2jpg') === 'Y' ? true : false;
|
||||
$file_config->image_autoconv['png2jpg'] = Context::get('image_autoconv_png2jpg') === 'Y' ? true : false;
|
||||
$file_config->image_autoconv['webp2jpg'] = Context::get('image_autoconv_webp2jpg') === 'Y' ? true : false;
|
||||
$file_config->image_autoconv['gif2mp4'] = Context::get('image_autoconv_gif2mp4') === 'Y' ? true : false;
|
||||
$file_config->image_autoconv_quality = max(50, min(100, intval(Context::get('image_autoconv_quality'))));
|
||||
$file_config->ffmpeg_command = escape(utf8_trim(Context::get('ffmpeg_command'))) ?: '/usr/bin/ffmpeg';
|
||||
$file_config->image_autorotate = Context::get('image_autorotate') === 'Y' ? true : false;
|
||||
$file_config->image_autorotate_quality = max(50, min(100, intval(Context::get('image_autorotate_quality'))));
|
||||
|
||||
|
|
|
|||
|
|
@ -1064,9 +1064,13 @@ class fileController extends file
|
|||
{
|
||||
$convert = array($image_width, $image_height, 'jpg', $config->image_autoconv_quality ?: 75, 0);
|
||||
}
|
||||
if($config->image_autoconv['gif2mp4'] && function_exists('exec') && $image_type === 1)
|
||||
{
|
||||
$convert = array($image_width, $image_height, 'mp4', $config->image_autoconv_quality ?: 75, 0);
|
||||
}
|
||||
|
||||
// Check image rotation
|
||||
if($config->image_autorotate && function_exists('exif_read_data'))
|
||||
if($config->image_autorotate && $image_type !== 1 && function_exists('exif_read_data'))
|
||||
{
|
||||
$exif = @exif_read_data($file_info['tmp_name']);
|
||||
if($exif && isset($exif['Orientation']))
|
||||
|
|
@ -1154,11 +1158,26 @@ class fileController extends file
|
|||
// Convert image if necessary
|
||||
if ($convert)
|
||||
{
|
||||
$result = FileHandler::createImageFile($file_info['tmp_name'], $file_info['tmp_name'] . '.conv', $convert[0], $convert[1], $convert[2], 'crop', $convert[3], $convert[4]);
|
||||
if ($convert[2] === 'mp4')
|
||||
{
|
||||
$command = $config->ffmpeg_command ?: '/usr/bin/ffmpeg';
|
||||
$command .= ' -i ' . escapeshellarg($file_info['tmp_name']);
|
||||
$command .= ' -movflags faststart -pix_fmt yuv420p -c:v libx264 -crf 23 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"';
|
||||
$command .= ' ' . escapeshellarg($file_info['tmp_name'] . '.mp4');
|
||||
$status = @exec($command, $output, $return_var);
|
||||
$result = $return_var == 0 ? true : false;
|
||||
$newext = '.mp4';
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = FileHandler::createImageFile($file_info['tmp_name'], $file_info['tmp_name'] . '.conv', $convert[0], $convert[1], $convert[2], 'crop', $convert[3], $convert[4]);
|
||||
$newext = '.conv';
|
||||
}
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$file_info['name'] = preg_replace('/\.' . preg_quote($file_info['extension'], '/') . '$/i', '.' . $convert[2], $file_info['name']);
|
||||
$file_info['tmp_name'] = $file_info['tmp_name'] . '.conv';
|
||||
$file_info['tmp_name'] = $file_info['tmp_name'] . $newext;
|
||||
$file_info['size'] = filesize($file_info['tmp_name']);
|
||||
$file_info['extension'] = $convert[2];
|
||||
$file_info['converted'] = true;
|
||||
|
|
|
|||
|
|
@ -202,6 +202,7 @@ class fileModel extends file
|
|||
$config->image_autoconv_quality = $file_config->image_autoconv_quality;
|
||||
$config->image_autorotate = $file_config->image_autorotate;
|
||||
$config->image_autorotate_quality = $file_config->image_autorotate_quality;
|
||||
$config->ffmpeg_command = $file_config->ffmpeg_command;
|
||||
$config->download_grant = $file_config->download_grant;
|
||||
$config->allow_outlink = $file_config->allow_outlink;
|
||||
$config->allow_outlink_site = $file_config->allow_outlink_site;
|
||||
|
|
@ -226,6 +227,7 @@ class fileModel extends file
|
|||
if(!$config->image_autoconv_quality) $config->image_autoconv_quality = $file_module_config->image_autoconv_quality;
|
||||
if(!$config->image_autorotate) $config->image_autorotate = $file_module_config->image_autorotate;
|
||||
if(!$config->image_autorotate_quality) $config->image_autorotate_quality = $file_module_config->image_autorotate_quality;
|
||||
if(!$config->ffmpeg_command) $config->ffmpeg_command = $file_module_config->ffmpeg_command;
|
||||
|
||||
// Default setting if not exists
|
||||
if(!$config->allowed_filesize) $config->allowed_filesize = '2';
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ $lang->image_autoconv = 'Auto-Convert Image';
|
|||
$lang->image_autoconv_bmp2jpg = 'BMP → JPG';
|
||||
$lang->image_autoconv_png2jpg = 'PNG → JPG';
|
||||
$lang->image_autoconv_webp2jpg = 'WebP → JPG';
|
||||
$lang->image_autoconv_gif2mp4 = 'GIF → MP4';
|
||||
$lang->ffmpeg_path = 'Path to ffmpeg';
|
||||
$lang->image_autorotate = 'Auto-Rotate Image';
|
||||
$lang->inline_download_format = 'Open in current window';
|
||||
$lang->inline_download_image = 'Image';
|
||||
|
|
@ -49,6 +51,7 @@ $lang->about_allowed_size_limits = 'The file size will be limited to the value s
|
|||
$lang->about_allowed_filetypes = 'Rhymix no longer uses the old *.* syntax. Simply list the extensions you wish to allow.<br />Please use a comma (,) to separate items: e.g. doc, zip, pdf';
|
||||
$lang->about_max_image_size = 'You can limit the maximum width and/or height of uploaded images.<br />This limit does not apply to files uploaded by the administrator.';
|
||||
$lang->about_image_autoconv = 'Automatically convert types of images that often cause trouble or waste disk space into other types.<br />This also works for WebP images that incorrectly have the JPG extension.<br />If enabled, this feature also applies to images uploaded by the administrator.';
|
||||
$lang->about_image_autoconv_mp4 = 'Automatically convert animated GIF images into MP4 videos to save storage and bandwidth.<br />Videos may not play properly in older browsers.';
|
||||
$lang->about_image_autorotate = 'Automatically correct images that are rotated by mobile devices.<br />If enabled, this feature also applies to images uploaded by the administrator.';
|
||||
$lang->cmd_delete_checked_file = 'Delete Selected Item(s)';
|
||||
$lang->cmd_move_to_document = 'Move to Document';
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ $lang->image_autoconv = '이미지 자동 변환';
|
|||
$lang->image_autoconv_bmp2jpg = 'BMP → JPG';
|
||||
$lang->image_autoconv_png2jpg = 'PNG → JPG';
|
||||
$lang->image_autoconv_webp2jpg = 'WebP → JPG';
|
||||
$lang->image_autoconv_gif2mp4 = 'GIF → MP4';
|
||||
$lang->ffmpeg_path = 'ffmpeg 경로';
|
||||
$lang->image_autorotate = '이미지 자동 회전';
|
||||
$lang->inline_download_format = '다운로드시 현재 창 사용';
|
||||
$lang->inline_download_image = '이미지';
|
||||
|
|
@ -49,6 +51,7 @@ $lang->about_allowed_size_limits = 'IE9 이하, 구버전 안드로이드 등에
|
|||
$lang->about_allowed_filetypes = '업로드를 허용할 확장자 목록입니다. 구 버전의 *.* 문법은 사용하지 않습니다.<br />여러 개 입력시 쉼표(,)을 이용해서 구분해 주세요. 예) doc, zip, pdf';
|
||||
$lang->about_max_image_size = '이미지 파일의 가로, 세로, 또는 가로세로 크기를 모두 제한할 수 있습니다.<br />관리자가 업로드한 파일에는 적용되지 않습니다.';
|
||||
$lang->about_image_autoconv = '종종 문제를 일으키거나 용량을 낭비하는 이미지 타입을 다른 타입으로 자동 변환합니다.<br />WebP 이미지에 JPG 확장자가 잘못 부여된 경우에도 변환할 수 있습니다.<br />관리자가 업로드한 파일에도 적용됩니다.';
|
||||
$lang->about_image_autoconv_mp4 = '움직이는 GIF 이미지를 MP4 동영상으로 변환하여 용량 및 트래픽을 절약합니다.<br />구형 브라우저에서는 동영상이 재생되지 않을 수도 있습니다.';
|
||||
$lang->about_image_autorotate = '모바일 기기 등에서 잘못 회전된 이미지를 바로잡습니다.<br />관리자가 업로드한 파일에도 적용됩니다.';
|
||||
$lang->cmd_delete_checked_file = '선택항목 삭제';
|
||||
$lang->cmd_move_to_document = '문서로 이동';
|
||||
|
|
|
|||
|
|
@ -81,7 +81,13 @@
|
|||
<option value="{$q}" selected="selected"|cond="$file_config->image_autoconv_quality == $q">{$lang->image_resize_quality} {$q}%</option>
|
||||
<!--@endfor-->
|
||||
</select>
|
||||
<p class="x_help-block">{$lang->about_image_autoconv}</p>
|
||||
<p class="x_help-block" style="margin-bottom:10px">{$lang->about_image_autoconv}</p>
|
||||
<label for="image_autoconv_gif2mp4" class="x_inline">
|
||||
<input type="checkbox" name="image_autoconv_gif2mp4" id="image_autoconv_gif2mp4" value="Y" checked="checked"|cond="$file_config->image_autoconv['gif2mp4']" disabled="disabled"|cond="!function_exists('exec')" />
|
||||
{$lang->image_autoconv_gif2mp4}
|
||||
</label>
|
||||
<input type="text" name="ffmpeg_command" id="ffmpeg_command" value="{$file_config->ffmpeg_command ?: '/usr/bin/ffmpeg'}" placeholder="{$lang->ffmpeg_path}" />
|
||||
<p class="x_help-block">{$lang->about_image_autoconv_mp4}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
|
|
|
|||
|
|
@ -68,7 +68,13 @@
|
|||
<option value="{$q}" selected="selected"|cond="$config->image_autoconv_quality == $q">{$lang->image_resize_quality} {$q}%</option>
|
||||
<!--@endfor-->
|
||||
</select>
|
||||
<p class="x_help-block">{$lang->about_image_autoconv}</p>
|
||||
<p class="x_help-block" style="margin-bottom:10px">{$lang->about_image_autoconv}</p>
|
||||
<label for="image_autoconv_gif2mp4" class="x_inline">
|
||||
<input type="checkbox" name="image_autoconv_gif2mp4" id="image_autoconv_gif2mp4" value="Y" checked="checked"|cond="$config->image_autoconv['gif2mp4']" disabled="disabled"|cond="!function_exists('exec')" />
|
||||
{$lang->image_autoconv_gif2mp4}
|
||||
</label>
|
||||
<input type="text" name="ffmpeg_command" id="ffmpeg_command" value="{$config->ffmpeg_command ?: '/usr/bin/ffmpeg'}" placeholder="{$lang->ffmpeg_path}" />
|
||||
<p class="x_help-block">{$lang->about_image_autoconv_mp4}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue