PW Akshay

Generation

generate functionMon, 05 Dec 2022

Program to stream m3u8 url to rtmp in python using RTMPDump .

def stream_to_rtmp(m3u8_url, output, swf_url, page_url, token_url, timeout=10, verbose=False): rtmpdump_cmd = ['rtmpdump', '-r', m3u8_url, '-o', output, '--swfVfy', swf_url, '--pageUrl', page_url, '--token', token_url, '--live'] if verbose: rtmpdump_cmd.append('--verbose') process = subprocess.Popen(rtmpdump_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) count = 0 while True: # Wait for the process to finish and timeout every 10 seconds exit_code = process.poll() if exit_code is not None: break time.sleep(1) count += 1 if count >= timeout: process.terminate() break

Questions about programming?Chat with your personal AI assistant