diff --git a/douyin_youtube_ffplay.py b/douyin_youtube_ffplay.py index 1dbb42a..c0967e2 100644 --- a/douyin_youtube_ffplay.py +++ b/douyin_youtube_ffplay.py @@ -305,10 +305,13 @@ def start_douyin_youtube_ffplay( # ] -# 1080p - 极致优化版本(高质量 + YouTube直播推荐友好 + 强防Content ID) -# 视频:比特率拉高到YouTube 1080p直播推荐上限附近,preset faster 平衡质量与CPU -# 音频:采样率统一48000Hz,音高抬升5%,频率偏移加大,EQ更针对性衰减背景音乐频段,增加轻微相位/噪门处理 -# 整体:更稳定的推流参数,适合长时间直播 +# 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) ffmpeg_command = [ "ffmpeg", "-y", "-loglevel", "info", "-nostdin", "-re", @@ -325,16 +328,16 @@ def start_douyin_youtube_ffplay( "-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", "faster", + "-preset", "medium", # Ubuntu server CPU通常能承受,质量比faster好很多;若掉帧可回退到faster或veryfast "-tune", "zerolatency", "-profile:v", "high", - "-level", "4.2", # 适配1080p@25fps + "-level", "4.2", # 支持1080p@25fps "-b:v", "8500k", "-maxrate", "10000k", "-bufsize", "20000k", "-vsync", "cfr", "-g", "50", "-keyint_min", "50", @@ -344,24 +347,24 @@ def start_douyin_youtube_ffplay( "-x264-params", "force-cfr=1:scenecut=0:open_gop=0:sync-lookahead=0:rc-lookahead=0", "-pix_fmt", "yuv420p", - # 音频处理 - 防Content ID 强化版 + # 音频处理 - 防Content ID 强化版(多维度修改音频指纹) "-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," # 中频衰减,进一步破坏音乐结构 - "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%(不改变速度) - "afreqshift=shift=22," # 频率整体偏移,破坏指纹匹配 - "aphaser=type=t:decay=0.35:feedback=0.4," # 轻微相位扰动,进一步防检测 - "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," # 中频衰减,破坏音乐结构 + "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", # 强制音视频同步 - # 推流优化 + # 推流优化(FLV适合YouTube RTMP/RTMPS) "-flvflags", "no_duration_filesize", "-f", "flv", youtube_rtmp ]