From 7aa77cb473f0ec42702b72c955249fa74179757f Mon Sep 17 00:00:00 2001 From: eric Date: Sat, 20 Dec 2025 09:28:42 -0600 Subject: [PATCH] 's' --- main.py | 70 +++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 12 deletions(-) diff --git a/main.py b/main.py index 9c81441..6390798 100644 --- a/main.py +++ b/main.py @@ -1736,9 +1736,55 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None: "Referer: https://live.douyin.com/\r\n" "Origin: https://live.douyin.com\r\n" ) + + + # 720p + # 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, + # # 720p + # "-vf", "fps=30,scale=720:1280:force_original_aspect_ratio=decrease:flags=lanczos,pad=720:1280:(ow-iw)/2:(oh-ih)/2:black", + # "-c:v", "libx264", + # "-preset", "fast", + # # "-tune", "zerolatency", + # "-profile:v", "high", + # # 720p + # # "-minrate", "3200k","-b:v", "3200k", "-maxrate", "3200k", "-bufsize", "6400k", # bufsize = 2× bitrate,保持真 CBR + # "-b:v", "2600k","-maxrate", "3000k","-bufsize", "5200k", + # "-vsync", "cfr", + # "-g", "60", "-keyint_min", "60", + # "-r", "30", + # "-bf", "0", + # "-sc_threshold", "0", + # # "-nal-hrd", "cbr", # 改2:强制 CBR + # # 720p + # # "-x264-params", "nal-hrd=cbr:force-cfr=1:scenecut=0:filler=1", # 改3:简化 params,锁死 CBR + # "-x264-params", "force-cfr=1:scenecut=0:open_gop=0:sync-lookahead=0", + # "-pix_fmt", "yuv420p", + # "-c:a", "aac", "-b:a", "128k", "-ar", "48000", "-ac", "2", # 改4:1080p可音频上 128k(YouTube 推荐) + # "-af", "aresample=async=1:first_pts=0", + + # "-flags", "+global_header", + # "-flvflags", "no_duration_filesize", + # "-f", "flv", youtube_rtmp + # ] + + + # 1080p ffmpeg_command = [ "ffmpeg", "-y", "-loglevel", "info", "-nostdin", "-re", - "-stats", "-stats_period", "1", "-fflags", "+genpts", + "-stats", "-stats_period", "1", "-rw_timeout", "30000000", "-reconnect", "1", "-reconnect_at_eof", "1", "-reconnect_streamed", "1", "-reconnect_delay_max", "5", @@ -1750,24 +1796,24 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None: "-headers", douyin_headers, "-i", real_url, - - # "-vf", "scale=1080:1920:force_original_aspect_ratio=decrease:flags=lanczos,pad=1080:1920:(ow-iw)/2:(oh-ih)/2:black", - "-vf", "scale=720:1280:force_original_aspect_ratio=decrease,pad=720:1280:(ow-iw)/2:(oh-ih)/2:black", - + # 1080p + "-vf","fps=30,scale=1080:1920:force_original_aspect_ratio=decrease:flags=lanczos,pad=1080:1920:(ow-iw)/2:(oh-ih)/2:black", "-c:v", "libx264", - "-preset", "superfast", + "-preset", "veryfast", "-tune", "zerolatency", "-profile:v", "high", - "-b:v", "4200k", "-maxrate", "4200k", "-bufsize", "8400k", # 改1:2× bufsize,真 CBR - "-g", "60", "-keyint_min", "50", + # 1080p + "-b:v", "5200k", "-maxrate", "5800k", "-bufsize", "10400k", # 改1:2× bufsize,真 CBR + "-vsync", "cfr", + "-g", "60", "-keyint_min", "60", "-r", "30", "-bf", "0", "-sc_threshold", "0", - "-nal-hrd", "cbr", # 改2:强制 CBR - "-x264-params", "nal-hrd=cbr:force-cfr=1:scenecut=0", # 改3:简化 params,锁死 CBR + # "-nal-hrd", "cbr", # 改2:强制 CBR + # 1080p + "-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", # 改4:音频上 128k(YouTube 推荐) + "-c:a", "aac", "-b:a", "128k", "-ar", "44100", "-ac", "2", "-af", "aresample=async=1:first_pts=0", "-flags", "+global_header",