parent
bc48cbecdd
commit
0c73b6b4b7
@ -47,8 +47,6 @@ width = 1024
|
|||||||
height = 576
|
height = 576
|
||||||
fps = 25
|
fps = 25
|
||||||
v_bitrate = 50000
|
v_bitrate = 50000
|
||||||
a_bitrate = 256
|
|
||||||
a_sample = 44100
|
|
||||||
live_protocols = ["http", "https", "ftp", "rtmp", "rtmpe", "rtmps", "rtp", "rtsp", "srt", "tcp", "udp"]
|
live_protocols = ["http", "https", "ftp", "rtmp", "rtmpe", "rtmps", "rtp", "rtsp", "srt", "tcp", "udp"]
|
||||||
copy_mode = False
|
copy_mode = False
|
||||||
ffmpeg_copy_settings = ["-c", "copy", "-bsf:v", "h264_mp4toannexb", "-threads", "2", "-f", "mpegts", "-"]
|
ffmpeg_copy_settings = ["-c", "copy", "-bsf:v", "h264_mp4toannexb", "-threads", "2", "-f", "mpegts", "-"]
|
||||||
@ -92,8 +90,9 @@ map_extension =
|
|||||||
|
|
||||||
# buffer_length: length in seconds of the buffer
|
# buffer_length: length in seconds of the buffer
|
||||||
# this is the time what the playout have, to change from one clip to the next
|
# this is the time what the playout have, to change from one clip to the next
|
||||||
# # buffer size gets calculate with: (v_bitrate + a_bitrate) * 0.125 * buffer_length
|
# be liberal with this value but dont exaggerate
|
||||||
# by rawvideo (yuv 420) calculation would be:
|
# # buffer size gets calculate with: (v_bitrate * 0.125 + 281.25) * buffer_length
|
||||||
|
# by rawvideo calculation would be:
|
||||||
# (width x height * 3 / 2 * fps * buffer_length / 1024) + ((a_sample * 16 * 2 * buffer_length) / 8 / 1024)
|
# (width x height * 3 / 2 * fps * buffer_length / 1024) + ((a_sample * 16 * 2 * buffer_length) / 8 / 1024)
|
||||||
# Size is in KB
|
# Size is in KB
|
||||||
|
|
||||||
@ -123,7 +122,7 @@ service_provider = example.org
|
|||||||
logo = /usr/local/share/logo.png
|
logo = /usr/local/share/logo.png
|
||||||
logo_o = overlay=W-w-2:0
|
logo_o = overlay=W-w-2:0
|
||||||
post_comp_video = ["-c:v", "libx264", "-crf", "23", "-g", "50", "-maxrate", "1300k", "-bufsize", "2600k", "-preset", "medium", "-profile:v", "Main", "-level", "3.1", "-refs", "3"]
|
post_comp_video = ["-c:v", "libx264", "-crf", "23", "-g", "50", "-maxrate", "1300k", "-bufsize", "2600k", "-preset", "medium", "-profile:v", "Main", "-level", "3.1", "-refs", "3"]
|
||||||
post_comp_audio = ["-c:a", "libfdk_aac", "-b:a", "128k"]
|
post_comp_audio = ["-c:a", "libfdk_aac", "-ar", "44100", "-b:a", "128k"]
|
||||||
post_comp_extra = ["-threads", "2", "-flags", "+global_header", "-f", "flv"]
|
post_comp_extra = ["-threads", "2", "-flags", "+global_header", "-f", "flv"]
|
||||||
post_comp_copy = ["-bsf:a", "aac_adtstoasc"]
|
post_comp_copy = ["-bsf:a", "aac_adtstoasc"]
|
||||||
out_addr = rtmp://127.0.0.1/live/stream
|
out_addr = rtmp://127.0.0.1/live/stream
|
||||||
|
35
ffplayout.py
35
ffplayout.py
@ -71,8 +71,6 @@ _pre_comp = SimpleNamespace(
|
|||||||
fps=cfg.getint('PRE_COMPRESS', 'fps'),
|
fps=cfg.getint('PRE_COMPRESS', 'fps'),
|
||||||
v_bitrate=cfg.getint('PRE_COMPRESS', 'v_bitrate'),
|
v_bitrate=cfg.getint('PRE_COMPRESS', 'v_bitrate'),
|
||||||
v_bufsize=cfg.getint('PRE_COMPRESS', 'v_bitrate'),
|
v_bufsize=cfg.getint('PRE_COMPRESS', 'v_bitrate'),
|
||||||
a_bitrate=cfg.getint('PRE_COMPRESS', 'a_bitrate'),
|
|
||||||
a_sample=cfg.getint('PRE_COMPRESS', 'a_sample'),
|
|
||||||
protocols=cfg.get('PRE_COMPRESS', 'live_protocols'),
|
protocols=cfg.get('PRE_COMPRESS', 'live_protocols'),
|
||||||
copy=cfg.getboolean('PRE_COMPRESS', 'copy_mode'),
|
copy=cfg.getboolean('PRE_COMPRESS', 'copy_mode'),
|
||||||
copy_settings=literal_eval(cfg.get('PRE_COMPRESS', 'ffmpeg_copy_settings'))
|
copy_settings=literal_eval(cfg.get('PRE_COMPRESS', 'ffmpeg_copy_settings'))
|
||||||
@ -223,7 +221,7 @@ def mail_or_log(message, time, path):
|
|||||||
# calculating the size for the buffer in KB
|
# calculating the size for the buffer in KB
|
||||||
def calc_buffer_size():
|
def calc_buffer_size():
|
||||||
return int(
|
return int(
|
||||||
(_pre_comp.v_bitrate + _pre_comp.a_bitrate) * 0.125 * _buffer.length)
|
(_pre_comp.v_bitrate * 0.125 + 281.25) * _buffer.length)
|
||||||
|
|
||||||
|
|
||||||
# check if processes a well
|
# check if processes a well
|
||||||
@ -262,21 +260,21 @@ def seek_in_cut_end(in_file, duration, seek, out):
|
|||||||
if out < duration:
|
if out < duration:
|
||||||
length = out - seek - 1.0
|
length = out - seek - 1.0
|
||||||
cut_end = ['-t', str(out - seek)]
|
cut_end = ['-t', str(out - seek)]
|
||||||
fade_out_vid = '[0:v]fade=out:st=' + str(length) + ':d=1.0;'
|
fade_out_vid = '[0:v]fade=out:st=' + str(length) + ':d=1.0[v];'
|
||||||
fade_out_aud = '[0:a]afade=out:st=' + str(length) + ':d=1.0'
|
fade_out_aud = '[0:a]afade=out:st=' + str(length) + ':d=1.0[a]'
|
||||||
shorten = []
|
end = ['-map', '[v]', '-map', '[a]']
|
||||||
else:
|
else:
|
||||||
cut_end = []
|
cut_end = []
|
||||||
fade_out_vid = ''
|
fade_out_vid = ''
|
||||||
fade_out_aud = '[0:a]apad'
|
fade_out_aud = '[0:a]apad[a]'
|
||||||
shorten = ['-shortest']
|
end = ['-shortest', '-map', '0:v', '-map', '[a]']
|
||||||
|
|
||||||
if _pre_comp.copy:
|
if _pre_comp.copy:
|
||||||
return inpoint + ['-i', in_file] + cut_end
|
return inpoint + ['-i', in_file] + cut_end
|
||||||
else:
|
else:
|
||||||
return inpoint + ['-i', in_file] + cut_end + [
|
return inpoint + ['-i', in_file] + cut_end + [
|
||||||
'-filter_complex', fade_out_vid + fade_out_aud
|
'-filter_complex', fade_out_vid + fade_out_aud
|
||||||
] + shorten
|
] + end
|
||||||
|
|
||||||
|
|
||||||
# generate a dummy clip, with black color and empty audiotrack
|
# generate a dummy clip, with black color and empty audiotrack
|
||||||
@ -289,7 +287,7 @@ def gen_dummy(duration):
|
|||||||
'color=s={}x{}:d={}'.format(
|
'color=s={}x{}:d={}'.format(
|
||||||
_pre_comp.w, _pre_comp.h, duration
|
_pre_comp.w, _pre_comp.h, duration
|
||||||
),
|
),
|
||||||
'-f', 'lavfi', '-i', 'anullsrc=r=' + str(_pre_comp.a_sample),
|
'-f', 'lavfi', '-i', 'anullsrc=r=48000',
|
||||||
'-shortest'
|
'-shortest'
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -320,17 +318,21 @@ def src_or_dummy(src, duration, seek, out, dummy_len=None):
|
|||||||
if seek > 0.0 or out < duration:
|
if seek > 0.0 or out < duration:
|
||||||
return seek_in_cut_end(src, duration, seek, out)
|
return seek_in_cut_end(src, duration, seek, out)
|
||||||
else:
|
else:
|
||||||
return ['-i', src, '-filter_complex', '[0:a]apad', '-shortest']
|
return [
|
||||||
|
'-i', src, '-filter_complex', '[0:a]apad[a]',
|
||||||
|
'-shortest', '-map', '0:v', '-map', '[a]']
|
||||||
else:
|
else:
|
||||||
# no duration found, so we set duration to 24 hours,
|
# no duration found, so we set duration to 24 hours,
|
||||||
# to be sure that out point will cut the lenght
|
# to be sure that out point will cut the lenght
|
||||||
return seek_in_cut_end(src, 86400, 0, out)
|
return seek_in_cut_end(src, 86400, 0, out - seek)
|
||||||
|
|
||||||
elif check_file_exist(src):
|
elif check_file_exist(src):
|
||||||
if seek > 0.0 or out < duration:
|
if seek > 0.0 or out < duration:
|
||||||
return seek_in_cut_end(src, duration, seek, out)
|
return seek_in_cut_end(src, duration, seek, out)
|
||||||
else:
|
else:
|
||||||
return ['-i', src, '-filter_complex', '[0:a]apad', '-shortest']
|
return [
|
||||||
|
'-i', src, '-filter_complex', '[0:a]apad[a]',
|
||||||
|
'-shortest', '-map', '0:v', '-map', '[a]']
|
||||||
else:
|
else:
|
||||||
mail_or_log(
|
mail_or_log(
|
||||||
'Clip not exist:', get_time(None),
|
'Clip not exist:', get_time(None),
|
||||||
@ -682,12 +684,13 @@ def play_clips(out_file, iter_src_commands):
|
|||||||
'-b:v', '{}k'.format(_pre_comp.v_bitrate),
|
'-b:v', '{}k'.format(_pre_comp.v_bitrate),
|
||||||
'-minrate', '{}k'.format(_pre_comp.v_bitrate),
|
'-minrate', '{}k'.format(_pre_comp.v_bitrate),
|
||||||
'-maxrate', '{}k'.format(_pre_comp.v_bitrate),
|
'-maxrate', '{}k'.format(_pre_comp.v_bitrate),
|
||||||
'-bufsize', '{}k'.format(_pre_comp.v_bufsize),
|
'-bufsize', '{}k'.format(_pre_comp.v_bufsize / 2),
|
||||||
'-c:a', 'mp2', '-b:a', '{}k'.format(_pre_comp.a_bitrate),
|
'-c:a', 's302m', '-strict', '-2', '-ar', '48000', '-ac', '2',
|
||||||
'-ar', str(_pre_comp.a_sample), '-ac', '2',
|
|
||||||
'-threads', '2', '-f', 'mpegts', '-'
|
'-threads', '2', '-f', 'mpegts', '-'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
print(src_cmd, ff_pre_settings)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
file_piper = Popen(
|
file_piper = Popen(
|
||||||
[
|
[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user