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(url, rtmp, timeout=10): r = requests.get(url, stream=True) chunks = [] ts_urls = [] for chunk in r.iter_content(chunk_size=1024): if chunk: chunks.append(chunk) else: m3u8_str = b''.join(chunks) ts_urls = re.findall(r'(?<=#EXTINF:)[^\n]+\n(http[^\n]+)', m3u8_str.decode('utf-8')) break ts_urls = [(url, response_headers(url)) for url in ts_urls] if not ts_urls: raise Exception("Could not get ts urls") ts_urls = sorted(ts_urls, key=lambda x: x[0]) rtmp_url = rtmp + '/' + url.split('/')[-1].split('

Questions about programming?Chat with your personal AI assistant