Skip to content

Instantly share code, notes, and snippets.

@agrif
Last active January 3, 2016 02:09
Show Gist options
  • Select an option

  • Save agrif/8394113 to your computer and use it in GitHub Desktop.

Select an option

Save agrif/8394113 to your computer and use it in GitHub Desktop.
overviewer.org RTMP configuration
# RTMP server
rtmp {
server {
listen 1935;
ping 30s;
application stream {
live on;
hls on;
hls_path /var/www/org/overviewer/htdocs/stream/hls;
on_publish http://127.0.0.1/stream/authenticate;
exec_publish /var/www/org/overviewer/on-stream-publish.py $name $args;
}
}
}
# within http / server
http {
server {
# RTMP streaming
location ^~ /stream/statistics {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stream/hls {
root /var/www/org/overviewer/htdocs;
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
add_header Cache-Control no-cache;
}
location ^~ /stream/authenticate {
# do auth here
# return 401 if not authorized
# otherwise, continue on!
return 200;
}
}
}
#!/usr/bin/env python
# responsible for forwarding published streams with a 'twitch'
# argument to twitch.tv
from urllib.parse import parse_qs, quote
import subprocess
import sys
_, name, args = sys.argv
args = parse_qs(args)
if not 'twitch' in args:
exit(0)
src = "rtmp://127.0.0.1/stream/{}".format(quote(name))
dest = "rtmp://live.twitch.tv/app/{}".format(quote(args['twitch'][-1]))
cmd = ["ffmpeg", "-re", "-i", src, "-vcodec", "copy", "-acodec", "copy", "-f", "flv", dest]
subprocess.call(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment