Des del 2000 compartiendo sobre…

RTMP source to HLS (HTTP Live Streaming) Apple

Reading time: 2 – 3 minutes

I just solved a very specific problem and I have to write some notes here to remember the solution. Given a RTMP source we have to stream the content to Apple devices like iPad, iPhone and iPod because RTMP couldn’t be played using Safari browser.

If we need to play streaming on Apple devices the best solution is convert it to HLS and publish generated files using HTTP server.

To solve this issue I use rtmpdump and vlc. Firstly rtmpdump gets video stream from source. Secondly the stream is sent to vlc and finally vlc transcodes de video and audio and outputs small .ts files and one .m3u8 index file.

The command is something like this:

rtmpdump -v -r "$RTMP" | sudo -u xymon vlc -I dummy fd://0 vlc://quit --sout="#transcode{width=320,height=240,fps=25,vcodec=h264,vb=256,venc=x264{aud,profile=baseline,level=30,keyint=30,ref=1,nocabac},acodec=mp3,ab=96,audio-sync,deinterlace,channels=2,samplerate=44100}:std{access=livehttp{seglen=10,delsegs=true,numsegs=5,index=$M3U8,index-url=$TS_URL},mux=ts{use-key-frames},dst=$TSF}"

Variables descriptions are:


Then create an HTML file, for example live.html, with a reference to .m3u8 file, the relevant code of the HTML file is like this:

<video width="320" height="240"><source src="http://example.tld/path/live.m3u8" /></video>

A simple code to public files via HTTP:

python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"

Then we only need to open Safary browser in Apple device and set the proper URL, in our case:


IMPORTANT NOTE: the audio output have to be with two channels and a sample rate of 44KHz in other cases the audio fails.

5 thoughts on “RTMP source to HLS (HTTP Live Streaming) Apple

  1. when i entered this:
    rtmpdump -v -r “$RTMP://” -o 1lv –playpath live | sudo -u maf -I dummy fd://0 vlc://quit –sout=”#transcode{width=320,height=240,fps=25,vcodec=h264,vb=256,venc=x264{aud,profile=baseline,level=30,keyint=30,ref=1,nocabac},acodec=mp3,ab=96,audio-sync,deinterlace,channels=2,samplerate=44100}:std{access=livehttp{seglen=10,delsegs=true,numsegs=5,index=$M3U8,index-url=$TS_URL},mux=ts{use-key-frames},dst=$TSF}”

    my streaming started but i don’t know which address should be use to see streaming on iOS. really i don’t realize what is “Variables descriptions” and python code and address.

    please say me, step by step what i should to do?

  2. As you can see the command you run uses some variables. For example, $TSF is a variable. So you have to setup all the variables in ‘variables descriptions’ before you run the command.

    RTMP= the URL where you have your RTMP source
    WD= working directory where you are going to store small chunks of video, the directory have to be public via HTTP
    TS= the pattern name used to create the chunk video files stored in working directory, you don’t need to touch it
    TSF= don’t touch it, for a while
    TS_URL= the public URL where your apple device have to connect to find the .m3u file and other video chunks files. Change the first part of the URL and keep the $TS if you want to keep simple.
    M3U8= the name of the .m3u file, keep it to be simple

    does it help you?

  3. Thanks Oriol.
    I installed rtmpdump with Synapthic. any other program should be install?
    please explain me about directories.

  4. You only rtmpdump and ffmpeg. I don’t know what can I explain about directories? could you make the question in another way. What is your problem exactly?

Últimas entradas

Resumen 2023

Reading time: 14 – 22 minutes El 2023 comenzó con una sensación de renovación y optimismo. Tras un período marcado por la pandemia, este año se presentó como un lienzo en blanco, lleno de posibilidades y nuevas experiencias. Aunque el

Leer más »