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`);
`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;
+ }
}