PW Akshay

Generation

generate functionMon, 05 Dec 2022

Program to live stream m3u8 to rtmp in python (no ffmpeg and no function)

def m3u8_to_rtmp_flv(m3u8_url, rtmp_url): ts_urls = [urljoin(m3u8_url, url) for url in re.findall(r'(/.*?\.ts)', requests.get(m3u8_url).text)] ts_urls = ts_urls if ts_urls: ts_url = random.choice(ts_urls) response = requests.get(ts_url, stream=True) if response.status_code == 200: print("Streaming:", ts_url) return ffmpeg_stream(response, rtmp_url) def ffmpeg_stream(response, rtmp_url): ffmpeg_cmd = ['ffmpeg', '-y', '-i', '-', '-c', 'copy', '-f', 'flv', rtmp_url] proc = Popen(ffmpeg_cmd, stdin=PIPE, stderr=P

Questions about programming?Chat with your personal AI assistant