Skip to content

Commit

Permalink
https://github.com/WWBN/AVideo/issues/9353
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Aug 26, 2024
1 parent a537aea commit 0cb0780
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 10 deletions.
2 changes: 1 addition & 1 deletion install/checkConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
18 changes: 9 additions & 9 deletions install/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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);
25 changes: 25 additions & 0 deletions objects/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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]} " : "";

Expand Down Expand Up @@ -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]} ";
}
Expand All @@ -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\";");

Expand Down
23 changes: 23 additions & 0 deletions update/updateDb.v5.1.sql
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 0cb0780

Please sign in to comment.