PW Akshay

Generation

generate functionMon, 05 Dec 2022

Program to live stream m3u8 to rtmp in python (no ffmpeg)

#!/usr/bin/env python """ Live streaming of a m3u8 file to rtmp The file is chunked and read in a loop. When complete it is re-read. The ffmpeg command can be modified to suit the target RTMP server. For example: ffmpeg -re -i 'http://localhost:8000/path/to/file.m3u8' \ -c copy -f flv 'rtmp://a.rtmp.youtube.com/live2/stream_key_from_youtube' """ # https://gist.github.com/rca/5c1a539f4a4be4d4c4ff import os import sys import subprocess import time import signal import logging def get_chunk_list(filename): return [ filename, *[f"{filename}-{i}" for i in range(1, 1000)] ] def get_chunk_timeout(filename): return int(os.stat(filename).st_

Questions about programming?Chat with your personal AI assistant