PW Akshay

Generation

generate functionSun, 04 Dec 2022

stream with m3u8 to rtmp in python (no ffmpeg)

from subprocess import Popen, PIPE import requests import os def hls2rtmp(hls_url, rtmp_url): """ hls_url: https://baidu.com/hls/stream.m3u8 rtmp_url:rtmp://baidu.com/live/stream """ rtmpdump_cmd = [ "rtmpdump", "-r", hls_url, "-o", "- | ffmpeg -i - -c copy -f flv " + rtmp_url ] p1 = Popen(rtmpdump_cmd, stdout=PIPE) p2 = Popen(["ffmpeg", "-i", "-", "-c", "copy", "-f", "flv", rtmp_url], stdin=p1.stdout, stdout=PIPE) p1.stdout.close() output = p2.communicate()[0] hls2rtmp("https://example

Questions about programming?Chat with your personal AI assistant