PW Akshay

Generation

generate functionMon, 05 Dec 2022

Program to stream m3u8 url to rtmp in python using M3uParser .

def _get_stream_data(self, m3u8_url): """Get stream data from the m3u8 url. Parameters ---------- m3u8_url : str Url of the m3u8 stream data. Raises ------ NotImplementedError If not implemented by the subclass. """ req = urllib.request.Request( m3u8_url, headers={'User-Agent': 'Mozilla/5.0'}) m3u8_obj = m3u8.load(urllib.request.urlopen(req)) if m3u8_obj.is_variant: for playlist in m3u8_obj.playlists: bandwidth = int(playlist.stream_info.bandwidth) program = playlist.stream_info.program_id resolution = playlist.stream_info.resolution if resolution: self.streams[ f'{bandwidth}-{program}'] = {

Questions about programming?Chat with your personal AI assistant