【问题标题】:How do i change the name on nginx hls file?如何更改 nginx hls 文件的名称?
【发布时间】:2019-01-04 02:12:05
【问题描述】:

我已经使用本教程成功地为 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;
}   
}
}

我将不胜感激。

问候丹尼尔。

【问题讨论】:

    标签: ubuntu nginx http-live-streaming


    【解决方案1】:

    作为一种简单的解决方法,您可以创建一个从 index.m3u8playlist.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;
    }
    

    【讨论】:

      猜你喜欢
      • 2013-04-04
      • 2017-05-29
      • 2018-04-03
      • 2020-06-08
      • 1970-01-01
      • 1970-01-01
      • 2016-02-03
      • 2020-06-01
      • 1970-01-01
      相关资源
      最近更新 更多