PW Akshay

Generation

generate functionMon, 05 Dec 2022

live stream m3u8 to rtmp in python

import requests import re import time import subprocess def get_m3u8(url): #url = "http://douyu.com/lapi/live/getPlay/96419" headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'} response = requests.get(url, headers=headers) data = response.text strinfo = re.compile('hls_url="(.*?)"') result = strinfo.findall(data) #print(result[0]) return result[0] def stream(url): print('start') p = subprocess.Popen(['ffmpeg', '-i', url, '-c:v', 'libx264', '-c:a', 'aac', '-strict', '-2', '-f', '

Questions about programming?Chat with your personal AI assistant