nginx-rtmp-module
nginx-rtmp-module copied to clipboard
I can capture RTMP, but in certain cases when I go to hls, the chunks lose the video stream
I am capturing 4 channels by RTMP, but there are two channels that capture OK but when I see them for hls I see that the video stream is lost. The channels are America and A24, the rest works OK. In the case of A24 I made a script that generates a m3u8 using the original chunks, not those generated by the hls parameter. In this case those chunks work fine, but browsers can't play it. In the case of America, I left everything as the rest of the channels work, but like A24 the files of the hls seems not to have the full video stream. When I use ffmpeg I see the following:
original chunk (the one generated by rtmp): Stream # 0: 0 [0x100]: Video: h264 (High) ([27] [0] [0] [0] / 0x001B), yuv420p (progressive), 1280x720 [SAR 1: 1 DAR 16: 9], 25 fps, 25 tbr, 90k tbn, 50 tbc
Same chunk hls: Stream # 0: 0 [0x100]: Video: h264 ([27] [0] [0] [0] / 0x001B), none, 25 fps, 25 tbr, 90k tbn, 180k tbc
Attach error debug log : error-debug.log.gz
Attach chunks: amricatv_ovac-szgcrk-161332.ts.gz amricatv_ovac-szgcrk-1578329623_06012020_165343.ts.gz
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
error_log /var/log/nginx/error-debug.log debug;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
rtmp {
server {
listen 1935;
# chunk_size 4000;
ping 30s;
notify_method get;
application live {
live on;
drop_idle_publisher 10s;
recorder amricatv_ovac-szgcrk {
record all;
record_path /mnt/america;
record_unique on;
record_suffix _%d%m%Y_%H%M%S.flv;
record_interval 5s;
}
hls on;
hls_fragment 5;
hls_cleanup off;
hls_playlist_length 90;
hls_path /mnt/america;
}
application a24 {
live on;
drop_idle_publisher 10s;
recorder a24_live {
record all;
record_path /mnt/a24;
record_unique on;
record_suffix _%d%m%Y_%H%M%S.flv;
record_interval 5s;
exec_record_done /usr/local/bin/postproc.a24 $path;
}
hls on;
hls_fragment 5;
hls_cleanup off;
hls_playlist_length 90;
hls_path /mnt/a24/live;
}
application canal-4 {
live on;
drop_idle_publisher 10s;
recorder live {
record all;
record_path /mnt/canal4;
record_unique on;
record_suffix _%d%m%Y_%H%M%S.flv;
record_interval 5s;
}
hls on;
hls_cleanup off;
hls_fragment 5;
hls_playlist_length 90;
hls_path /mnt/canal4;
}
application cronica {
live on;
record off;
allow publish all;
allow play all;
hls on;
hls_path /mnt/cronica;
hls_fragment 10s;
hls_playlist_length 90;
record all;
pull rtmp://**************************************************video1-100044 name=cronica live=1 static;
}
}
}
HLS export:
cat /etc/nginx/sites-enabled/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /mnt;
index index.html index.htm index.nginx-debian.html;
server_name _;
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
allow all;
add_header Refresh "3; $request_uri";
}
location /stat.xsl {
allow all;
root /var/www/html;
}
location / {
autoindex on;
}
location /america {
# Disable cache
add_header 'Cache-Control' 'no-cache';
# CORS setup
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length';
# allow CORS preflight requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
types {
application/vnd.apple.mpegurl m3u8;
}
}
}
Original Chunk:
ffprobe -v quiet -print_format json -show_format -show_streams amricatv_ovac-szgcrk-1578329623_06012020_165343.ts
{
"streams": [
{
"index": 0,
"codec_name": "h264",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"profile": "High",
"codec_type": "video",
"codec_time_base": "1/50",
"codec_tag_string": "[27][0][0][0]",
"codec_tag": "0x001b",
"width": 1280,
"height": 720,
"coded_width": 1280,
"coded_height": 720,
"has_b_frames": 3,
"sample_aspect_ratio": "1:1",
"display_aspect_ratio": "16:9",
"pix_fmt": "yuv420p",
"level": 31,
"chroma_location": "topleft",
"field_order": "progressive",
"refs": 1,
"is_avc": "false",
"nal_length_size": "0",
"id": "0x100",
"r_frame_rate": "25/1",
"avg_frame_rate": "25/1",
"time_base": "1/90000",
"start_pts": 144000,
"start_time": "1.600000",
"duration_ts": 529200,
"duration": "5.880000",
"bits_per_raw_sample": "8",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
},
{
"index": 1,
"codec_name": "aac",
"codec_long_name": "AAC (Advanced Audio Coding)",
"profile": "LC",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[15][0][0][0]",
"codec_tag": "0x000f",
"sample_fmt": "fltp",
"sample_rate": "48000",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 0,
"id": "0x101",
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/90000",
"start_pts": 127440,
"start_time": "1.416000",
"duration_ts": 522240,
"duration": "5.802667",
"bit_rate": "128250",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "amricatv_ovac-szgcrk-1578329623_06012020_165343.ts",
"nb_streams": 2,
"nb_programs": 1,
"format_name": "mpegts",
"format_long_name": "MPEG-TS (MPEG-2 Transport Stream)",
"start_time": "1.416000",
"duration": "6.064000",
"size": "2896892",
"bit_rate": "3821757",
"probe_score": 50
}
}
HLS chunk:
ffprobe -v quiet -print_format json -show_format -show_streams amricatv_ovac-szgcrk-161332.ts
{
"streams": [
{
"index": 0,
"codec_name": "h264",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"codec_type": "video",
"codec_time_base": "1/50",
"codec_tag_string": "[27][0][0][0]",
"codec_tag": "0x001b",
"width": 0,
"height": 0,
"coded_width": 0,
"coded_height": 0,
"has_b_frames": 1,
"level": -99,
"chroma_location": "left",
"refs": 1,
"is_avc": "false",
"nal_length_size": "0",
"id": "0x100",
"r_frame_rate": "25/1",
"avg_frame_rate": "25/1",
"time_base": "1/90000",
"start_pts": 542503800,
"start_time": "6027.820000",
"duration_ts": 522000,
"duration": "5.800000",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
},
{
"index": 1,
"codec_name": "aac",
"codec_long_name": "AAC (Advanced Audio Coding)",
"profile": "LC",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[15][0][0][0]",
"codec_tag": "0x000f",
"sample_fmt": "fltp",
"sample_rate": "48000",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 0,
"id": "0x101",
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/90000",
"start_pts": 542492010,
"start_time": "6027.689000",
"duration_ts": 495360,
"duration": "5.504000",
"bit_rate": "130125",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "amricatv_ovac-szgcrk-161332.ts",
"nb_streams": 2,
"nb_programs": 1,
"format_name": "mpegts",
"format_long_name": "MPEG-TS (MPEG-2 Transport Stream)",
"start_time": "6027.689000",
"duration": "5.931000",
"size": "2768300",
"bit_rate": "3734007",
"probe_score": 50
}
}
I use the rtmp module from debian : ii libnginx-mod-rtmp 1.14.2-2+deb10u1 amd64 RTMP support for Nginx ii librtmp1:amd64 2.4+20151223.gitfa8646d.1-2 amd64 toolkit for RTMP streams (shared library)
and the encoder is the ATEME TITAN Live
Have you solved it so far?