This commit is contained in:
eric
2026-01-31 22:02:56 -06:00
parent 5722f2f6b3
commit dc4c1c514b
3 changed files with 106 additions and 48 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,2 +1,2 @@
# Pyarmor 9.2.3 (trial), 000000, 2026-01-31T21:44:12.520443
# Pyarmor 9.2.3 (trial), 000000, 2026-01-31T22:01:53.471815
from .pyarmor_runtime import __pyarmor__

View File

@@ -151,7 +151,7 @@ def start_douyin_youtube_ffplay(
except Exception as e:
print(f"[WARN] NVENC 检测失败,回退软件编码: {e}")
# 720p
# 720p (最原始)
# ffmpeg_command = [
# "ffmpeg", "-y", "-loglevel", "info", "-nostdin", "-re",
# "-stats", "-stats_period", "1",
@@ -194,13 +194,14 @@ def start_douyin_youtube_ffplay(
# ]
# 1080p
# 720p-处理背景音(低 CPU + Content ID 防护优化版)
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", "1", "-reconnect_at_eof", "1", "-reconnect_streamed", "1",
"-reconnect_delay_max", "5",
"-fflags", "+genpts+discardcorrupt+nobuffer+flush_packets",
"-flags", "low_delay",
@@ -211,42 +212,99 @@ def start_douyin_youtube_ffplay(
"-headers", douyin_headers,
"-i", real_url,
"-vf", "fps=30,scale=1080:1920:force_original_aspect_ratio=decrease:flags=lanczos,"
"pad=1080:1920:(ow-iw)/2:(oh-ih)/2:black",
# 视频处理 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",
"-tune", "zerolatency",
"-preset", "veryfast", # 降低 CPU 压力
"-profile:v", "high",
"-b:v", "5200k", "-maxrate", "5800k", "-bufsize", "10400k",
"-b:v", "2600k", "-maxrate", "3000k", "-bufsize", "5200k",
"-vsync", "cfr",
"-g", "60", "-keyint_min", "60",
"-r", "30",
"-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",
"-c:a", "aac", "-b:a", "128k", "-ar", "44100", "-ac", "2",
# 音频处理(轻量版 + 防 Content ID
"-c:a", "aac", "-b:a", "128k", "-ar", "48000", "-ac", "2",
"-af",
"arnndn=m=./arnndn-models/cb.rnnn:mix=0.88,"
"afftdn=nf=-24:tn=1,"
"highpass=f=110,lowpass=f=4800,"
"equalizer=f=250:width_type=o:width=2:g=-9,"
"equalizer=f=800:width_type=o:width=1.5:g=-6,"
"atempo=1.03,"
"asetrate=48000*1.02,aresample=48000,"
"afreqshift=shift=20,"
"acompressor=threshold=-28dB:ratio=5:attack=8:release=80:makeup=5,"
"volume=1.15,"
"aresample=async=1:first_pts=0",
"afftdn=nf=-28:tn=1," # 轻 FFT 降噪
"highpass=f=120,lowpass=f=5000," # 切低频鼓 & 高频镲
"equalizer=f=250:width_type=o:width=2:g=-6," # 音乐低频基础
"equalizer=f=900:width_type=o:width=1.2:g=-4,"# 音乐旋律区轻弱化
"acompressor=threshold=-32dB:ratio=3.5:attack=12:release=150:makeup=3," # 压动态
"asetrate=48000*1.02,aresample=48000," # 音高上移 1/2 半音
"afreqshift=shift=15," # 小幅频率偏移
"volume=1.05," # 音量补偿
"aresample=async=1:first_pts=0", # 保证音视频同步
# 推流参数
"-flvflags", "no_duration_filesize",
"-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
stderr_q = None