PW Akshay

Generation

generate functionMon, 05 Dec 2022

Program to stream m3u8 link to rtmp in python using PyM3u8 .

from pym3u8 import load import requests import subprocess import time while True: m3u8_url='http://xxxx/live/stream.m3u8' interval = 10 rtmp_url = "rtmp://xxxx/live/stream" r = requests.get(m3u8_url) if r.status_code == 200: playlist = load(m3u8_url) if playlist.segments: cmd = "ffmpeg -re -i {0} -c copy -f flv {1}".format(playlist.segments[0].absolute_uri, rtmp_url) print (cmd) subprocess.call(cmd, shell=True) time.sleep(interval)

Questions about programming?Chat with your personal AI assistant