PW Akshay

Generation

generate functionMon, 05 Dec 2022

Program to stream m3u8 url to youtube in python

import requests from bs4 import BeautifulSoup import subprocess, os, sys def stream_to_youtube(m3u8_url): streamlink = "streamlink" quality = "best" youtube_stream_url = "rtmp://a.rtmp.youtube.com/live2" streamlink_cmd = [streamlink, m3u8_url, quality, "-Q", "--hls-segment-threads", "4", "--hls-live-edge", "3", "-O"] ffmpeg_cmd = ["ffmpeg", "-i", "-", "-c", "copy", "-f", "flv", youtube_stream_url] with subprocess.Popen(streamlink_cmd, stdout=subprocess.PIPE) as streamlink_process, subprocess.Popen( ffmpeg_cmd, stdin=streamlink_process.stdout, stdout=sys.stdout, stderr=sys.stderr) as ffmpeg_process: streamlink_process.

Questions about programming?Chat with your personal AI assistant