This commit is contained in:
eric
2026-02-23 09:12:50 -06:00
parent ba4aaa1b65
commit d86e8e339d

View File

@@ -291,7 +291,6 @@ def start_douyin_youtube_ffplay(
# "-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,"
@@ -305,86 +304,69 @@ def start_douyin_youtube_ffplay(
# "-f", "flv", youtube_rtmp
# ]
# 1080p 工业优化版(稳定 + 防ContentID + 低CPU
# 1080p 工业优化版(CPU 低负载 + 防ContentID + 稳定25fps
ffmpeg_command = [
"ffmpeg", "-y", "-loglevel", "info", "-nostdin", "-re",
"-stats", "-stats_period", "1",
"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",
# 网络稳定性
"-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",
# 低延迟
"-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,
"-headers", douyin_headers,
"-i", real_url,
# ================== 视频处理 ==================
# 保留你竖屏策略,降低 CPU bicubic → bilinear
"-vf", "fps=25,scale=1080:1920:force_original_aspect_ratio=decrease:flags=bilinear,"
"pad=1080:1920:(ow-iw)/2:(oh-ih)/2:black",
# ================== 视频处理 ==================
# bilinear 降低 CPU + 保持竖屏
"-vf", "fps=25,scale=1080:1920:force_original_aspect_ratio=decrease:flags=bilinear,"
"pad=1080:1920:(ow-iw)/2:(oh-ih)/2:black",
# 编码优化
"-c:v", "libx264",
"-preset", "veryfast", # superfast→veryfast画质更稳
"-tune", "zerolatency",
"-profile:v", "high",
"-b:v", "4500k", "-maxrate", "5000k", "-bufsize", "9000k",
"-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:v", "libx264",
"-preset", "ultrafast", # CPU 低负载
"-tune", "zerolatency",
"-profile:v", "high",
"-b:v", "4500k", "-maxrate", "5000k", "-bufsize", "9000k",
"-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", "96k", # 降码率,降低ContentID指纹精度
"-ar", "48000",
"-ac", "2",
# ================== 音频编码 ==================
"-c:a", "aac",
"-b:a", "96k", # 降码率,ContentID
"-ar", "48000",
"-ac", "2",
# ================== 音频防ContentID ==================
"-af",
# 深度降噪(可选,模型路径必须绝对路径)
# "arnndn=m=/home/eric/ffmpeg/arnndn-models/cb.rnnn:mix=0.6,"
# 背景音乐削弱关键防ContentID
"afftdn=nf=-25:tn=1:om=o,"
# 人声带通(强化人声)
"highpass=f=90,lowpass=f=4200,"
# 人声EQ
"equalizer=f=180:width_type=o:width=2:g=3," # 低频增强
"equalizer=f=1200:width_type=o:width=1.2:g=2,"# 清晰度
# 轻微变调ContentID杀手
"asetrate=48000*1.006,aresample=48000,"
# 压缩器
"acompressor=threshold=-28dB:ratio=3:attack=5:release=80:makeup=3,"
# 音量
"volume=1.05,"
# 防音画漂移
"aresample=async=1:first_pts=0",
# ================== 音频轻量防ContentID ==================
"-af",
# 背景音乐削弱 + 人声强化 + 轻微变调
"highpass=f=90,lowpass=f=4200,"
"equalizer=f=180:width_type=o:width=2:g=3,"
"equalizer=f=1200:width_type=o:width=1.2:g=2,"
"asetrate=48000*1.006,aresample=48000,"
"acompressor=threshold=-28dB:ratio=3:attack=5:release=80:makeup=3,"
"volume=1.05,"
"aresample=async=1:first_pts=0",
# ================== 输出 ==================
"-flvflags", "no_duration_filesize",
"-f", "flv", youtube_rtmp
]
# ====================== 主重试循环(原样保留) ======================
# ================== 输出 ==================
"-flvflags", "no_duration_filesize",
"-f", "flv", youtube_rtmp
]
proc = None
stderr_q = None
reader_t = None