stream m3u8 url to rtmp in python using Streamlink
def stream_m3u8(url): cwd = os.getcwd() os.chdir(os.path.join(cwd, '..', '..', '..', '..', '..', 'Streamlink', 'bin', 'streamlink')) subprocess.call(['streamlink', url, 'best', '--quiet', '--hls-live-restart', '--hls-segment-threads', '3', '--hls-segment-timeout', '30', '--hls-segment-attempts', '3', '--hls-playlist-reload', '30', '--hls-segment-timeout', '30', '-o', '-', '|', 'ffmpeg', '-i', 'pipe:0', '-c', 'copy', '-f', 'flv', 'rtmp://a.rtmp.youtube.com/live2/' + livestreamkey]) os.chdir(cwd)