diff --git a/html/input.php b/html/input.php index 628f64e..bf09d5c 100644 --- a/html/input.php +++ b/html/input.php @@ -164,7 +164,7 @@ function all_service_update() . ' -c:a ' . $new["audio_format"] . ' -b:a ' . $new["audio_bitrate"] . 'k -ar 48000 -ac 2 -af "volume=' . $new["volume"] . 'dB" ' . ' -metadata service_provider="ShreeBhattJI" '; if ($new["program_id"] !== "") { - $ffmpeg .= '-map i:p:' . $new["program_id"] . '" '; + $ffmpeg .= '-map i:p:' . $new["program_id"]; } if ($new["service_name"] !== "") { $ffmpeg .= ' -metadata service_name="' . $new["service_name"] . '" '; @@ -217,7 +217,7 @@ function all_service_start() . ' -c:a ' . $new["audio_format"] . ' -b:a ' . $new["audio_bitrate"] . 'k -ar 48000 -ac 2 -af "volume=' . $new["volume"] . 'dB" ' . ' -metadata service_provider="ShreeBhattJI" '; if ($new["program_id"] !== "") { - $ffmpeg .= '-map i:p:' . $new["program_id"] . '" '; + $ffmpeg .= '-map i:p:' . $new["program_id"]; } if ($new["service_name"] !== "") { $ffmpeg .= ' -metadata service_name="' . $new["service_name"] . '" '; @@ -311,7 +311,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") { . ' -c:a ' . $new["audio_format"] . ' -b:a ' . $new["audio_bitrate"] . 'k -ar 48000 -ac 2 -af "volume=' . $new["volume"] . 'dB" ' . ' -metadata service_provider="ShreeBhattJI" '; if ($new["program_id"] !== "") { - $ffmpeg .= '-map i:p:' . $new["program_id"] . '" '; + $ffmpeg .= '-map i:p:' . $new["program_id"]; } if ($new["service_name"] !== "") { $ffmpeg .= ' -metadata service_name="' . $new["service_name"] . '" '; @@ -355,8 +355,8 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") { foreach ($data as $row) { if ($row["id"] == $id) { - $new = [ - "id" => time(), + $row = [ + "id" => $id, "service_name" => $_POST["service_name"], "input_udp" => $_POST["input_udp"], "output_udp" => $_POST["output_udp"], @@ -367,8 +367,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") { "service" => $_POST["service"] ]; - $new = $row; - $alloc = allocateCore($new["id"]); + $alloc = allocateCore($row["id"]); $core = (int)$alloc["cpu"]; $node = (int)$alloc["node"]; @@ -376,21 +375,23 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") { . ' --preferred=' . $node . ' taskset -c ' . $core . ' ffmpeg -hide_banner -loglevel info -thread_queue_size 512 -fflags +genpts+discardcorrupt+nobuffer -readrate 1.0' - . ' -i "udp://' . $new["input_udp"] . '?fifo_size=50000&buffer_size=50000&overrun_nonfatal=1"' - . ' -c:v copy ' - . ' -c:a ' . $new["audio_format"] . ' -b:a ' . $new["audio_bitrate"] . 'k -ar 48000 -ac 2 -af "volume=' . $new["volume"] . 'dB" ' + . ' -i "udp://' . $row["input_udp"] . '?fifo_size=50000&buffer_size=50000&overrun_nonfatal=1"' + . ' -c:v copy' + . ' -c:a ' . $row["audio_format"] . ' -b:a ' . $row["audio_bitrate"] . 'k -ar 48000 -ac 2 -af "volume=' . $row["volume"] . 'dB"' . ' -metadata service_provider="ShreeBhattJI" '; - if ($new["program_id"] !== "") { - $ffmpeg .= '-map i:p:' . $new["program_id"] . '" '; + + if ($row["program_id"] !== "") { + $ffmpeg .= '-map i:p:' . $row["program_id"] . ' '; } - if ($new["service_name"] !== "") { - $ffmpeg .= ' -metadata service_name="' . $new["service_name"] . '" '; + if ($row["service_name"] !== "") { + $ffmpeg .= '-metadata service_name="' . $row["service_name"] . '" '; } - $ffmpeg .= ' -f mpegts "udp://' . $new["output_udp"] . '?pkt_size=1316&flush_packets=1"'; + + $ffmpeg .= '-f mpegts "udp://' . $row["output_udp"] . '?pkt_size=1316&flush_packets=1"'; file_put_contents("/var/www/encoder/$id.sh", $ffmpeg); - if ($new["service"] === "enable") { + if ($row["service"] === "enable") { exec("sudo systemctl enable encoder@$id"); exec("sudo systemctl restart encoder@$id"); } else { diff --git a/install.sh b/install.sh index ea1a1c8..6e4692f 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,5 @@ sudo apt update -sudo apt install -y apache2 php libapache2-mod-php vainfo ufw intel-media-va-driver-non-free libavcodec-extra mesa-utils i965-va-driver libmfx1 intel-gpu-tools ffmpeg v4l-utils python3-pip mpv alsa-utils vlan git zlib1g-dev php-zip php-curl +sudo apt install -y apache2 php libapache2-mod-php vainfo ufw intel-media-va-driver-non-free libavcodec-extra mesa-utils i965-va-driver libmfx1 intel-gpu-tools ffmpeg v4l-utils python3-pip mpv alsa-utils vlan git zlib1g-dev php-zip php-curl numactl sudo pip3 install psutil --break-system-packages cat > /etc/sudoers.d/www-data << 'EOL'