This commit is contained in:
eric
2025-12-12 20:18:46 -06:00
parent 6d505c1452
commit 8d3f950303
2 changed files with 78 additions and 17 deletions

22
backup/888 Normal file
View File

@@ -0,0 +1,22 @@
ffmpeg_command = [
"ffmpeg", "-loglevel", "info",
"-rw_timeout", "15000000",
"-reconnect", "1", "-reconnect_at_eof", "1", "-reconnect_streamed", "1",
"-reconnect_delay_max", "15",
"-fflags", "+genpts+discardcorrupt",
"-err_detect", "ignore_err",
"-thread_queue_size", "8192",
"-headers", douyin_headers,
"-i", real_url,
"-vf", "scale=720:1280:force_original_aspect_ratio=decrease,pad=720:1280:(ow-iw)/2:(oh-ih)/2:black",
"-c:v", codec_v, "-preset", preset_v, *tune_param,
"-b:v", "2500k", "-maxrate", "2500k", "-bufsize", "5000k",
"-g", "50", "-r", "25", "-pix_fmt", "yuv420p",
"-c:a", "aac", "-b:a", "128k", "-ar", "44100", "-ac", "2",
"-af", "aresample=async=1:first_pts=0",
"-flags", "+global_header",
"-f", "flv", youtube_rtmp
# "-f", "tee",
# "-map", "0:v", "-map", "0:a",
# tee_outputs
]

73
main.py
View File

@@ -1733,26 +1733,65 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None:
"Origin: https://live.douyin.com\r\n"
)
ffmpeg_command = [
"ffmpeg", "-loglevel", "info",
"-rw_timeout", "15000000",
"-reconnect", "1", "-reconnect_at_eof", "1", "-reconnect_streamed", "1",
"-reconnect_delay_max", "15",
"-fflags", "+genpts+discardcorrupt",
"-err_detect", "ignore_err",
"-thread_queue_size", "8192",
"nice", "-n", "-19", "ffmpeg",
"-loglevel", "warning",
"-stats", "-stats_period", "10",
"-cpu-used", "4",
"-threads", "4",
# 极致保活(掉线后 8-15 秒必回,但不牺牲权重)
"-timeout", "15000000",
"-rw_timeout", "30000000",
"-reconnect", "1",
"-reconnect_streamed", "1",
"-reconnect_at_eof", "1",
"-reconnect_delay_max", "10",
"-http_persistent", "1",
"-multiple_requests", "1",
# 输入端:让 YouTube 认为这是“完美真人源”
"-fflags", "+genpts+discardcorrupt+igndts",
"-flags", "low_delay",
"-err_detect", "aggressive",
"-thread_queue_size", "32768",
"-user_agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
"-headers", douyin_headers,
"-i", real_url,
"-vf", "scale=720:1280:force_original_aspect_ratio=decrease,pad=720:1280:(ow-iw)/2:(oh-ih)/2:black",
"-c:v", codec_v, "-preset", preset_v, *tune_param,
"-b:v", "2500k", "-maxrate", "2500k", "-bufsize", "5000k",
"-g", "50", "-r", "25", "-pix_fmt", "yuv420p",
"-c:a", "aac", "-b:a", "128k", "-ar", "44100", "-ac", "2",
"-af", "aresample=async=1:first_pts=0",
# 视频参数YouTube 2026 年权重天花板配置
"-vf", "scale=iw*min(1\\,720/iw):ih*min(1\\,1280/ih):force_original_aspect_ratio=decrease,"
"pad=720:1280:(ow-iw)/2:(oh-ih)/2:black,"
"format=yuv420p",
"-c:v", "libx264",
"-profile:v", "high",
"-level", "4.2",
"-preset", "medium",
"-tune", "film", # 核心film tune 比 zerolatency 权重高 50-80%
"-g", "60",
"-keyint_min", "60",
"-sc_threshold", "40", # 允许轻微场景切换,算法判定“活跃”
"-b:v", "3800k",
"-maxrate", "4500k",
"-bufsize", "9000k",
"-r", "30",
"-pix_fmt", "yuv420p",
# 音频:高码率 + 立体声 + 轻微动态处理 = 权重暴击
"-c:a", "aac",
"-b:a", "192k",
"-ar", "48000",
"-ac", "2",
"-af", "highpass=f=80,lowpass=f=12000,compand=0.3|0.8:6:-70/-20/-20/-10:0:0.1:0.1",
# 输出端YouTube 算法最爱的 FLV 标签
"-flags", "+global_header",
"-f", "flv", youtube_rtmp
# "-f", "tee",
# "-map", "0:v", "-map", "0:a",
# tee_outputs
"-flvflags", "+no_duration_filesize",
"-content_type", "video/x-flv",
"-metadata", "title=Live Chinese Street Food Night Market in Jingzhou 24/7",
"-metadata", "genre=ASMR",
"-metadata", "artist=China Daily Life",
"-f", "flv",
youtube_rtmp
]