Search code examples
nginxffmpegwowzahttp-live-streamingffserver

Forward HLS Stream - Solution needed


i'm receiving a HLS/AppleHTTP stream with FFmpeg. The source stream looks like:

Input #0, hls,applehttp, from 'http://example.com/hls/index.m3u8':
   Duration: 00:00:00.09, start: 42870.540944, bitrate: 91 kb/s
   Program 0
   Metadata:
      variant_bitrate : 0
   Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1024x576 [SAR 1:1 DAR 16:9], 12.50 fps, 25 tbr, 90k tbn, 50 tbc
   Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 114 kb/s
   Stream #0:2: Unknown: none ([21][0][0][0] / 0x0015)

I need to forward this kind of stream with FFmpeg to a Stream Server. My problem is, how to do it with FFmpeg without encoding and have high CPU usage (i think -video copy -audio copy). Second, which Streaming Server Software is the best (low cpu usage) to recieve the stream and send it to the users as HLS stream?


Solution

  • HLS stands for HTTP Live Streaming. You don't need a special server to send it to the clients, just a regular web server like Nginx (one of your tags).

    You can do:

    ffmpeg -i http://example.com/hls/index.m3u8 -c copy /path/to/web/dir/index.m3u8

    The command will create the playlist and copy the segments to /path/to/web/dir which is located in the web server's document root. The clients only need the new URL.

    Things will get more complicated if the input playlist is a master playlist containing multiple variant streams. In this case you need to capture all individual streams to different directories and write a new master playlist on your side to regroup the different streams.