#!/usr/bin/python3 import os import json import subprocess config = { 'RTMP_URL': "rtmp://a.rtmp.youtube.com/live2", 'SRC': 'rtsp://192.168.1.64:554/Streaming/channels/103', 'STREAM_KEY': 'not-set' } with open('youtube.json') as fd: config.update(json.load(fd)) cmd = [ 'ffmpeg', '-hide_banner', '-i', config['SRC'], '-f', 'lavfi', '-i', 'anullsrc=channel_layout=stereo:sample_rate=44100', '-map', '0:v', '-map', '1:a', '-codec:a', 'libmp3lame', '-threads', '4', '-b:a', '11025', '-bufsize', '1024k', '-fflags', '+genpts', '-c:v', 'copy', '-f', 'flv', '-reconnect', '1', '{RTMP_URL}/{STREAM_KEY}'.format(**config) ] subprocess.check_output(cmd)