This commit is contained in:
root 2025-10-28 12:07:24 +00:00
parent b17ed95160
commit cf2b2fdceb
10 changed files with 62 additions and 169 deletions

View File

@ -1,19 +0,0 @@
{
"input": "hdmi",
"hdmi": {
"resolution": "1920x1080",
"audio_source": "hw:1,0"
},
"url": "https://cdn.urmic.org/unavailable.mp4",
"rtmp": {
"mount": "mahadev",
"password": "live",
"port": "1935"
},
"srt": {
"stream_id_1": "har",
"stream_id_2": "har",
"stream_id_3": "Mahadev",
"port": "1937"
}
}

View File

@ -8,7 +8,8 @@ $defaults = [
'input' => 'url', 'input' => 'url',
'hdmi' => [ 'hdmi' => [
'resolution' => '1920x1080', 'resolution' => '1920x1080',
'audio_source' => 'hw:1,0' 'audio_source' => 'hw:1,0',
'framerate' => '30'
], ],
'url' => 'https://cdn.urmic.org/unavailable.mp4', 'url' => 'https://cdn.urmic.org/unavailable.mp4',
'rtmp' => [ 'rtmp' => [
@ -43,7 +44,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
'input' => $posted('input', $defaults['input']), 'input' => $posted('input', $defaults['input']),
'hdmi' => [ 'hdmi' => [
'resolution' => $posted('hdmi_resolution', $defaults['hdmi']['resolution']), 'resolution' => $posted('hdmi_resolution', $defaults['hdmi']['resolution']),
'audio_source' => $posted('hdmi_audio_source', $defaults['hdmi']['audio_source']) 'audio_source' => $posted('hdmi_audio_source', $defaults['hdmi']['audio_source']),
'framerate' => $posted('hdmi_framerate', $defaults['hdmi']['framerate'])
], ],
'url' => $posted('url', $defaults['url']), 'url' => $posted('url', $defaults['url']),
'rtmp' => [ 'rtmp' => [
@ -123,6 +125,20 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
</select> </select>
</div> </div>
</div> </div>
<div class="dropdown-container">
<span class="dropdown-label">Framerate :</span>
<div class="dropdown">
<select name="hdmi_framerate">
<?php
$aopts = ['10','20', '30', '50','60'];
foreach ($aopts as $a) {
$sel = ($data['hdmi']['framerate'] === $a) ? 'selected' : '';
echo "<option value=\"" . htmlspecialchars($a) . "\" $sel>$a</option>";
}
?>
</select>
</div>
</div>
</div> </div>
<div class="card wide"> <div class="card wide">

View File

@ -1 +1 @@
ffmpeg -f v4l2 -input_format mjpeg -framerate 30 -video_size 1920x1080 -i /dev/video0 -f alsa -i hw:1,0 -vf "scale=1920x1080" -c:v h264 -b:v 3.3M -minrate 3.3M -maxrate 3.3M -bufsize 3.3M -g 12 -c:a aac -ar 48000 -b:a 96k -f flv rtmp://127.0.0.1:1935/shree/bhattji ffmpeg -stream_loop -1 -re -i https://cdn.urmic.org/unavailable.mp4 -vf "scale=1920x1080" -c:v mpeg2video -b:v 3.3M -minrate 3.3M -maxrate 3.3M -bufsize 3.3M -g 12 -c:a aac -ar 48000 -b:a 96k -f flv rtmp://127.0.0.1:1935/shree/bhattji

File diff suppressed because one or more lines are too long

View File

@ -22,9 +22,6 @@ rtmp {
wait_video on; wait_video on;
push rtmp://192.168.2.45/live/live1; push rtmp://192.168.2.45/live/live1;
push rtmp://192.168.2.45/live/live2;
push rtmp://192.168.2.45/live/live3;
push rtmp://192.168.2.45/live/live4;
} }
} }
} }

View File

