From d4cf7293ad10721eac6c8cca982a3386c7d7c074 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 29 Oct 2021 09:12:17 +0000 Subject: [PATCH] wait #4847 @1 --- inc/commons/class.common.tools.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/inc/commons/class.common.tools.php b/inc/commons/class.common.tools.php index 4ce5a0d2b..851aabdc7 100644 --- a/inc/commons/class.common.tools.php +++ b/inc/commons/class.common.tools.php @@ -1368,10 +1368,10 @@ class commonTools exit; } - public static function _youtubedl($url) + public static function _youtubedl($url, $ch264 = false) { set_time_limit(0); - $dir = '/data/extranet/www/cache/youtubedl'; + $dir = '/data/extranet/www/cache/youtubedl/'; $opts = ' -f \'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4\' -o \'%(id)s-%(title)s.%(ext)s\' --restrict-filenames '; $fname = trim(`youtube-dl --get-filename $opts $url`); @@ -1381,7 +1381,21 @@ class commonTools `cd $dir;youtube-dl $opts $url`; } - return $fname; + if ($ch264) { + $cmd = "ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 $final"; + $codec = `$cmd`; + if ($codec === 'h264') { + return $fname; + } + $fnameh264 = str_replace('.mp4', '.h264.mp4', $fname); + $h264 = $dir . $fnameh264; + if (!file_exists($h264) || filesize($h264) == 0) { + `ffmpeg -i $final -vcodec libx264 -acodec aac $h264`; + } + return $fnameh264; + } else { + return $fname; + } } -- 2.39.5