PW Akshay

Generation

generate functionMon, 05 Dec 2022

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

def stream_m3u8_to_rtmp(m3u8_url, rtmp_url): """ Stream m3u8 url to rtmp url """ base_url = os.path.dirname(m3u8_url) m3u8 = requests.get(m3u8_url) m3u8_content = m3u8.text m3u8_list = m3u8_content.split('\n') ts_list = [] for item in m3u8_list: if item.endswith('.ts'): ts_list.append(item) ts_list = [base_url + '/' + ts for ts in ts_list] p = subprocess.Popen(['ffmpeg', '-y', '-i', 'concat:' + '|'.join(ts_list), '-c', 'copy', '-f', 'flv', '-metadata',

Questions about programming?Chat with your personal AI assistant