nginx-rtmp – HLS or DASH streaming


Checkout: | |

You may also like...

26 Responses

  1. Fidri says:

    How to stream with DASH then? Do i need special player?

  2. Daniel Miranda says:

    My HLS configuration is not working, rtpm streaming works fine, but when I try to call it from safari and my mac computer , it does not load anything…. can you help

  3. Augusto says:

    Hi to all! I had a problem in this section, as I was trying to use an open source video player that supports live streaming.
    I found Clappr that supports HLS in almost every web browser, but I couldn’t fetch the StreamKey.m3u8 as described above.

    I found that there is a issue with /tmp/hls folder that has not appropriate permissions.

    I used chmod on a linux machine, and give 755 permissions to the folder /tmp/hls recursively, and the URL must be , since the source is located in the folder /tmp/hls/StreamKey, and the m3u8 file is called index.m3u8

    I don’t know if it was due a compile problem, but I hope this comment helps you and saves you lots of trouble.


    Hi, thanks for your help …
    I have a question about it, this configuration will work with live streaming me, I tried putting this code in jwplayer, but in an android device did not load the video, I do not get any kind of error, just waiting for the signal … in windows if I work:

                     TEST LIVE STREAMING

                             Loading the player …
                                    jwplayer (“container”). setup ({
                                    autostart: false,
                                    playlist: [{
                                    Sources: [{
                                    file: “rtmp: //”
                                    }, {
                                    file: “”
                                    width: ‘480’
                                    height: ‘270’
                                    androidhls: ‘true’,
                                    primary: ‘flash’


  5. jim says:

    Can the ffmpeg command be put into the rtmp “application hls” section or must it be run from a shell script? I can successfully serve rtmp live video using exec_pull in an application, but I can’t get it to connect using the http method.

    • RobinJack0r says:

      Yup “exec ffmpeg …” can be used in any of the rtmp applications (under Linux) as far as I know.
      If you cant watch the stream over the http address, check if the hls playlist is created or if the error.log maybe has some more info.

  6. raka says:

    Hello I new guy to using nginx. How to I configure nginx ip? it is from here?

    server {
    listen 80;
    server_name localhost;

    #charset koi8-r;

    #access_log logs/host.access.log main;

    Because I want to change my localhost to my ip(192.x.x.x)? thanks

    • RobinJack0r says:

      You cannot change the IP with nginx. But it should use your “local” ip already.
      For example if it runs on PC (192.x.x.x) you should be able to reach it through that address on your network. Make sure you have no deny rules in your config though, so access is not blocked.

  7. hd says:

    When the ts fragments are being deleted?

    • RobinJack0r says:

      They should depend on the playlist and fragment length I think. Default is 30 seconds with 5 second fragments. It will probably keep one or two more fragments, I guess.

  8. minh says:

    Hi all,
    I use Iphone,VLC,android test but only display video and no sound. Please help? I test on vmware.
    ffmpeg -loglevel verbose -re -i bbb.avi -vcodec libx264 -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 -f flv rtmp://

    ffmpeg -loglevel verbose -re -i bbb.avi -vcodec libx264 -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 -f flv rtmp://
    ffmpeg version git-2014-11-20-4388e78 Copyright (c) 2000-2014 the FFmpeg developers
    built on Nov 20 2014 09:03:45 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11)
    configuration: –prefix=/root/ffmpeg_build –extra-cflags=-I/root/ffmpeg_build/include –extra-ldflags=-L/root/ffmpeg_build/lib –bindir=/root/bin –enable-gpl –enable-nonfree –enable-libfdk_aac –enable-libmp3lame –enable-libopus –enable-libvorbis –enable-libvpx –enable-libx264
    libavutil 54. 14.100 / 54. 14.100
    libavcodec 56. 12.101 / 56. 12.101
    libavformat 56. 14.100 / 56. 14.100
    libavdevice 56. 3.100 / 56. 3.100
    libavfilter 5. 2.103 / 5. 2.103
    libswscale 3. 1.101 / 3. 1.101
    libswresample 1. 1.100 / 1. 1.100
    libpostproc 53. 3.100 / 53. 3.100
    Input #0, avi, from ‘bbb.avi’:
    encoder : MEncoder SVN-r33883(20110719-gcc4.5.2)
    Duration: 00:32:05.25, start: 0.000000, bitrate: 996 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 640×272 [SAR 1:1 DAR 40:17], 856 kb/s, SAR 34816:34815 DAR 16384:6963, 24 fps, 24 tbr, 24 tbn, 24 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 128 kb/s
    [graph 0 input from stream 0:0 @ 0x2294400] w:640 h:272 pixfmt:yuv420p tb:1/24 fr:24/1 sar:34816/34815 sws_param:flags=2
    [graph 1 input from stream 0:1 @ 0x22b21e0] tb:1/44100 samplefmt:s16p samplerate:44100 chlayout:0x3
    [audio format for output stream 0:1 @ 0x22b2a40] auto-inserting filter ‘auto-inserted resampler 0’ between the filter ‘Parsed_anull_0’ and the filter ‘audio format for output stream 0:1’
    [auto-inserted resampler 0 @ 0x22b4040] ch:2 chl:stereo fmt:s16p r:44100Hz -> ch:1 chl:mono fmt:s16p r:44100Hz
    [libx264 @ 0x22a2f00] using SAR=1/1
    [libx264 @ 0x22a2f00] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
    [libx264 @ 0x22a2f00] profile Constrained Baseline, level 2.1
    [libx264 @ 0x22a2f00] 264 – core 142 r2 24e4fed – H.264/MPEG-4 AVC codec – Copyleft 2003-2014 – – options: cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    Output #0, flv, to ‘rtmp://’:
    encoder : Lavf56.14.100
    Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 640×272 [SAR 34816:34815 DAR 16384:6963], q=-1–1, 24 fps, 1k tbn, 24 tbc
    encoder : Lavc56.12.101 libx264
    Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 44100 Hz, mono, s16p
    encoder : Lavc56.12.101 libmp3lame
    Stream mapping:
    Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
    Stream #0:1 -> #0:1 (mp3 (native) -> mp3 (libmp3lame))
    Press [q] to stop, [?] for help
    [flv @ 0x22a1ea0] Failed to update header with correct duration.ate= 207.3kbits/s
    [flv @ 0x22a1ea0] Failed to update header with correct filesize.
    frame= 98 fps= 19 q=28.0 Lsize= 190kB time=00:00:04.84 bitrate= 321.6kbits/s
    video:147kB audio:38kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.807169%
    Input file #0 (bbb.avi):
    Input stream #0:0 (video): 99 packets read (313529 bytes); 99 frames decoded;
    Input stream #0:1 (audio): 184 packets read (76904 bytes); 184 frames decoded (211968 samples);
    Total: 283 packets (390433 bytes) demuxed
    Output file #0 (rtmp://
    Output stream #0:0 (video): 98 frames encoded; 98 packets muxed (150925 bytes);
    Output stream #0:1 (audio): 184 frames encoded (211968 samples); 185 packets muxed (38661 bytes);
    Total: 283 packets (189586 bytes) muxed
    [libx264 @ 0x22a2f00] frame I:4 Avg QP:18.97 size: 18110
    [libx264 @ 0x22a2f00] frame P:94 Avg QP:23.75 size: 828
    [libx264 @ 0x22a2f00] mb I I16..4: 24.9% 0.0% 75.1%
    [libx264 @ 0x22a2f00] mb P I16..4: 0.5% 0.0% 0.1% P16..4: 23.1% 6.5% 2.2% 0.0% 0.0% skip:67.4%
    [libx264 @ 0x22a2f00] coded y,uvDC,uvAC intra: 63.9% 78.9% 27.6% inter: 3.3% 9.6% 0.0%
    [libx264 @ 0x22a2f00] i16 v,h,dc,p: 43% 35% 10% 12%
    [libx264 @ 0x22a2f00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 25% 12% 6% 4% 6% 5% 6% 6%
    [libx264 @ 0x22a2f00] i8c dc,h,v,p: 37% 30% 24% 9%
    [libx264 @ 0x22a2f00] ref P L0: 76.8% 12.1% 11.1%
    [libx264 @ 0x22a2f00] kb/s:294.47

  9. Amity says:

    Sorry , I config nginx follow step you but My server don’t create file m3u8 in /tmp/hls and I Stream RTMP by Adobe flash media encoder Url : rtmp://my-IP/hls/Streamkey
    Please Help
    Thank you and sorry for my English

  10. Javiergs says:

    When I look into the directory /tmp/hls/ there is a m3u8 file but when enter the url http://[my_server_ip]/hls/%5Bmystreamkey%5D.m3u8 nothing load. What’s wrong on my server?

    thanks and sorry for my english.

  11. sinni800 says:

    You mentioned dash but in the end you completely ignored it’s existence… So how do you make dash work? I know I need different codecs (like for example webm should work with dash) but I could never get a ffmpeg commandline that converts that correctly to work.

    • RobinJack0r says:

      I did not know that you need different codecs for dash to work. From the nginx side it only mentioned the necessary configuration, and I knew you need a software/player for the playback part.
      Will have to investigate this further, thanks for letting me know.

  12. Shihan Ali khan says:

    how to create /tmp/hls and /tmp/dash folder. every time i reboot there is no folder

  13. Lanka says:

    hi, bro, i have a requirement that we will start a new stream at any time.
    but it seems hls config should specify the exactly the stream name, is this right?
    is there any solution i can find?

  14. Pedro says:

    Great tutorial.
    I still didn’t get how to stream to the m3u8 file.
    I want to send one RTMP stream to both RTMP and HLS.
    Will I need an extra software to transcode? How to create the m3u8 file?

    • RobinJack0r says:

      Oh, nginx should actually create the m3u8 file (as well as the part files) if HLS is active in the application.
      If I remember right (its been a while) both rtmp and hls can be supplied from one application. So if you send an rtmp stream to the app for example like this:
      the m3u8 address should be rtmp://server.ip/appname/streamkey.m3u8
      Check if you can watch the rtmp stream from your server with VLC and if that works test if you can load the m3u8 file.

  15. Dan says:

    I don’t know about the iPhone, but I can play high profile on my old Android (Nexus 4), and even high10 @ 720p.

    Please don’t use baseline, its a terrible codec setting and disables all the features of h264 that actually make it useful, in fact baseline is worse than XVid, since it turns off features XVid has.

    Maybe something is wrong with your encoder or other settings (too many bframes?) to play back properly, but setting baseline is the worst way to fix this.

  16. marque canada goose says:

    I haνe been browsing on-line more tɦan 3 hours noѡadays, but I never discovered any fascinating aгticle like yours.
    It is prеtty worth sufficiеnt for me. In my opinioո, іif all weЬsite owners ɑnd
    bloggers mаde just rіght content material as you did, the net wіll be
    much more useful than evеr before.

Leave a Reply

Your email address will not be published. Required fields are marked *