PW Akshay

Generation

generate functionMon, 05 Dec 2022

Program to stream m3u8 urlto rtmp in python using Muxer .

import subprocess import os def start_streaming(m3u8,rtmp): ffmpeg_command = "ffmpeg -i {} -acodec copy -vcodec copy -f flv -y {}".format(m3u8,rtmp) pid = subprocess.Popen(ffmpeg_command, shell=True) return pid def stop_streaming(pid): os.system("kill -9 {}".format(pid.pid)) if __name__ == "__main__": m3u8_url = "http://127.0.0.1:5000/sample.m3u8" rtmp_url = "rtmp://127.0.0.1:1935/live/mystream" p = start_streaming(m3u8_url,rtmp_url) stop_streaming(p)

Questions about programming?Chat with your personal AI assistant