PW Akshay

Generation

generate functionSun, 04 Dec 2022

stream m3u8 url to rtmp in python with pyffmpeg

def m3u8_to_rtmp(url, stream_name, local_port=10000, time_interval=5): print("start streaming m3u8 to rtmp\n") stream_cmd = "ffmpeg -i %s -c copy -f flv rtmp://localhost:%s/%s" % (url, local_port, stream_name) print(stream_cmd) stream_subprocess = subprocess.Popen(stream_cmd, shell=True, stderr=subprocess.STDOUT) print("streaming pid: %s\n" % stream_subprocess.pid) print("streaming url: %s\n" % url) print("streaming stream name: %s\n" % stream_name) print("streaming local port: %s\n" % local_port) print("streaming time interval: %s\n" % time_interval) while True: time.sleep(time_interval) if stream_subprocess.poll() is

Questions about programming?Chat with your personal AI assistant