@ -1,135 +0,0 @@
{
"output": "rtmp_multiple",
"video": {
"resolution": "1920x1080",
"format": "h264",
"data_rate": "3.3M",
"gop": "12"
},
"audio": {
"format": "aac",
"sample_rate": "48000",
"bit_rate": "96k"
},
"output_display": "1920x1080@60.00",
"output_display_audio": "0,3",
"rtmp_single": "",
"srt_single": "",
"rtmp_multiple": {
"1": {
"url": "rtmp://192.168.2.45/live/live1",
"name": "facebook",
"enabled": true
},
"2": {
"url": "rtmp://192.168.2.45/live/live2",
"name": "youtube.com",
"enabled": true
},
"3": {
"url": "rtmp://192.168.2.45/live/live3",
"name": "urmic",
"enabled": true
},
"4": {
"url": "rtmp://192.168.2.45/live/live4",
"name": "test4",
"enabled": true
},
"5": {
"url": "",
"name": "",
"enabled": false
},
"6": {
"url": "",
"name": "",
"enabled": false
},
"7": {
"url": "",
"name": "",
"enabled": false
},
"8": {
"url": "",
"name": "",
"enabled": false
},
"9": {
"url": "",
"name": "",
"enabled": false
},
"10": {
"url": "",
"name": "",
"enabled": false
},
"11": {
"url": "",
"name": "",
"enabled": false
}
},
"srt_multiple": {
"1": {
"url": "",
"name": "",
"enabled": false
},
"2": {
"url": "",
"name": "",
"enabled": false
},
"3": {
"url": "",
"name": "",
"enabled": false
},
"4": {
"url": "",
"name": "",
"enabled": false
},
"5": {
"url": "",
"name": "",
"enabled": false
},
"6": {
"url": "",
"name": "",
"enabled": false
},
"7": {
"url": "",
"name": "",
"enabled": false
},
"8": {
"url": "",
"name": "",
"enabled": false
},
"9": {
"url": "",
"name": "",
"enabled": false
},
"10": {
"url": "",
"name": "",
"enabled": false
},
"11": {
"url": "",
"name": "",
"enabled": false
}
},
"udp_primary": "",
"udp_vlan": "",
"custom_output": ""
}

View File

