Skip to content

Commit ee068ef

Browse files
committed
Added a hls2srt tool
1 parent f00a0d9 commit ee068ef

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

Dockerfile.hls2srt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM eyevinntechnology/ffmpeg-base:0.3.0
2+
MAINTAINER Eyevinn Technology <[email protected]>
3+
COPY python/hls2srt.py /root/hls2srt.py
4+
ENTRYPOINT ["/root/hls2srt.py"]
5+
CMD []

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The Eyevinn Toolbox is a set of Docker containers with tools that may come in ha
1111
| Mosaic TS | Render a 2x2 or 3x3 mosaic in MPEG-TS from 4 or 9 HLS sources | eyevinntechnology/toolbox-mosaicts |
1212
| HLS 2 TS | Pull a live HLS stream and output to multicast TS | eyevinntechnology/toolbox-hls2ts |
1313
| HLS 2 RTMP | Pull a live HLS stream and re-stream to multiple RTMP destinations. | eyevinntechnology/toolbox-hls2rtmp |
14+
| HLS 2 SRT | Pull a live HLS stream and transmit over SRT | eyevinntechnology/toolbox-hls2srt |
1415
| SRT 2 RTMP | Receive an SRT stream and re-stream to multiple RTMP destinations. | eyevinntechnology/toolbox-srt2rtmp |
1516
| RTMP 2 SRT | Receive an RTMP stream and transmit over SRT. | eyevinntechnology/toolbox-rtmp2srt |
1617

@@ -279,6 +280,16 @@ Example:
279280
docker run --rm eyevinntechnology/toolbox-hls2rtmp:0.1.3 HLSURL <RTMPURL1> <RTMPURL2>
280281
```
281282

283+
## Pull a live HLS stream and output to SRT
284+
285+
Use the `hls2srt` tool to pull a live HLS stream and make available over SRT.
286+
287+
Example:
288+
289+
```
290+
docker run -d --restart always -p 1234:1234/udp eyevinntechnology/toolbox-hls2srt:0.1.0 HLSURL 0.0.0.0:1234
291+
```
292+
282293
## Listen for an RTMP stream and output to SRT
283294

284295
Use the `rtmp2srt` tool to receive an RTMP stream and transmit over SRT.

build-hls2srt.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker build -t eyevinntechnology/toolbox-hls2srt:0.1.0 -f Dockerfile.hls2srt .

python/hls2srt.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/python2.7
2+
#
3+
# Copyright 2019 Eyevinn Technology. All rights reserved
4+
# Use of this source code is governed by a MIT License
5+
# that can be found in the LICENSE file.
6+
# Author: Jonas Rydholm Birme (Eyevinn Technology)
7+
#
8+
# Receive HLS and stream over SRT
9+
#
10+
import argparse
11+
import subprocess
12+
from os.path import basename
13+
import re
14+
import glob
15+
16+
parser = argparse.ArgumentParser(description='Pull HLS and restream over SRT.')
17+
parser.add_argument('hlsurl')
18+
parser.add_argument('address')
19+
parser.add_argument('--srtmode', dest='srtmode', help='SRT mode [caller|listener]. Default is listener')
20+
parser.add_argument('--with-debug', dest='debug', action='store_true')
21+
args = parser.parse_args()
22+
23+
srtmode = "&mode=listener"
24+
if args.srtmode == "caller":
25+
srtmode = ""
26+
27+
srtoutput = "-f fifo -fifo_format mpegts -map 0:v:0 -map 0:a:0 -c copy srt://%s?pkt_size=1316%s" % (args.address, srtmode)
28+
29+
ffmpeg = "ffmpeg -fflags +genpts -re -i %s -strict -2 -y %s " % (args.hlsurl, srtoutput)
30+
31+
if args.debug:
32+
print "%s" % ffmpeg
33+
print ffmpeg.split()
34+
35+
p1 = subprocess.Popen(ffmpeg.split())
36+
output,err = p1.communicate()

0 commit comments

Comments
 (0)