Search code examples
http-live-streamingrtmpm3u8

nginx rtmp to hls streaming


My scenario is to pull data from a RTSP source via ffmpeg, send it to nginx-rtmp, and use nginx to provide hls playback. There are quite a lot of tutorials and q&a's on the internet. I followed this one:

https://docs.peer5.com/guides/setting-up-hls-live-streaming-server-using-nginx/

However, it miserably failed. To make things simpler to understand, I would like to ask the core question:

Who is responsible to create the m3u8 playlist file?

I tried to experiment in two steps: first, try to push a local mp4 file and play it back via HLS:

Following the above tutorial, I try to use ffmpeg to push a local mp4 file to nginx-rtmp, and use videojs to play it. The browser reported error:

VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) No compatible source was found for this media. 

Secondly, I have successfully saved the video file pushed to nginx-rtmp as a series of FLV file, and I know that I can use exec_push to call ffmpeg to convert flv to a format that is compatible with HLS. Again, here the core question is, howto create and UPDATE the m3u8 file as new video data is coming in endlessly.

For now, I would like experts to help me tackle the first question -- playback static mp4 file through HLS. Any tutorials on m3u8 playlist and mpeg-ts files are also much appreciated!


Solution

  • The nginx-rtmp module by itself creates and updates the playlist as new segments arrive.

    To troubleshoot check if the .m3u8 files are created under the folder specified in hls_path of your nginx conf. Rest is just nginx serving a file using http. If that works try the HLS url directly in safari (safari got inbuilt HLS player) or in Chrome (Play HLS M3u8) extension enabled. If that works the problem must be with your player.html