PW Akshay

Generation

generate functionTue, 17 Jan 2023

create a python program to stream video from m3u8 url to youtube using python-ffmpeg-video-streaming module (do not create function)(do not use subprocess)

#!/usr/bin/env python from ffmpeg_streaming import Formats, Bitrate, Representation, Size from ffmpeg_streaming import HLSStream import requests from bs4 import BeautifulSoup from urllib.request import urlopen # Getting the M3U8 URL url = 'https://github.com/lazyadmin/python-ffmpeg-video-streaming/blob/master/sample.m3u8' response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') link = soup.pre.text # Getting the stream object stream = HLSStream(link) # Get the available formats print('Available formats:') for f in stream.formats: print(f) # Get the available profiles print('\nAvailable profiles:') for p in stream.profiles: print(p) # Get the available subtitles print('\nAvailable subtitles:') for s in stream.subtitles: print(s)

Questions about programming?Chat with your personal AI assistant