PW Akshay

Generation

generate functionMon, 05 Dec 2022

Program to stream m3u8 url to rtmp in python using Streamlink

import streamlink import subprocess # M3U8 stream m3u8_stream_url = "https://www.youtube.com/watch?v=yVUbUYq3wq4" # RTMP stream rtmp_stream_url = "rtmp://rtmp.example.com:1935/app/stream_name" # Get streams streams = streamlink.streams(m3u8_stream_url) # Get best quality stream stream = streams['best'] # Get stream url stream_url = stream.url # Create command to stream m3u8 url to rtmp command = ["ffmpeg", "-i", stream_url, "-c:v", "copy", "-c:a", "aac", "-strict", "-2", "-f", "flv", rtmp_stream_url] # Stream to rtmp server subprocess.call(command)

Questions about programming?Chat with your personal AI assistant