This commit is contained in:
eric
2026-02-23 08:52:35 -06:00
parent 31e77d5203
commit 475e15bc16

View File

@@ -198,68 +198,11 @@ def start_douyin_youtube_ffplay(
# "arnndn=m=./arnndn-models/cb.rnnn:mix=0.85," # 人声增强 # "arnndn=m=./arnndn-models/cb.rnnn:mix=0.85," # 人声增强
# 720p-低CPU + 背景音乐处理 + 防ContentID # 720p-低CPU + 背景音乐处理 + 防ContentID
ffmpeg_command = [
"ffmpeg", "-y", "-loglevel", "info", "-nostdin", "-re",
"-stats", "-stats_period", "1",
"-rw_timeout", "30000000",
"-reconnect", "1", "-reconnect_at_eof", "1", "-reconnect_streamed", "1",
"-reconnect_delay_max", "5",
"-fflags", "+genpts+discardcorrupt+nobuffer+flush_packets",
"-flags", "low_delay",
"-err_detect", "ignore_err",
"-max_delay", "80000",
"-thread_queue_size", "2048",
"-headers", douyin_headers,
"-i", real_url,
# 视频处理 720p
"-vf",
"fps=25,scale=720:1280:force_original_aspect_ratio=decrease:flags=bicubic,"
"pad=720:1280:(ow-iw)/2:(oh-ih)/2:black",
"-c:v", "libx264",
"-preset", "veryfast", # 降低CPU
"-profile:v", "high",
"-b:v", "2600k", "-maxrate", "3000k", "-bufsize", "5200k",
"-vsync", "cfr",
"-g", "50", "-keyint_min", "50", # 与fps=25匹配
"-r", "25",
"-bf", "0",
"-sc_threshold", "0",
"-x264-params", "force-cfr=1:scenecut=0:open_gop=0:sync-lookahead=0",
"-pix_fmt", "yuv420p",
# 音频处理(轻量 + 背景音乐弱化 + 防Content ID
"-c:a", "aac", "-b:a", "128k", "-ar", "48000", "-ac", "2",
"-af",
"afftdn=nf=-28:tn=1," # 轻 FFT 降噪,背景弱化
"highpass=f=120,lowpass=f=4800," # 切低频鼓 & 高频镲
"equalizer=f=250:width_type=o:width=2:g=-8," # 衰减低中频
"equalizer=f=800:width_type=o:width=1.5:g=-5," # 衰减中频
"acompressor=threshold=-30dB:ratio=4:attack=10:release=100:makeup=4," # 压动态
"asetrate=48000*1.02,aresample=48000," # 音高微升
"afreqshift=shift=15," # 小幅频率偏移
"volume=1.1," # 音量补偿
"aresample=async=1:first_pts=0", # 音视频同步
# 推流参数
"-flvflags", "no_duration_filesize",
"-f", "flv", youtube_rtmp
]
# 1080p
# ffmpeg_command = [ # ffmpeg_command = [
# "ffmpeg", "-y", "-loglevel", "info", "-nostdin", "-re", # "ffmpeg", "-y", "-loglevel", "info", "-nostdin", "-re",
# "-stats", "-stats_period", "1", # "-stats", "-stats_period", "1",
# "-rw_timeout", "30000000", # "-rw_timeout", "30000000",
# "-reconnect", "1", "-reconnect_at_eof", "1", # "-reconnect", "1", "-reconnect_at_eof", "1", "-reconnect_streamed", "1",
# "-reconnect_streamed", "1",
# "-reconnect_delay_max", "5", # "-reconnect_delay_max", "5",
# "-fflags", "+genpts+discardcorrupt+nobuffer+flush_packets", # "-fflags", "+genpts+discardcorrupt+nobuffer+flush_packets",
# "-flags", "low_delay", # "-flags", "low_delay",
@@ -270,43 +213,100 @@ def start_douyin_youtube_ffplay(
# "-headers", douyin_headers, # "-headers", douyin_headers,
# "-i", real_url, # "-i", real_url,
# # 视频:不动你原策略,只给编码喘口气 # # 视频处理 720p
# "-vf", "fps=25,scale=1080:1920:force_original_aspect_ratio=decrease:flags=bicubic," # "-vf",
# "pad=1080:1920:(ow-iw)/2:(oh-ih)/2:black", # "fps=25,scale=720:1280:force_original_aspect_ratio=decrease:flags=bicubic,"
# "pad=720:1280:(ow-iw)/2:(oh-ih)/2:black",
# "-c:v", "libx264", # "-c:v", "libx264",
# "-preset", "superfast", # "-preset", "veryfast", # 降低CPU
# "-tune", "zerolatency",
# "-profile:v", "high", # "-profile:v", "high",
# "-b:v", "5200k", "-maxrate", "5800k", "-bufsize", "10400k", # "-b:v", "2600k", "-maxrate", "3000k", "-bufsize", "5200k",
# "-vsync", "cfr", # "-vsync", "cfr",
# "-g", "50", "-keyint_min", "50", # "-g", "50", "-keyint_min", "50", # 与fps=25匹配
# "-r", "25", # "-r", "25",
# "-bf", "0", # "-bf", "0",
# "-sc_threshold", "0", # "-sc_threshold", "0",
# "-x264-params", "force-cfr=1:scenecut=0:open_gop=0:sync-lookahead=0", # "-x264-params", "force-cfr=1:scenecut=0:open_gop=0:sync-lookahead=0",
# "-pix_fmt", "yuv420p", # "-pix_fmt", "yuv420p",
# # 音频 # # 音频处理(轻量 + 背景音乐弱化 + 防Content ID
# "-c:a", "aac", "-b:a", "128k", "-ar", "44100", "-ac", "2", # "-c:a", "aac", "-b:a", "128k", "-ar", "48000", "-ac", "2",
# "-af", # "-af",
# "arnndn=m=./arnndn-models/cb.rnnn:mix=0.80," # "afftdn=nf=-28:tn=1," # 轻 FFT 降噪,背景弱化
# "afftdn=nf=-18:tn=1," # "highpass=f=120,lowpass=f=4800," # 切低频鼓 & 高频镲
# "highpass=f=120,lowpass=f=4600," # "equalizer=f=250:width_type=o:width=2:g=-8," # 衰减低中频
# "equalizer=f=250:width_type=o:width=2:g=-6," # "equalizer=f=800:width_type=o:width=1.5:g=-5," # 衰减中频
# "equalizer=f=900:width_type=o:width=1.4:g=-4," # "acompressor=threshold=-30dB:ratio=4:attack=10:release=100:makeup=4," # 压动态
# "asetrate=48000*1.012,aresample=48000," # "asetrate=48000*1.02,aresample=48000," # 音高微升
# "acompressor=threshold=-30dB:ratio=4:attack=10:release=120:makeup=4," # "afreqshift=shift=15," # 小幅频率偏移
# "volume=1.10," # "volume=1.1," # 音量补偿
# "aresample=async=1:first_pts=0", # "aresample=async=1:first_pts=0", # 音视频同步
# # 推流参数
# "-flvflags", "no_duration_filesize", # "-flvflags", "no_duration_filesize",
# "-f", "flv", youtube_rtmp # "-f", "flv", youtube_rtmp
# ] # ]
# 1080p
ffmpeg_command = [
"ffmpeg", "-y", "-loglevel", "info", "-nostdin", "-re",
"-stats", "-stats_period", "1",
"-rw_timeout", "30000000",
"-reconnect", "1", "-reconnect_at_eof", "1",
"-reconnect_streamed", "1",
"-reconnect_delay_max", "5",
"-fflags", "+genpts+discardcorrupt+nobuffer+flush_packets",
"-flags", "low_delay",
"-err_detect", "ignore_err",
"-max_delay", "80000",
"-thread_queue_size", "2048",
"-headers", douyin_headers,
"-i", real_url,
# 视频:不动你原策略,只给编码喘口气
"-vf", "fps=25,scale=1080:1920:force_original_aspect_ratio=decrease:flags=bicubic,"
"pad=1080:1920:(ow-iw)/2:(oh-ih)/2:black",
"-c:v", "libx264",
"-preset", "superfast",
"-tune", "zerolatency",
"-profile:v", "high",
"-b:v", "5200k", "-maxrate", "5800k", "-bufsize", "10400k",
"-vsync", "cfr",
"-g", "50", "-keyint_min", "50",
"-r", "25",
"-bf", "0",
"-sc_threshold", "0",
"-x264-params", "force-cfr=1:scenecut=0:open_gop=0:sync-lookahead=0",
"-pix_fmt", "yuv420p",
# 音频
"-c:a", "aac", "-b:a", "128k", "-ar", "44100", "-ac", "2",
"-af",
"arnndn=m=./arnndn-models/cb.rnnn:mix=0.80,"
"afftdn=nf=-18:tn=1,"
"highpass=f=120,lowpass=f=4600,"
"equalizer=f=250:width_type=o:width=2:g=-6,"
"equalizer=f=900:width_type=o:width=1.4:g=-4,"
"asetrate=48000*1.012,aresample=48000,"
"acompressor=threshold=-30dB:ratio=4:attack=10:release=120:makeup=4,"
"volume=1.10,"
"aresample=async=1:first_pts=0",
"-flvflags", "no_duration_filesize",
"-f", "flv", youtube_rtmp
]
# ====================== 主重试循环(原样保留) ====================== # ====================== 主重试循环(原样保留) ======================
proc = None proc = None
stderr_q = None stderr_q = None