HLS streaming option
This commit is contained in:
parent
95bc1995e9
commit
ab7943f6a7
22
youtube.py
22
youtube.py
|
@ -3,8 +3,10 @@ import os
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
'RTMP_URL': "rtmp://a.rtmp.youtube.com/live2",
|
'RTMP_URL': 'rtmp://a.rtmp.youtube.com/live2/{STREAM_KEY}',
|
||||||
|
'HLS_URL': 'https://a.upload.youtube.com/http_upload_hls?cid=${STREAM_KEY}©=0&file=live.m3u8',
|
||||||
'SRC': 'rtsp://192.168.1.64:554/Streaming/channels/103',
|
'SRC': 'rtsp://192.168.1.64:554/Streaming/channels/103',
|
||||||
'STREAM_KEY': 'not-set'
|
'STREAM_KEY': 'not-set'
|
||||||
}
|
}
|
||||||
|
@ -14,11 +16,25 @@ with open('youtube.json') as fd:
|
||||||
cmd = [
|
cmd = [
|
||||||
'ffmpeg',
|
'ffmpeg',
|
||||||
'-hide_banner',
|
'-hide_banner',
|
||||||
|
'-threads', '4',
|
||||||
'-i',
|
'-i',
|
||||||
config['SRC'],
|
config['SRC'],
|
||||||
'-f', 'lavfi', '-i', 'anullsrc=channel_layout=stereo:sample_rate=44100',
|
'-f', 'lavfi', '-i', 'anullsrc=channel_layout=stereo:sample_rate=44100',
|
||||||
'-map', '0:v',
|
'-map', '0:v',
|
||||||
'-map', '1:a',
|
'-map', '1:a',
|
||||||
|
]
|
||||||
|
if config.get('HLS'):
|
||||||
|
cmd += [
|
||||||
|
'-codec:a', 'aac',
|
||||||
|
'-b:a', '44100',
|
||||||
|
'-bufsize', '1024k',
|
||||||
|
'-c:v', 'copy',
|
||||||
|
'-f', 'hls', '-method', 'PUT', '-hls_time', '2', '-hls_list_size', '4',
|
||||||
|
'-reconnect', '1',
|
||||||
|
config['HLS_URL'].format(**config)
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
cmd += [
|
||||||
'-codec:a', 'libmp3lame',
|
'-codec:a', 'libmp3lame',
|
||||||
'-threads', '4',
|
'-threads', '4',
|
||||||
'-b:a', '11025',
|
'-b:a', '11025',
|
||||||
|
@ -27,6 +43,6 @@ cmd = [
|
||||||
'-c:v', 'copy',
|
'-c:v', 'copy',
|
||||||
'-f', 'flv',
|
'-f', 'flv',
|
||||||
'-reconnect', '1',
|
'-reconnect', '1',
|
||||||
'{RTMP_URL}/{STREAM_KEY}'.format(**config)
|
config['RTMP_URL'].format(**config)
|
||||||
]
|
]
|
||||||
subprocess.check_output(cmd)
|
subprocess.check_output(cmd)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user