's'
This commit is contained in:
@@ -305,13 +305,14 @@ def start_douyin_youtube_ffplay(
|
||||
# ]
|
||||
|
||||
|
||||
# 1080p - 极致优化版本(Ubuntu Server 专用,高质量 + YouTube直播推荐友好 + 强防Content ID)
|
||||
# 针对Ubuntu server(通常CPU较强,无iOS硬件限制):
|
||||
# - preset 升级到 medium 或 slow(如果CPU能承受,质量显著提升)
|
||||
# - 比特率保持8500k-10000k峰值,符合YouTube 1080p直播高质量推荐
|
||||
# - 音频防Content ID:音高+5%、频率偏移、多段EQ衰减背景音乐、强压缩、相位扰动(使用aphaser正确参数)、轻噪门
|
||||
# - 移除无效参数,修复之前aphaser错误(aphaser支持in_gain/out_gain/delay/decay/speed/type,不支持feedback)
|
||||
# - Ubuntu下推荐使用最新FFmpeg(apt install ffmpeg 或从源码编译支持libx264)
|
||||
|
||||
# 1080p - 防缓冲优先极致稳定版(针对 YouTube "not receiving enough video" 错误)
|
||||
# 关键变化:
|
||||
# - 强制关键帧每 2 秒(YouTube 强烈推荐,避免 GOP 过长)
|
||||
# - preset 降到 faster(降低 CPU 压力,确保实时输出)
|
||||
# - 比特率稍降到 7000k-9000k(更稳,YouTube 1080p 推荐 4500-9000k 范围)
|
||||
# - 增大 bufsize + 添加 rc-lookahead=10(帮助率控制更稳)
|
||||
# - 保持音频防Content ID,但简化链路防额外延迟
|
||||
|
||||
ffmpeg_command = [
|
||||
"ffmpeg", "-y", "-loglevel", "info", "-nostdin", "-re",
|
||||
@@ -322,52 +323,54 @@ def start_douyin_youtube_ffplay(
|
||||
"-fflags", "+genpts+discardcorrupt+nobuffer+flush_packets",
|
||||
"-flags", "low_delay",
|
||||
"-err_detect", "ignore_err",
|
||||
"-max_delay", "50000",
|
||||
"-thread_queue_size", "4096",
|
||||
"-max_delay", "30000", # 进一步降低延迟
|
||||
"-thread_queue_size", "8192", # 更大输入队列,防输入抖动
|
||||
|
||||
"-headers", douyin_headers,
|
||||
"-i", real_url,
|
||||
|
||||
# 视频处理:1080p 纵屏优化,黑边填充
|
||||
# 视频处理:1080p 纵屏,黑边
|
||||
"-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", "medium", # Ubuntu server CPU通常能承受,质量比faster好很多;若掉帧可回退到faster或veryfast
|
||||
"-preset", "faster", # 先用 faster 确保不掉帧;稳定后再试 medium
|
||||
"-tune", "zerolatency",
|
||||
"-profile:v", "high",
|
||||
"-level", "4.2", # 支持1080p@25fps
|
||||
"-b:v", "8500k", "-maxrate", "10000k", "-bufsize", "20000k",
|
||||
"-level", "4.2",
|
||||
"-b:v", "7000k", "-maxrate", "9000k", "-bufsize", "18000k", # 更保守比特率 + 大缓冲
|
||||
"-minrate", "5000k", # 添加 minrate 强制 CBR 更稳
|
||||
"-vsync", "cfr",
|
||||
"-g", "50", "-keyint_min", "50",
|
||||
"-r", "25",
|
||||
"-g", "50", "-keyint_min", "25", # GOP=50 (2s),min=25 防太频繁
|
||||
"-bf", "0",
|
||||
"-sc_threshold", "0",
|
||||
"-x264-params", "force-cfr=1:scenecut=0:open_gop=0:sync-lookahead=0:rc-lookahead=0",
|
||||
"-force_key_frames", "expr:gte(t,n_forced*2)", # 强制每2秒关键帧(最重要修复!)
|
||||
"-x264-params", "force-cfr=1:scenecut=0:open_gop=0:sync-lookahead=0:rc-lookahead=10:keyint=50:min-keyint=25",
|
||||
"-pix_fmt", "yuv420p",
|
||||
|
||||
# 音频处理 - 防Content ID 强化版(多维度修改音频指纹)
|
||||
"-c:a", "aac", "-b:a", "192k", "-ar", "48000", "-ac", "2",
|
||||
# 音频处理 - 保持防Content ID,但简化链路
|
||||
"-c:a", "aac", "-b:a", "160k", "-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," # 中频衰减,破坏音乐结构
|
||||
"equalizer=f=2800:width_type=o:width=1.2:g=-5," # 高中频轻衰减,保持人声自然
|
||||
"acompressor=threshold=-26dB:ratio=5.5:attack=7:release=90:makeup=6," # 强压缩,改变动态指纹
|
||||
"asetrate=48000*1.05,atempo=1.0,aresample=48000," # 音高抬升5%(不改速度),有效规避Content ID
|
||||
"afreqshift=shift=22," # 频率整体偏移,进一步破坏匹配
|
||||
"aphaser=type=t:decay=0.35:delay=3.0:speed=0.5," # 正确参数:轻微相位扰动(triangular类型),防检测
|
||||
# "anlmdn=s=0.00012:p=0.0008:r=0.002," # 轻量非线性噪门,清理残余背景音乐
|
||||
"volume=1.08," # 补偿音量衰减
|
||||
"aresample=async=1:first_pts=0:min_hard_comp=0.100000:first_pts=0", # 强制音视频同步
|
||||
"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,"
|
||||
"anlmdn=s=0.00012:p=0.0008:r=0.002,"
|
||||
"volume=1.08,"
|
||||
"aresample=async=1:first_pts=0:min_hard_comp=0.100000:first_pts=0",
|
||||
|
||||
# 推流优化(FLV适合YouTube RTMP/RTMPS)
|
||||
# 推流
|
||||
"-flvflags", "no_duration_filesize",
|
||||
"-f", "flv", youtube_rtmp
|
||||
]
|
||||
|
||||
proc = None
|
||||
stderr_q = None
|
||||
reader_t = None
|
||||
|
||||
Reference in New Issue
Block a user