diff --git a/main.py b/main.py index 1cfb234..0873abf 100644 --- a/main.py +++ b/main.py @@ -1781,44 +1781,44 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None: # 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", + # 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, - # 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", "veryfast", - "-tune", "zerolatency", - "-profile:v", "high", - # 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 - # 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", - "-af", "aresample=async=1:first_pts=0", + # "-headers", douyin_headers, + # "-i", real_url, + # # 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", "veryfast", + # "-tune", "zerolatency", + # "-profile:v", "high", + # # 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 + # # 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", + # "-af", "aresample=async=1:first_pts=0", - "-flags", "+global_header", - "-flvflags", "no_duration_filesize", - "-f", "flv", youtube_rtmp - ] + # "-flags", "+global_header", + # "-flvflags", "no_duration_filesize", + # "-f", "flv", youtube_rtmp + # ] # srs内网配置 @@ -1842,6 +1842,45 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None: # "-f", "flv", srs_rtmp # ] + + + + + # 1080p 输出到 HDMI + 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=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", "veryfast", + "-tune", "zerolatency", + "-profile:v", "high", + "-b:v", "5200k", "-maxrate", "5800k", "-bufsize", "10400k", + "-vsync", "cfr", + "-g", "60", "-keyint_min", "60", + "-r", "30", + "-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", "aresample=async=1:first_pts=0", + + # HDMI 输出,SDL 会直接开窗口显示 + "-f", "sdl", "HDMI" + ] + # ---- 单层重试循环(清晰可控) ---- proc = None stderr_q = None