@ -7,7 +7,8 @@ $defaults = [
'output' => 'display', 'output' => 'display',
'video' => [ 'video' => [
'resolution' => '1920x1080', 'resolution' => '1920x1080',
'format' => 'h264', 'format' => 'h264_qsv',
'framerate' => '25',
'data_rate' => '3.3M', 'data_rate' => '3.3M',
'gop' => '12' 'gop' => '12'
], ],
@ -57,6 +58,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$new['video']['resolution'] = $get('output_resolution', $defaults['video']['resolution']); $new['video']['resolution'] = $get('output_resolution', $defaults['video']['resolution']);
$new['video']['format'] = $get('output_video_formate', $defaults['video']['format']); $new['video']['format'] = $get('output_video_formate', $defaults['video']['format']);
$new['video']['framerate'] = $get('output_video_framerate', $defaults['video']['framerate']);
$new['video']['data_rate'] = $get('output_data_rate', $defaults['video']['data_rate']); $new['video']['data_rate'] = $get('output_data_rate', $defaults['video']['data_rate']);
$new['video']['gop'] = $get('output_gop', $defaults['video']['gop']); $new['video']['gop'] = $get('output_gop', $defaults['video']['gop']);
@ -147,13 +149,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<span class="dropdown-label">Output Video Formate :</span> <span class="dropdown-label">Output Video Formate :</span>
<div class="dropdown"> <div class="dropdown">
<select name="output_video_formate" id="output_video_formate"> <select name="output_video_formate" id="output_video_formate">
<option value="mpeg2" <?php if ($data['video']['format'] == 'mpeg2') echo 'selected'; ?>>mpeg2</option> <option value="mpeg2video" <?php if ($data['video']['format'] == 'mpeg2video') echo 'selected'; ?>>mpeg2</option>
<option value="mpeg4" <?php if ($data['video']['format'] == 'mpeg4') echo 'selected'; ?>>mpeg4</option> <option value="mpeg4" <?php if ($data['video']['format'] == 'mpeg4') echo 'selected'; ?>>mpeg4</option>
<option value="h264_qsv" <?php if ($data['video']['format'] == 'h264_qsv') echo 'selected'; ?>>h264</option> <option value="h264_qsv" <?php if ($data['video']['format'] == 'h264_qsv') echo 'selected'; ?>>h264</option>
<option value="h265" <?php if ($data['video']['format'] == 'h265') echo 'selected'; ?>>h265</option> <option value="h265" <?php if ($data['video']['format'] == 'h265') echo 'selected'; ?>>h265</option>
</select> </select>
</div> </div>
</div> </div>
<div class="input-group">
<input type="text" id="output_video_framerate" name="output_video_framerate" placeholder="25" value="<?php echo htmlspecialchars($data['video']['framerate']); ?>">
<label for="output_video_framerate">Framerate :</label>
</div>
<div class="input-group"> <div class="input-group">
<input type="text" id="output_data_rate" name="output_data_rate" placeholder="4M" value="<?php echo htmlspecialchars($data['video']['data_rate']); ?>"> <input type="text" id="output_data_rate" name="output_data_rate" placeholder="4M" value="<?php echo htmlspecialchars($data['video']['data_rate']); ?>">
<label for="output_data_rate">OutPut Data Rate :</label> <label for="output_data_rate">OutPut Data Rate :</label>

View File

@ -75,6 +75,8 @@ srt {
function update_service() function update_service()
{ {
shell_exec("sudo /bin/systemctl stop main-encoder");
$candidate = '/var/www/html/nginx.conf'; $candidate = '/var/www/html/nginx.conf';
$fallback = '/var/www/html/default_nginx.conf'; $fallback = '/var/www/html/default_nginx.conf';
$target = '/etc/nginx/nginx.conf'; $target = '/etc/nginx/nginx.conf';
@ -86,7 +88,6 @@ function update_service()
$test_cmd = 'sudo /usr/sbin/nginx -t -q'; $test_cmd = 'sudo /usr/sbin/nginx -t -q';
$restart_cmd = 'sudo /bin/systemctl reload nginx'; $restart_cmd = 'sudo /bin/systemctl reload nginx';
shell_exec("sudo systemctl stop main-encoder");
$input = "ffmpeg "; $input = "ffmpeg ";
$input_link = ""; $input_link = "";
@ -104,7 +105,8 @@ function update_service()
'input' => 'url', 'input' => 'url',
'hdmi' => [ 'hdmi' => [
'resolution' => '1920x1080', 'resolution' => '1920x1080',
'audio_source' => 'hw:1,0' 'audio_source' => 'hw:1,0',
'framerate' => '30'
], ],
'url' => 'https://cdn.urmic.org/unavailable.mp4', 'url' => 'https://cdn.urmic.org/unavailable.mp4',
'rtmp' => [ 'rtmp' => [
@ -140,7 +142,7 @@ function update_service()
switch ($input_source) { switch ($input_source) {
case "hdmi": case "hdmi":
$input .= "-f v4l2 -input_format mjpeg -framerate 30 -video_size " . $data['hdmi']['resolution'] . " -i /dev/video0 -f alsa -i " . $data['hdmi']['audio_source']; $input .= "-f v4l2 -input_format mjpeg -framerate " . $data['hdmi']['framerate'] . " -video_size " . $data['hdmi']['resolution'] . " -i /dev/video0 -f alsa -i " . $data['hdmi']['audio_source'];
break; break;
case "url": case "url":
$input .= "-stream_loop -1 -re -i " . $data['url']; $input .= "-stream_loop -1 -re -i " . $data['url'];
@ -335,8 +337,8 @@ rtmp {
exec($restart_cmd, $out, $rc2); exec($restart_cmd, $out, $rc2);
} }
sleep(5); sleep(10);
shell_exec("sudo systemctl restart main-encoder"); shell_exec("sudo /bin/systemctl restart main-encoder");
} }

BIN
html/www.zip Normal file

Binary file not shown.

View File

@ -1,6 +1,6 @@
sudo mkdir /etc/srt; sudo mkdir /etc/srt;
sudo apt update sudo apt update
sudo apt install -y vainfo intel-media-va-driver-non-free i965-va-driver-shaders ffmpeg nginx v4l-utils python3-pip php-fpm mpv libnginx-mod-rtmp alsa-utils vlan git zlib1g-dev sudo apt install -y vainfo intel-media-va-driver-non-free i965-va-driver-shaders ffmpeg nginx v4l-utils python3-pip php-fpm8.3 mpv libnginx-mod-rtmp alsa-utils vlan git zlib1g-dev
sudo pip3 install psutil --break-system-packages sudo pip3 install psutil --break-system-packages
dpkg -i srt-1.5.5-Linux.deb dpkg -i srt-1.5.5-Linux.deb
@ -177,6 +177,30 @@ cat > /etc/srt/srt.sh<<EOL
/etc/srt/srt -c /var/www/html/sls.conf /etc/srt/srt -c /var/www/html/sls.conf
EOL EOL
cat > /etc/nginx/sites-available/default<<EOL
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /var/www/html;
index index.php index.html;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
location ~ /\. { deny all; }
}
EOL
rm /var/www/html/index.nginx-debian.html;
cp -r html/* /var/www/html/
sudo chmod +x /usr/local/bin/nginx_system_monitor_sampler.py sudo chmod +x /usr/local/bin/nginx_system_monitor_sampler.py
sudo systemctl daemon-reload sudo systemctl daemon-reload
sudo systemctl enable --now system-monitor.service sudo systemctl enable --now system-monitor.service
@ -187,3 +211,5 @@ sudo systemctl enable --now srt.service
sudo systemctl status srt.service --no-pager sudo systemctl status srt.service --no-pager
sudo systemctl enable --now nginx.service sudo systemctl enable --now nginx.service
sudo systemctl status nginx.service --no-pager sudo systemctl status nginx.service --no-pager
sudo chmod -R 777 /var/www/html/*
sudo chown -R www-data:www-data /var/www/html/*