Merge pull request #1238 from ehii/ffmpeg

윈도우서버에서 ffmpge 호환성 개선
This commit is contained in:
Kijin Sung 2020-02-12 14:06:17 +09:00 committed by GitHub
commit e064a742ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View file

@ -77,8 +77,16 @@ class fileAdminController extends file
$config->image_remove_exif_data = Context::get('image_remove_exif_data') === 'Y' ? true : false;
$config->video_thumbnail = Context::get('video_thumbnail') === 'Y' ? true : false;
$config->video_mp4_gif_time = intval(Context::get('video_mp4_gif_time'));
$config->ffmpeg_command = escape(utf8_trim(Context::get('ffmpeg_command'))) ?: '/usr/bin/ffmpeg';
$config->ffprobe_command = escape(utf8_trim(Context::get('ffprobe_command'))) ?: '/usr/bin/ffprobe';
if(strtoupper(substr(\PHP_OS, 0, 3)) === 'WIN')
{
$config->ffmpeg_command = escape(Context::get('ffmpeg_command')) ?: 'C:\Program Files\ffmpeg\bin\ffmpeg.exe';
$config->ffprobe_command = escape(Context::get('ffprobe_command')) ?: 'C:\Program Files\ffmpeg\bin\ffprobe.exe';
}
else
{
$config->ffmpeg_command = escape(utf8_trim(Context::get('ffmpeg_command'))) ?: '/usr/bin/ffmpeg';
$config->ffprobe_command = escape(utf8_trim(Context::get('ffprobe_command'))) ?: '/usr/bin/ffprobe';
}
// Check maximum file size
if (PHP_INT_SIZE < 8)

View file

@ -1178,8 +1178,15 @@ class fileController extends file
$adjusted['height'] -= $adjusted['height'] % 2;
// Convert using ffmpeg
$command = $config->ffmpeg_command;
$command .= ' -i ' . escapeshellarg($file_info['tmp_name']);
if(strtoupper(substr(\PHP_OS, 0, 3)) === 'WIN')
{
$command = escapeshellarg($config->ffmpeg_command);
}
else
{
$command = $config->ffmpeg_command;
}
$command .= ' -nostdin -i ' . escapeshellarg($file_info['tmp_name']);
$command .= ' -movflags +faststart -pix_fmt yuv420p -c:v libx264 -crf 23';
$command .= sprintf(' -vf "scale=%d:%d"', $adjusted['width'], $adjusted['height']);
$command .= ' ' . escapeshellarg($output_name);