Как мне изменить имя файла nginx hls? - PullRequest
0 голосов
/ 04 января 2019

Я успешно настроил свой файл конфигурации для Nginx, который работает почти идеально, используя этот учебник.

https://www.vultr.com/docs/setup-nginx-on-ubuntu-to-stream-live-hls-video

Единственная проблема заключается в том, что имя файла, которое он выводит,"index.m3u8", и я бы хотел, чтобы он был "playlist.m3u8".

мой URL в настоящее время выглядит так для доступа к потоку.https://myurl.com/live/test/index.m3u8 и я хотел бы получить https://myurl.com/live/test/playlist.m3u8

Вот мой конфигурационный файл:)

worker_processes  auto;
error_log  logs/error.log debug;

events {
	worker_connections  1024;
}

rtmp {
	server {
	listen 1935;
	allow play all;

#creates our "live" full-resolution HLS videostream from our incoming encoder stream and tells where to put the HLS video manifest and video fragments
	application live {
		allow play all;
		live on;
		record off;
		hls on;
		hls_nested on;
		hls_path /HLS/live;
		hls_fragment 10s;

	#creates the downsampled or "trans-rated" mobile video stream as a 400kbps, 480x360 sized video
		exec ffmpeg -i rtmp://localhost:1935/$app/$name -acodec copy -c:v libx264 -preset veryfast -profile:v baseline -vsync cfr -s 480x360 -b:v 400k maxrate 400k -bufsize 400k -threads 0 -r 30 -f flv rtmp://localhost:1935/mobile/$;
	}

#creates our "mobile" lower-resolution HLS videostream from the ffmpeg-created stream and tells where to put the HLS video manifest and video fragments
	application mobile {
		allow play all;
		live on;
		hls on;
		hls_nested on;
		hls_path /HLS/mobile;
		hls_fragment 10s;
	}

	# #allows you to play your recordings of your live streams using a URL like "rtmp://my-ip:1935/vod/filename.flv"
	# application vod {
	# play /video_recordings;
	# }
	}
}


http {
include       mime.types;
default_type  application/octet-stream;

server {
listen 80;
server_name localhost;

#creates the http-location for our full-resolution (desktop) HLS stream - "http://my-ip/live/my-stream-key/index.m3u8"      
location /live {
	types {
		application/vnd.apple.mpegurl m3u8;
	}
	alias /HLS/live;
	add_header Cache-Control no-cache;
}

#creates the http-location for our mobile-device HLS stream - "http://my-ip/mobile/my-stream-key/index.m3u8"        
location /mobile {
	types {
		application/vnd.apple.mpegurl m3u8;
	}
	alias /HLS/mobile;
	add_header Cache-Control no-cache;
}   

#allows us to see how stats on viewers on our Nginx site using a URL like: "http://my-ip/stats"     
location /stats {
	stub_status;
}
#allows us to host some webpages which can show our videos: "http://my-ip/my-page.html"     
location / {	
	root   html;
	index  index.html index.htm;
}   
}
}

Буду признателен за любую помощь, которую смогу получить.

С уважением, Даниил.

1 Ответ

0 голосов
/ 04 января 2019

В качестве простого обходного пути вы можете создать символическую ссылку от index.m3u8 до playlist.m3u8

exec ln -sf /HLS/$app/$name/index.m3u8 /HLS/$app/$name/playlist.m3u8;

Добавить ее в блок application live

application live {
        allow play all;
        live on;
        record off;
        hls on;
        hls_nested on;
        hls_path /HLS/live;
        hls_fragment 10s;

        #creates the downsampled or "trans-rated" mobile video stream as a 400kbps, 480x360 sized video
        exec ffmpeg -i rtmp://localhost:1935/$app/$name -acodec copy -c:v libx264 -preset veryfast -profile:v baseline -vsync cfr -s 480x360 -b:v 400k maxrate 400k -bufsize 400k -threads 0 -r 30 -f flv rtmp://localhost:1935/mobile/$;
        exec ln -sf /HLS/$app/$name/index.m3u8 /HLS/$app/$name/playlist.m3u8;
}
...