PW Akshay

Generation

generate functionSun, 04 Dec 2022

stream m3u8 to rtmp in python (no ffmpeg)

def streamM3U8(url, host="rtmp://127.0.0.1:1935/live"): req = urllib.request.Request(url) res = urllib.request.urlopen(req) res2 = res.read().decode('utf-8') res.close() #print(res2) patt = re.compile('(^.*?\n)') res3 = patt.findall(res2) tsUrl = res3[-1].strip() #print(tsUrl) #tsUrl = "http://192.168.1.4/live/test.ts" return streamTS(tsUrl, host) def streamTS(url, host = "rtmp://127.0.0.1:1935/live"): size = 1024 stream = urllib.request.urlopen(url) #print(stream.info()) #print(stream.getcode()) #print(stream.get

Questions about programming?Chat with your personal AI assistant