PW Akshay

Generation

generate functionSun, 04 Dec 2022

stream m3u8 url to rtmp in python (with pym3u8)

import json import time import datetime import subprocess import sys import pym3u8 import os def stream_to_rtmp(url, rtmp_url, duration = 0): if not os.path.isdir("logs"): os.makedirs("logs") # print(url) sys.stdout.write("{}:\tStarted: {}\n".format(rtmp_url, datetime.datetime.now())) sys.stdout.write("{}:\tStream: {}\n".format(rtmp_url, url)) process = subprocess.Popen(['ffmpeg', '-i', url, '-acodec', 'copy', '-vcodec', 'copy', '-f', 'flv', rtmp_url], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) log_file = open("logs/{}.txt".format(rtmp_url), '

Questions about programming?Chat with your personal AI assistant