stream m3u8 url to rtmp in python (with pyM3U8)
import m3u8 import ffmpeg def stream_m3u8_to_rtmp(m3u8_url, rtmp_url): m3u8_obj = m3u8.load(m3u8_url) m3u8_urls = [] for playlist in m3u8_obj.playlists: m3u8_urls.append(playlist.absolute_uri) for m3u8_url in m3u8_urls: print("Streaming: " + m3u8_url) stream = ffmpeg.input(m3u8_url) stream = ffmpeg.output(stream, rtmp_url, format="flv", vcodec="copy", acodec="copy", r="30") ffmpeg.run(stream) stream_m3u8_to_rtmp("https://video-dev.github.io/streams/x36xhzz/x36xhzz.m3u8", "rtmp://localhost