PW Akshay

Generation

generate functionMon, 05 Dec 2022

live stream m3u8 to rtmp in python

import requests import os import subprocess import re import threading from datetime import datetime import time import sys from queue import Queue from threading import Thread def get_m3u8_url(): url = 'https://www.youtube.com/watch?v=gJN8QyhdxL4' r = requests.get(url) print(r.text) r1 = re.findall(r'"hlsManifestUrl":"(.*?)"', r.text) return r1[0] def download_m3u8(m3u8_url): file_name = 'tmp.m3u8' print('downloading m3u8...') os.system('ffmpeg -i ' + m3u8_url + ' -c copy ' + file_name) print('downloaded m3u8') return file_name def get_ts_list(m3u8_file_name): ts_list = []

Questions about programming?Chat with your personal AI assistant