This commit is contained in:
eric
2025-12-10 15:05:18 +08:00
parent 31e7c67425
commit b2af356c22

45
main.py
View File

@@ -1671,21 +1671,18 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None:
pass
# ========== 参数配置(保留你原始配置) ==========
YT_STREAM_KEY = "qxvb-r47b-r5ju-6ud3-6k7z"
# YT_STREAM_KEY = "qxvb-r47b-r5ju-6ud3-6k7z"
youtube_rtmp = f"rtmp://a.rtmp.youtube.com/live2/qxvb-r47b-r5ju-6ud3-6k7z"
# youtube_rtmp="rtmp://192.168.31.184/live/douyin"
# ←←←← 在这块代码的上方先定义你要推的多个地址 ←←←←
rtmp_targets = [
"rtmp://a.rtmp.youtube.com/live2/qxvb-r47b-r5ju-6ud3-6k7z", # 主频道
"rtmp://192.168.31.184/live/douyin", # 备用频道(换成你的第二个 YouTube 密钥)
# "rtmp://live-push.bilibili.com/live/xxx?streamkey=xxx", # B站示例
# "rtmp://ingest.twitch.tv/ingest/xxxxxxx", # Twitch 示例
# 想推几个就加几个
]
# # ←←←← 在这块代码的上方先定义你要推的多个地址 ←←←←
# rtmp_targets = [
# "rtmp://a.rtmp.youtube.com/live2/qxvb-r47b-r5ju-6ud3-6k7z", # 主频道
# "rtmp://192.168.31.184/live/douyin", # 备用频道(换成你的第二个 YouTube 密钥)
# ]
# 用 | 拼接所有地址(任何一个断开都不会影响其他)
tee_outputs = "|".join([f"[f=flv:onfail=ignore]{url}" for url in rtmp_targets])
# # 用 | 拼接所有地址(任何一个断开都不会影响其他)
# tee_outputs = "|".join([f"[f=flv]{url}" for url in rtmp_targets])
@@ -1735,7 +1732,6 @@ 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"
)
ffmpeg_command = [
"ffmpeg", "-loglevel", "info",
"-rw_timeout", "15000000",
@@ -1753,12 +1749,29 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None:
"-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
"-f", "flv", youtube_rtmp
# "-f", "tee",
# "-map", "0:v", "-map", "0:a",
# tee_outputs
]
# srs内网配置
# ffmpeg_command = [
# "ffmpeg", "-loglevel", "warning",
# "-err_detect", "ignore_err+explode",
# "-fflags", "+genpts+discardcorrupt+igndts",
# "-reconnect", "1", "-reconnect_at_eof", "1", "-reconnect_streamed", "1",
# "-reconnect_delay_max", "7",
# "-rw_timeout", "30000000",
# "-headers", douyin_headers,
# "-i", real_url,
# "-re", "-copyts", "-avoid_negative_ts", "disabled",
# "-max_muxing_queue_size", "9999",
# "-c:v", "copy", "-c:a", "copy",
# "-f", "flv", youtube_rtmp
# ]
# ---- 单层重试循环(清晰可控) ----
proc = None
stderr_q = None