PW Akshay

Generation

generate functionSun, 04 Dec 2022

stream m3u8 url to rtmp in python using Streamlink

import streamlink from streamlink.stream import HLSStream from streamlink.plugins.rtmpdump import RTMPStream import time from datetime import datetime from time import sleep def stream_m3u8(url, path): streams = streamlink.streams(url) stream = HLSStream(streams) stream.open() with open(path, 'wb') as f: while True: try: time.sleep(1) data = stream.read(1024) f.write(data) except KeyboardInterrupt: print("Exiting") break stream.close()

Want to kickstart your project?Use the new AI Studio to create your code