From 0cb07800276255b1db058721d55ddb02b6533c8a Mon Sep 17 00:00:00 2001 From: Daniel Neto Date: Sun, 25 Aug 2024 23:03:53 -0300 Subject: [PATCH] https://github.com/WWBN/AVideo/issues/9353 --- install/checkConfiguration.php | 2 +- install/database.sql | 18 +++++++++--------- objects/Format.php | 25 +++++++++++++++++++++++++ update/updateDb.v5.1.sql | 23 +++++++++++++++++++++++ 4 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 update/updateDb.v5.1.sql diff --git a/install/checkConfiguration.php b/install/checkConfiguration.php index 96d0fc26..994d8028 100644 --- a/install/checkConfiguration.php +++ b/install/checkConfiguration.php @@ -7,7 +7,7 @@ $_POST['databaseName'] = str_replace('-', '_', $_POST['databaseName']); require_once '../objects/functions.php'; -$installationVersion = '5.0'; +$installationVersion = '5.1'; header('Content-Type: application/json'); diff --git a/install/database.sql b/install/database.sql index 426183a8..b9628a9d 100644 --- a/install/database.sql +++ b/install/database.sql @@ -118,16 +118,16 @@ SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; INSERT INTO `formats` VALUES -(1,'MP4 Low','ffmpeg -i {$pathFileName} -vf scale=-2:360 -movflags +faststart -preset veryfast -vcodec h264 -acodec aac -max_muxing_queue_size 1024 -y {$destinationFile}',now(),now(),'mp4','mp4',10), -(2,'WEBM Low','ffmpeg -i {$pathFileName} -vf scale=-2:360 -movflags +faststart -preset veryfast -f webm -c:v libvpx -b:v 1M -acodec libvorbis -y {$destinationFile}',now(),now(),'webm','mp4',20), +(1,'MP4 Low','ffmpeg -i {$pathFileName} -vf scale=-2:360 -movflags +faststart -preset veryfast -vcodec h264 -b:v 700k -acodec aac -b:a 96k -max_muxing_queue_size 1024 -y {$destinationFile}',now(),now(),'mp4','mp4',10), +(2,'WEBM Low','ffmpeg -i {$pathFileName} -vf scale=-2:360 -movflags +faststart -preset veryfast -f webm -c:v libvpx -b:v 700k -acodec libvorbis -b:a 96k -y {$destinationFile}',now(),now(),'webm','mp4',20), (3,'MP3','ffmpeg -i {$pathFileName} -acodec libmp3lame -y {$destinationFile}',now(),now(),'mp3','mp3',30), (4,'OGG','ffmpeg -i {$pathFileName} -acodec libvorbis -y {$destinationFile}',now(),now(),'ogg','mp3',40), (5,'MP3 to Spectrum.MP4','ffmpeg -i {$pathFileName} -filter_complex \'[0:a]showwaves=s=1280x720:mode=line,format=yuv420p[v]\' -map \'[v]\' -map 0:a -c:v libx264 -c:a copy {$destinationFile}',now(),now(),'mp4','mp3',50), (6,'Video.MP4 to Audio.MP3','ffmpeg -i {$pathFileName} -y {$destinationFile}',now(),now(),'mp3','mp4',60), -(7,'MP4 SD','ffmpeg -i {$pathFileName} -vf scale=-2:540 -movflags +faststart -preset veryfast -vcodec h264 -acodec aac -max_muxing_queue_size 1024 -y {$destinationFile}',now(),now(),'mp4','mp4',11), -(8,'MP4 HD','ffmpeg -i {$pathFileName} -vf scale=-2:720 -movflags +faststart -preset veryfast -vcodec h264 -acodec aac -max_muxing_queue_size 1024 -y {$destinationFile}',now(),now(),'mp4','mp4',12), -(9,'WEBM SD','ffmpeg -i {$pathFileName} -vf scale=-2:540 -movflags +faststart -preset veryfast -f webm -c:v libvpx -b:v 1M -acodec libvorbis -y {$destinationFile}',now(),now(),'webm','mp4',21), -(10,'WEBM HD','ffmpeg -i {$pathFileName} -vf scale=-2:720 -movflags +faststart -preset veryfast -f webm -c:v libvpx -b:v 1M -acodec libvorbis -y {$destinationFile}',now(),now(),'webm','mp4',22), +(7,'MP4 SD','ffmpeg -i {$pathFileName} -vf scale=-2:540 -movflags +faststart -preset veryfast -vcodec h264 -b:v 1200k -acodec aac -b:a 128k -max_muxing_queue_size 1024 -y {$destinationFile}',now(),now(),'mp4','mp4',11), +(8,'MP4 HD','ffmpeg -i {$pathFileName} -vf scale=-2:720 -movflags +faststart -preset veryfast -vcodec h264 -b:v 2500k -acodec aac -b:a 128k -max_muxing_queue_size 1024 -y {$destinationFile}',now(),now(),'mp4','mp4',12), +(9,'WEBM SD','ffmpeg -i {$pathFileName} -vf scale=-2:540 -movflags +faststart -preset veryfast -f webm -c:v libvpx -b:v 1200k -acodec libvorbis -b:a 128k -y {$destinationFile}',now(),now(),'webm','mp4',21), +(10,'WEBM HD','ffmpeg -i {$pathFileName} -vf scale=-2:720 -movflags +faststart -preset veryfast -f webm -c:v libvpx -b:v 2500k -acodec libvorbis -b:a 128k -y {$destinationFile}',now(),now(),'webm','mp4',22), (11,'Video to Spectrum','60-50-10',now(),now(),'mp4','mp4',70), (12,'Video to Audio','60-40',now(),now(),'mp3','mp4',71), (13,'Both Video','10-20',now(),now(),'mp4','mp4',72), @@ -146,12 +146,12 @@ INSERT INTO `formats` VALUES (26,'Both SD HD','11-12-21-22',now(),now(),'mp4','mp4',85), (27,'Both Low HD','10-12-20-22',now(),now(),'mp4','mp4',86), (28,'Both Low SD HD','10-11-12-20-21-22',now(),now(),'mp4','mp4',87), -(29,'Multi Bitrate HLS VOD encrypted','ffmpeg -re -i {$pathFileName} -c:a aac -b:a 128k -c:v libx264 -vf scale=-2:360 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 800k -maxrate 856k -bufsize 1200k -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}low/index.m3u8 -c:a aac -b:a 128k -c:v libx264 -vf scale=-2:540 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 1400k -maxrate 1498k -bufsize 2100k -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}sd/index.m3u8 -c:a aac -b:a 128k -c:v libx264 -vf scale=-2:720 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 2800k -maxrate 2996k -bufsize 4200k -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}hd/index.m3u8',now(),now(),'mp4','m3u8',9); +(29,'Multi Bitrate HLS VOD encrypted','ffmpeg -re -i {$pathFileName} -c:a aac -b:a 128k -c:v libx264 -vf scale=-2:360 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 800k -maxrate 856k -bufsize 1200k -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}low/index.m3u8 -c:a aac -b:a 128k -c:v libx264 -vf scale=-2:540 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 1400k -maxrate 1498k -bufsize 2100k -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}sd/index.m3u8 -c:a aac -b:a 128k -c:v libx264 -vf scale=-2:720 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 2800k -maxrate 2996k -bufsize 4200k -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}hd/index.m3u8',now(),now(),'mp4','m3u8',9); -- ffmpeg -re -i {$pathFileName} -c:a aac -b:a 128k -c:v libx264 -vf scale=-2:540 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 1400k -maxrate 1498k -bufsize 2100k -b:a 128k -f hls -hls_time 15 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}low/index.m3u8 -c:a aac -b:a 128k -c:v libx264 -vf scale=-2:720 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 2800k -maxrate 2996k -bufsize 4200k -b:a 128k -f hls -hls_time 15 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}sd/index.m3u8 -c:a aac -b:a 128k -c:v libx264 -vf scale=-2:1080 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 5000k -maxrate 5350k -bufsize 7500k -b:a 192k -f hls -hls_time 15 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}hd/index.m3u8 INSERT INTO `formats` VALUES (30,'Dynamic HLS','-c:v h264 -vf scale=-2:{$resolution} -r 24 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -minrate {$minrate}k -crf 23 -maxrate {$maxrate}k -bufsize {$bufsize}k -c:a aac -b:a {$autioBitrate}k -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}res{$resolution}/index.m3u8',now(),now(),'m3u8','mp4',6); -INSERT INTO `formats` VALUES (31,'Dynamic MP4','-vf scale=-2:{$resolution} -movflags +faststart -preset veryfast -vcodec h264 -acodec aac -b:a {$autioBitrate}k -max_muxing_queue_size 1024 -y {$destinationFile}',now(),now(),'mp4','mp4',7); -INSERT INTO `formats` VALUES (32,'Dynamic WEBM','-vf scale=-2:{$resolution} -movflags +faststart -preset veryfast -f webm -c:v libvpx -b:v 1M -acodec libvorbis -b:a {$autioBitrate}k -y {$destinationFile}',now(),now(),'webm','mp4',8); +INSERT INTO `formats` VALUES (31,'Dynamic MP4','-vf scale=-2:{$resolution} -movflags +faststart -preset veryfast -vcodec h264 -b:v {$bitrate}k -acodec aac -b:a {$autioBitrate}k -max_muxing_queue_size 1024 -y {$destinationFile}',now(),now(),'mp4','mp4',7); +INSERT INTO `formats` VALUES (32,'Dynamic WEBM','-vf scale=-2:{$resolution} -movflags +faststart -preset veryfast -f webm -c:v libvpx -b:v 1M -acodec libvorbis -b:a {$autioBitrate}k -y {$destinationFile}',now(),now(),'webm','mp4',8); INSERT INTO `formats` VALUES (33,'Audio to HLS','',now(),now(),'m3u8','mp3',88); INSERT INTO `formats` VALUES (34,'Audio to MP4','',now(),now(),'mp4','mp3',89); INSERT INTO `formats` VALUES (35,'Audio to WEBM','',now(),now(),'webm','mp3',90); diff --git a/objects/Format.php b/objects/Format.php index 1ca1c131..cf2740eb 100644 --- a/objects/Format.php +++ b/objects/Format.php @@ -18,6 +18,14 @@ class Format extends ObjectYPT { protected $extension; protected $extension_from; protected $order; + const BITRATES = array( + '240'=>700, + '360'=>1000, + '480'=>1500, + '720'=>2500, + '1080'=>5000, + '2160'=>20000, + ); public static function getSearchFieldsNames() { return array('name'); @@ -588,6 +596,11 @@ private static function getDynamicCommandFromFormat($pathFileName, $encoder_queu _error_log("Encoder:Format:: getDynamicCommandFromFormat destination file is empty"); continue; } + if(!empty(Format::BITRATES[$resolution])){ + $bitrate = Format::BITRATES[$resolution]; + }else{ + $bitrate = 1500; + } $autioBitrate = $audioBitrate[$i]; $framerate = (!empty($videoFramerate[$i])) ? " -r {$videoFramerate[$i]} " : ""; @@ -687,6 +700,12 @@ private static function preProcessDynamicHLS($pathFileName, $destinationFile) { } $resolution = $value; + + if(!empty(Format::BITRATES[$resolution])){ + $bitrate = Format::BITRATES[$resolution]; + }else{ + $bitrate = 1500; + } if (!empty($videoFramerate[$key])) { $framerate = " -r {$videoFramerate[$key]} "; } @@ -698,6 +717,12 @@ private static function preProcessDynamicHLS($pathFileName, $destinationFile) { } $resolution = $height; + + if(!empty(Format::BITRATES[$resolution])){ + $bitrate = Format::BITRATES[$resolution]; + }else{ + $bitrate = 1500; + } //$code = ' -c:v h264 -c:a aac -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}res{$resolution}/index.m3u8'; eval("\$command .= \" $code\";"); diff --git a/update/updateDb.v5.1.sql b/update/updateDb.v5.1.sql new file mode 100644 index 00000000..ac32e5d1 --- /dev/null +++ b/update/updateDb.v5.1.sql @@ -0,0 +1,23 @@ +-- Update existing formats or insert if they don't exist +INSERT INTO `formats` (`id`, `name`, `code`, `created`, `modified`, `extension`, `extension_from`, `order`) +VALUES +(1,'MP4 Low','ffmpeg -i {$pathFileName} -vf scale=-2:360 -movflags +faststart -preset veryfast -vcodec h264 -b:v 700k -acodec aac -b:a 96k -max_muxing_queue_size 1024 -y {$destinationFile}',now(),now(),'mp4','mp4',10), +(2,'WEBM Low','ffmpeg -i {$pathFileName} -vf scale=-2:360 -movflags +faststart -preset veryfast -f webm -c:v libvpx -b:v 700k -acodec libvorbis -b:a 96k -y {$destinationFile}',now(),now(),'webm','mp4',20), +(7,'MP4 SD','ffmpeg -i {$pathFileName} -vf scale=-2:540 -movflags +faststart -preset veryfast -vcodec h264 -b:v 1200k -acodec aac -b:a 128k -max_muxing_queue_size 1024 -y {$destinationFile}',now(),now(),'mp4','mp4',11), +(8,'MP4 HD','ffmpeg -i {$pathFileName} -vf scale=-2:720 -movflags +faststart -preset veryfast -vcodec h264 -b:v 2500k -acodec aac -b:a 128k -max_muxing_queue_size 1024 -y {$destinationFile}',now(),now(),'mp4','mp4',12), +(9,'WEBM SD','ffmpeg -i {$pathFileName} -vf scale=-2:540 -movflags +faststart -preset veryfast -f webm -c:v libvpx -b:v 1200k -acodec libvorbis -b:a 128k -y {$destinationFile}',now(),now(),'webm','mp4',21), +(10,'WEBM HD','ffmpeg -i {$pathFileName} -vf scale=-2:720 -movflags +faststart -preset veryfast -f webm -c:v libvpx -b:v 2500k -acodec libvorbis -b:a 128k -y {$destinationFile}',now(),now(),'webm','mp4',22), +(29,'Multi Bitrate HLS VOD encrypted','ffmpeg -re -i {$pathFileName} -c:a aac -b:a 128k -c:v libx264 -vf scale=-2:360 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 800k -maxrate 856k -bufsize 1200k -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}low/index.m3u8 -c:a aac -b:a 128k -c:v libx264 -vf scale=-2:540 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 1400k -maxrate 1498k -bufsize 2100k -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}sd/index.m3u8 -c:a aac -b:a 128k -c:v libx264 -vf scale=-2:720 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 2800k -maxrate 2996k -bufsize 4200k -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}hd/index.m3u8',now(),now(),'mp4','m3u8',9), +(30,'Dynamic HLS','-c:v h264 -vf scale=-2:{$resolution} -r 24 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -minrate {$minrate}k -crf 23 -maxrate {$maxrate}k -bufsize {$bufsize}k -c:a aac -b:a {$autioBitrate}k -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}res{$resolution}/index.m3u8',now(),now(),'m3u8','mp4',6), +(31,'Dynamic MP4','-vf scale=-2:{$resolution} -movflags +faststart -preset veryfast -vcodec h264 -b:v {$bitrate}k -acodec aac -b:a {$autioBitrate}k -max_muxing_queue_size 1024 -y {$destinationFile}',now(),now(),'mp4','mp4',7), +(32,'Dynamic WEBM','-vf scale=-2:{$resolution} -movflags +faststart -preset veryfast -f webm -c:v libvpx -b:v 1M -acodec libvorbis -b:a {$autioBitrate}k -y {$destinationFile}',now(),now(),'webm','mp4',8) +ON DUPLICATE KEY UPDATE + `name` = VALUES(`name`), + `code` = VALUES(`code`), + `created` = VALUES(`created`), + `modified` = VALUES(`modified`), + `extension` = VALUES(`extension`), + `extension_from` = VALUES(`extension_from`), + `order` = VALUES(`order`); +; +UPDATE configurations_encoder SET version = '5.1', modified = now() WHERE id = 1; \ No newline at end of file