This commit is contained in:
eric
2026-02-23 17:41:36 -06:00
parent 3842833ad0
commit 326ab8aea2

View File

@@ -372,45 +372,48 @@ def start_douyin_youtube_ffplay(
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", "30000", # 降下来
"-thread_queue_size", "2048",
"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",
"-err_detect","ignore_err",
"-max_delay","500000",
"-thread_queue_size","512",
# 抖音源
"-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",
# 视频处理
"-vf","fps=25,scale=1080:1920:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2:black",
"-c:v", "libx264",
"-preset", "veryfast", # 关键改动!先用 veryfast 测试
# "-tune", "zerolatency", # 注释掉或移除,先不加
"-profile:v", "high",
"-level", "4.2",
"-b:v", "5200k", "-maxrate", "6000k", "-bufsize", "12000k", # 降比特率 + 合理 bufsize
"-vsync", "cfr",
"-g", "50", "-keyint_min", "25",
"-r", "25",
"-bf", "0",
"-sc_threshold", "0",
"-x264-params", "force-cfr=1:scenecut=0:open_gop=0:sync-lookahead=0:rc-lookahead=0",
"-pix_fmt", "yuv420p",
# 编码
"-c:v","libx264",
"-preset","veryfast",
"-profile:v","high",
"-level","4.2",
"-b:v","4500k","-maxrate","4500k","-bufsize","9000k",
"-g","50","-keyint_min","50",
"-r","25",
"-pix_fmt","yuv420p",
"-bf","0",
"-sc_threshold","0",
"-x264-params","force-cfr=1:scenecut=0:open_gop=0",
# 音频部分保持你的防Content ID很强但如果 CPU 紧,可简化 af 链
"-c:a", "aac", "-b:a", "192k", "-ar", "48000", "-ac", "2",
"-af", "afftdn=nf=-24:tn=1,highpass=f=100,lowpass=f=5200,equalizer=f=180:width_type=o:width=2.2:g=-12,equalizer=f=350:width_type=o:width=1.8:g=-9,equalizer=f=750:width_type=o:width=1.6:g=-7,acompressor=threshold=-26dB:ratio=5.5:attack=7:release=90:makeup=6,asetrate=48000*1.05,atempo=1.0,aresample=48000,afreqshift=shift=22,aphaser=type=t:decay=0.35:delay=3.0:speed=0.5,volume=1.08,aresample=async=1:first_pts=0:min_hard_comp=0.100000",
# 音频(强烈建议简化)
"-c:a","aac","-b:a","128k","-ar","44100","-ac","2",
"-af","aresample=async=1,volume=1.05",
"-flvflags", "no_duration_filesize",
"-f", "flv", youtube_rtmp
# 推流
"-flvflags","no_duration_filesize",
"-f","flv", youtube_rtmp
]
proc = None
stderr_q = None
reader_t = None