]> _ Git - cubeextranet.git/commitdiff
wait #4847 @1
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 29 Oct 2021 09:12:17 +0000 (09:12 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 29 Oct 2021 09:12:17 +0000 (09:12 +0000)
inc/commons/class.common.tools.php

index 4ce5a0d2b207ff2697bb6efbf8d59ad624c8b35a..851aabdc7644528950afb69aa6d0b96be1bb02fd 100644 (file)
@@ -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;
+        }
     }