Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6760dc99f |
@@ -145,8 +145,8 @@ def start_douyin_to_youtube(record_url, youtube_key, room_name=None, delay_sec=3
|
|||||||
|
|
||||||
# ----------------- 示例 -----------------
|
# ----------------- 示例 -----------------
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
DOUYIN_URL = "https://live.douyin.com/674071534727"
|
DOUYIN_URL = "https://live.douyin.com/640087893839"
|
||||||
YOUTUBE_KEY = "ue78-1c3e-mr9g-14mz-9r4z"
|
YOUTUBE_KEY = "qxvb-r47b-r5ju-6ud3-6k7z"
|
||||||
|
|
||||||
hls_instance = start_douyin_to_youtube(DOUYIN_URL, YOUTUBE_KEY, delay_sec=30)
|
hls_instance = start_douyin_to_youtube(DOUYIN_URL, YOUTUBE_KEY, delay_sec=30)
|
||||||
|
|
||||||
202
backup/back3
202
backup/back3
@@ -1,202 +0,0 @@
|
|||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import threading
|
|
||||||
import asyncio
|
|
||||||
import uuid
|
|
||||||
import queue
|
|
||||||
import time
|
|
||||||
import signal
|
|
||||||
import sys
|
|
||||||
import shutil
|
|
||||||
import spider
|
|
||||||
import stream
|
|
||||||
|
|
||||||
class AdaptiveHLS2YouTube:
|
|
||||||
def __init__(self, max_bitrate=5000, min_bitrate=3000, audio_bitrate=192,
|
|
||||||
delay_sec=40, segment_time=2, check_interval=5):
|
|
||||||
self.processes = {}
|
|
||||||
self.stop_flag = threading.Event()
|
|
||||||
self.delay_sec = delay_sec
|
|
||||||
self.segment_time = segment_time
|
|
||||||
self.check_interval = check_interval
|
|
||||||
self.buffer_queue = queue.Queue()
|
|
||||||
self.max_bitrate = max_bitrate
|
|
||||||
self.min_bitrate = min_bitrate
|
|
||||||
self.audio_bitrate = audio_bitrate
|
|
||||||
self.current_bitrate = max_bitrate
|
|
||||||
|
|
||||||
def start_stream(self, real_url, youtube_key, room_name=None):
|
|
||||||
room_name = room_name or f"抖音_{str(uuid.uuid4())[:8]}"
|
|
||||||
print(f"[{room_name}] 启动推流,目标 YouTube Key: {youtube_key}")
|
|
||||||
threading.Thread(target=self._pull_thread, args=(real_url,), daemon=True).start()
|
|
||||||
threading.Thread(target=self._push_thread, args=(youtube_key, room_name), daemon=True).start()
|
|
||||||
threading.Thread(target=self._abr_thread, daemon=True).start()
|
|
||||||
|
|
||||||
def _pull_thread(self, real_url):
|
|
||||||
cmd = [
|
|
||||||
"ffmpeg",
|
|
||||||
"-rw_timeout", "50000000",
|
|
||||||
"-user_agent", "Mozilla/5.0",
|
|
||||||
"-headers", "Referer: https://www.douyin.com/",
|
|
||||||
"-fflags", "+nobuffer+genpts",
|
|
||||||
"-flags", "low_delay",
|
|
||||||
"-reconnect", "1",
|
|
||||||
"-reconnect_at_eof", "1",
|
|
||||||
"-reconnect_streamed", "1",
|
|
||||||
"-reconnect_delay_max", "10",
|
|
||||||
"-i", real_url,
|
|
||||||
"-c", "copy",
|
|
||||||
"-f", "mpegts",
|
|
||||||
"-"
|
|
||||||
]
|
|
||||||
try:
|
|
||||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
|
|
||||||
print("[拉流] FFmpeg 启动成功")
|
|
||||||
while not self.stop_flag.is_set():
|
|
||||||
data = proc.stdout.read(188*500) # 读取更大块,减少空跑
|
|
||||||
if not data:
|
|
||||||
time.sleep(0.05)
|
|
||||||
continue
|
|
||||||
self.buffer_queue.put(data)
|
|
||||||
except Exception as e:
|
|
||||||
print(f"拉流异常: {e}")
|
|
||||||
|
|
||||||
def _push_thread(self, youtube_key, room_name):
|
|
||||||
min_buffer = max(1, self.delay_sec // self.segment_time)
|
|
||||||
while not self.stop_flag.is_set():
|
|
||||||
if self.buffer_queue.qsize() < min_buffer:
|
|
||||||
time.sleep(0.05)
|
|
||||||
continue
|
|
||||||
|
|
||||||
cmd = [
|
|
||||||
"ffmpeg",
|
|
||||||
"-re",
|
|
||||||
"-f", "mpegts",
|
|
||||||
"-i", "-",
|
|
||||||
"-c:v", "libx264",
|
|
||||||
"-preset", "veryfast",
|
|
||||||
"-tune", "zerolatency",
|
|
||||||
"-b:v", f"{self.current_bitrate}k",
|
|
||||||
"-maxrate", f"{self.current_bitrate}k",
|
|
||||||
"-bufsize", f"{self.current_bitrate*4}k",
|
|
||||||
"-r", "30",
|
|
||||||
"-g", "60",
|
|
||||||
"-s", "720x1280",
|
|
||||||
"-c:a", "aac",
|
|
||||||
"-b:a", f"{self.audio_bitrate}k",
|
|
||||||
"-ar", "44100",
|
|
||||||
"-ac", "2",
|
|
||||||
"-f", "flv",
|
|
||||||
"-rtmp_live", "live",
|
|
||||||
f"rtmp://a.rtmp.youtube.com/live2/{youtube_key}"
|
|
||||||
]
|
|
||||||
try:
|
|
||||||
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
||||||
self.processes[room_name] = proc
|
|
||||||
|
|
||||||
def read_stderr():
|
|
||||||
while proc.poll() is None:
|
|
||||||
line = proc.stderr.readline()
|
|
||||||
if line:
|
|
||||||
print(f"[{room_name} FFmpeg]: {line.decode(errors='ignore').strip()}")
|
|
||||||
threading.Thread(target=read_stderr, daemon=True).start()
|
|
||||||
|
|
||||||
while not self.stop_flag.is_set():
|
|
||||||
try:
|
|
||||||
data = self.buffer_queue.get(timeout=1)
|
|
||||||
proc.stdin.write(data)
|
|
||||||
proc.stdin.flush()
|
|
||||||
except queue.Empty:
|
|
||||||
continue
|
|
||||||
except Exception as e:
|
|
||||||
print(f"[{room_name}] 推流异常: {e}")
|
|
||||||
|
|
||||||
def _abr_thread(self):
|
|
||||||
while not self.stop_flag.is_set():
|
|
||||||
queue_len = self.buffer_queue.qsize()
|
|
||||||
if queue_len > 100:
|
|
||||||
new_bitrate = max(self.min_bitrate, self.current_bitrate - 300)
|
|
||||||
elif queue_len < 30:
|
|
||||||
new_bitrate = min(self.max_bitrate, self.current_bitrate + 300)
|
|
||||||
else:
|
|
||||||
new_bitrate = self.current_bitrate
|
|
||||||
if new_bitrate != self.current_bitrate:
|
|
||||||
print(f"[ABR] 调整码率: {self.current_bitrate}k -> {new_bitrate}k")
|
|
||||||
self.current_bitrate = new_bitrate
|
|
||||||
time.sleep(self.check_interval)
|
|
||||||
|
|
||||||
def stop_all(self):
|
|
||||||
print("停止所有推流...")
|
|
||||||
self.stop_flag.set()
|
|
||||||
for proc in self.processes.values():
|
|
||||||
if proc.poll() is None:
|
|
||||||
proc.terminate()
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------- 抖音解析逻辑 -----------------
|
|
||||||
async def get_douyin_real_url(record_url, record_quality="原画"):
|
|
||||||
if 'v.douyin.com' not in record_url and '/user/' not in record_url:
|
|
||||||
json_data = await spider.get_douyin_stream_data(url=record_url)
|
|
||||||
else:
|
|
||||||
json_data = await spider.get_douyin_app_stream_data(url=record_url)
|
|
||||||
port_info = await stream.get_douyin_stream_url(json_data, record_quality, None)
|
|
||||||
return port_info.get("record_url")
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------- 启动推流 -----------------
|
|
||||||
def start_douyin_to_youtube(record_url, youtube_key, room_name=None, delay_sec=40):
|
|
||||||
try:
|
|
||||||
real_url = asyncio.run(get_douyin_real_url(record_url))
|
|
||||||
except Exception as e:
|
|
||||||
print(f"获取真实直播流失败: {e}")
|
|
||||||
return
|
|
||||||
if not real_url:
|
|
||||||
print("获取真实直播流失败")
|
|
||||||
return
|
|
||||||
print(f"实际直播流: {real_url}")
|
|
||||||
hls2yt = AdaptiveHLS2YouTube(delay_sec=delay_sec)
|
|
||||||
hls2yt.start_stream(real_url, youtube_key, room_name)
|
|
||||||
return hls2yt
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------- 控制台监控面板 -----------------
|
|
||||||
def monitor_panel_thread(hls_instance, interval=2, max_width=50):
|
|
||||||
term_width, _ = shutil.get_terminal_size()
|
|
||||||
bar_width = min(max_width, term_width - 30)
|
|
||||||
|
|
||||||
while not hls_instance.stop_flag.is_set():
|
|
||||||
queue_len = hls_instance.buffer_queue.qsize()
|
|
||||||
bitrate = hls_instance.current_bitrate
|
|
||||||
active_push = any(proc and proc.poll() is None for proc in hls_instance.processes.values())
|
|
||||||
|
|
||||||
queue_bar_len = min(bar_width, queue_len)
|
|
||||||
queue_bar = "#" * queue_bar_len + "-" * (bar_width - queue_bar_len)
|
|
||||||
|
|
||||||
print("\r", end="")
|
|
||||||
print(f"[监控] 队列: [{queue_bar}] {queue_len:4} | 码率: {bitrate:4}k | 推流活跃: {active_push}", end="")
|
|
||||||
time.sleep(interval)
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------- 示例 -----------------
|
|
||||||
if __name__ == "__main__":
|
|
||||||
DOUYIN_URL = "https://live.douyin.com/364595817295"
|
|
||||||
YOUTUBE_KEY = "qxvb-r47b-r5ju-6ud3-6k7z"
|
|
||||||
|
|
||||||
hls_instance = start_douyin_to_youtube(DOUYIN_URL, YOUTUBE_KEY, delay_sec=40)
|
|
||||||
if not hls_instance:
|
|
||||||
print("推流实例创建失败,程序退出")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
threading.Thread(target=monitor_panel_thread, args=(hls_instance,), daemon=True).start()
|
|
||||||
|
|
||||||
def signal_handler(sig, frame):
|
|
||||||
if hls_instance:
|
|
||||||
hls_instance.stop_all()
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, signal_handler)
|
|
||||||
signal.signal(signal.SIGTERM, signal_handler)
|
|
||||||
|
|
||||||
print("程序已启动,按 Ctrl+C 停止...")
|
|
||||||
while True:
|
|
||||||
time.sleep(60)
|
|
||||||
208
backup/back4
208
backup/back4
@@ -1,208 +0,0 @@
|
|||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import threading
|
|
||||||
import asyncio
|
|
||||||
import uuid
|
|
||||||
import queue
|
|
||||||
import time
|
|
||||||
import signal
|
|
||||||
import sys
|
|
||||||
import shutil
|
|
||||||
import spider
|
|
||||||
import stream
|
|
||||||
|
|
||||||
class AdaptiveHLS2YouTube:
|
|
||||||
def __init__(self, max_bitrate=5000, min_bitrate=3000, audio_bitrate=192,
|
|
||||||
delay_sec=40, segment_time=2, check_interval=5):
|
|
||||||
self.processes = {}
|
|
||||||
self.stop_flag = threading.Event()
|
|
||||||
self.delay_sec = delay_sec
|
|
||||||
self.segment_time = segment_time
|
|
||||||
self.check_interval = check_interval
|
|
||||||
self.buffer_queue = queue.Queue(maxsize=500) # 增大队列,防止阻塞
|
|
||||||
self.max_bitrate = max_bitrate
|
|
||||||
self.min_bitrate = min_bitrate
|
|
||||||
self.audio_bitrate = audio_bitrate
|
|
||||||
self.current_bitrate = max_bitrate
|
|
||||||
|
|
||||||
def start_stream(self, real_url, youtube_key, room_name=None):
|
|
||||||
room_name = room_name or f"抖音_{str(uuid.uuid4())[:8]}"
|
|
||||||
print(f"[{room_name}] 启动推流,目标 YouTube Key: {youtube_key}")
|
|
||||||
threading.Thread(target=self._pull_thread, args=(real_url,), daemon=True).start()
|
|
||||||
threading.Thread(target=self._push_thread, args=(youtube_key, room_name), daemon=True).start()
|
|
||||||
threading.Thread(target=self._abr_thread, daemon=True).start()
|
|
||||||
|
|
||||||
def _pull_thread(self, real_url):
|
|
||||||
cmd = [
|
|
||||||
"ffmpeg",
|
|
||||||
"-rw_timeout", "50000000",
|
|
||||||
"-user_agent", "Mozilla/5.0",
|
|
||||||
"-headers", "Referer: https://www.douyin.com/",
|
|
||||||
"-fflags", "+nobuffer+genpts",
|
|
||||||
"-flags", "low_delay",
|
|
||||||
"-reconnect", "1",
|
|
||||||
"-reconnect_at_eof", "1",
|
|
||||||
"-reconnect_streamed", "1",
|
|
||||||
"-reconnect_delay_max", "10",
|
|
||||||
"-i", real_url,
|
|
||||||
"-c", "copy",
|
|
||||||
"-f", "mpegts",
|
|
||||||
"-"
|
|
||||||
]
|
|
||||||
try:
|
|
||||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
|
|
||||||
print("[拉流] FFmpeg 启动成功")
|
|
||||||
while not self.stop_flag.is_set():
|
|
||||||
data = proc.stdout.read(188*2000) # 大块读取,减少空跑
|
|
||||||
if not data:
|
|
||||||
time.sleep(0.05)
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
self.buffer_queue.put_nowait(data) # 非阻塞写入队列
|
|
||||||
except queue.Full:
|
|
||||||
continue # 队列满直接丢掉,保证不卡
|
|
||||||
except Exception as e:
|
|
||||||
print(f"拉流异常: {e}")
|
|
||||||
|
|
||||||
def _push_thread(self, youtube_key, room_name):
|
|
||||||
min_buffer = max(1, self.delay_sec // self.segment_time)
|
|
||||||
while not self.stop_flag.is_set():
|
|
||||||
if self.buffer_queue.qsize() < min_buffer:
|
|
||||||
time.sleep(0.05)
|
|
||||||
continue
|
|
||||||
|
|
||||||
cmd = [
|
|
||||||
"ffmpeg",
|
|
||||||
"-re",
|
|
||||||
"-f", "mpegts",
|
|
||||||
"-i", "-",
|
|
||||||
"-c:v", "libx264",
|
|
||||||
"-preset", "veryfast",
|
|
||||||
"-tune", "zerolatency",
|
|
||||||
"-b:v", f"{self.current_bitrate}k",
|
|
||||||
"-maxrate", f"{self.current_bitrate}k",
|
|
||||||
"-bufsize", f"{self.current_bitrate*4}k",
|
|
||||||
"-r", "30",
|
|
||||||
"-g", "60",
|
|
||||||
"-s", "720x1280",
|
|
||||||
"-c:a", "aac",
|
|
||||||
"-b:a", f"{self.audio_bitrate}k",
|
|
||||||
"-ar", "44100",
|
|
||||||
"-ac", "2",
|
|
||||||
"-f", "flv",
|
|
||||||
"-rtmp_live", "live",
|
|
||||||
f"rtmp://a.rtmp.youtube.com/live2/{youtube_key}"
|
|
||||||
]
|
|
||||||
try:
|
|
||||||
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
||||||
self.processes[room_name] = proc
|
|
||||||
|
|
||||||
def read_stderr():
|
|
||||||
while proc.poll() is None:
|
|
||||||
line = proc.stderr.readline()
|
|
||||||
if line:
|
|
||||||
print(f"[{room_name} FFmpeg]: {line.decode(errors='ignore').strip()}")
|
|
||||||
threading.Thread(target=read_stderr, daemon=True).start()
|
|
||||||
|
|
||||||
while not self.stop_flag.is_set():
|
|
||||||
try:
|
|
||||||
data = self.buffer_queue.get(timeout=0.5)
|
|
||||||
try:
|
|
||||||
proc.stdin.write(data)
|
|
||||||
proc.stdin.flush()
|
|
||||||
except (BrokenPipeError, OSError):
|
|
||||||
break # 管道断开,退出推流循环
|
|
||||||
except queue.Empty:
|
|
||||||
continue
|
|
||||||
except Exception as e:
|
|
||||||
print(f"[{room_name}] 推流异常: {e}")
|
|
||||||
|
|
||||||
def _abr_thread(self):
|
|
||||||
while not self.stop_flag.is_set():
|
|
||||||
queue_len = self.buffer_queue.qsize()
|
|
||||||
if queue_len > 100:
|
|
||||||
new_bitrate = max(self.min_bitrate, self.current_bitrate - 300)
|
|
||||||
elif queue_len < 30:
|
|
||||||
new_bitrate = min(self.max_bitrate, self.current_bitrate + 300)
|
|
||||||
else:
|
|
||||||
new_bitrate = self.current_bitrate
|
|
||||||
if new_bitrate != self.current_bitrate:
|
|
||||||
print(f"[ABR] 调整码率: {self.current_bitrate}k -> {new_bitrate}k")
|
|
||||||
self.current_bitrate = new_bitrate
|
|
||||||
time.sleep(max(self.check_interval, 10)) # 降低 ABR 更新频率,避免频繁干扰
|
|
||||||
|
|
||||||
def stop_all(self):
|
|
||||||
print("停止所有推流...")
|
|
||||||
self.stop_flag.set()
|
|
||||||
for proc in self.processes.values():
|
|
||||||
if proc.poll() is None:
|
|
||||||
proc.terminate()
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------- 抖音解析逻辑 -----------------
|
|
||||||
async def get_douyin_real_url(record_url, record_quality="原画"):
|
|
||||||
if 'v.douyin.com' not in record_url and '/user/' not in record_url:
|
|
||||||
json_data = await spider.get_douyin_stream_data(url=record_url)
|
|
||||||
else:
|
|
||||||
json_data = await spider.get_douyin_app_stream_data(url=record_url)
|
|
||||||
port_info = await stream.get_douyin_stream_url(json_data, record_quality, None)
|
|
||||||
return port_info.get("record_url")
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------- 启动推流 -----------------
|
|
||||||
def start_douyin_to_youtube(record_url, youtube_key, room_name=None, delay_sec=40):
|
|
||||||
try:
|
|
||||||
real_url = asyncio.run(get_douyin_real_url(record_url))
|
|
||||||
except Exception as e:
|
|
||||||
print(f"获取真实直播流失败: {e}")
|
|
||||||
return
|
|
||||||
if not real_url:
|
|
||||||
print("获取真实直播流失败")
|
|
||||||
return
|
|
||||||
print(f"实际直播流: {real_url}")
|
|
||||||
hls2yt = AdaptiveHLS2YouTube(delay_sec=delay_sec)
|
|
||||||
hls2yt.start_stream(real_url, youtube_key, room_name)
|
|
||||||
return hls2yt
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------- 控制台监控面板 -----------------
|
|
||||||
def monitor_panel_thread(hls_instance, interval=2, max_width=50):
|
|
||||||
term_width, _ = shutil.get_terminal_size()
|
|
||||||
bar_width = min(max_width, term_width - 30)
|
|
||||||
|
|
||||||
while not hls_instance.stop_flag.is_set():
|
|
||||||
queue_len = hls_instance.buffer_queue.qsize()
|
|
||||||
bitrate = hls_instance.current_bitrate
|
|
||||||
active_push = any(proc and proc.poll() is None for proc in hls_instance.processes.values())
|
|
||||||
|
|
||||||
queue_bar_len = min(bar_width, queue_len)
|
|
||||||
queue_bar = "#" * queue_bar_len + "-" * (bar_width - queue_bar_len)
|
|
||||||
|
|
||||||
print("\r", end="")
|
|
||||||
print(f"[监控] 队列: [{queue_bar}] {queue_len:4} | 码率: {bitrate:4}k | 推流活跃: {active_push}", end="")
|
|
||||||
time.sleep(interval)
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------- 示例 -----------------
|
|
||||||
if __name__ == "__main__":
|
|
||||||
DOUYIN_URL = "https://live.douyin.com/125742860435"
|
|
||||||
YOUTUBE_KEY = "qxvb-r47b-r5ju-6ud3-6k7z"
|
|
||||||
|
|
||||||
hls_instance = start_douyin_to_youtube(DOUYIN_URL, YOUTUBE_KEY, delay_sec=40)
|
|
||||||
if not hls_instance:
|
|
||||||
print("推流实例创建失败,程序退出")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
threading.Thread(target=monitor_panel_thread, args=(hls_instance,), daemon=True).start()
|
|
||||||
|
|
||||||
def signal_handler(sig, frame):
|
|
||||||
if hls_instance:
|
|
||||||
hls_instance.stop_all()
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, signal_handler)
|
|
||||||
signal.signal(signal.SIGTERM, signal_handler)
|
|
||||||
|
|
||||||
print("程序已启动,按 Ctrl+C 停止...")
|
|
||||||
while True:
|
|
||||||
time.sleep(60)
|
|
||||||
220
backup/back5
220
backup/back5
@@ -1,220 +0,0 @@
|
|||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import threading
|
|
||||||
import asyncio
|
|
||||||
import uuid
|
|
||||||
import queue
|
|
||||||
import time
|
|
||||||
import signal
|
|
||||||
import sys
|
|
||||||
import shutil
|
|
||||||
import spider
|
|
||||||
import stream
|
|
||||||
|
|
||||||
|
|
||||||
class AdaptiveHLS2YouTube:
|
|
||||||
def __init__(self, max_bitrate=5000, min_bitrate=3000, audio_bitrate=192,
|
|
||||||
delay_sec=40, segment_time=2, check_interval=5):
|
|
||||||
self.processes = {}
|
|
||||||
self.stop_flag = threading.Event()
|
|
||||||
self.delay_sec = delay_sec
|
|
||||||
self.segment_time = segment_time
|
|
||||||
self.check_interval = check_interval
|
|
||||||
self.buffer_queue = queue.Queue(maxsize=800) # 队列加大
|
|
||||||
self.max_bitrate = max_bitrate
|
|
||||||
self.min_bitrate = min_bitrate
|
|
||||||
self.audio_bitrate = audio_bitrate
|
|
||||||
self.current_bitrate = max_bitrate
|
|
||||||
|
|
||||||
def start_stream(self, real_url, youtube_key, room_name=None):
|
|
||||||
room_name = room_name or f"抖音_{str(uuid.uuid4())[:8]}"
|
|
||||||
print(f"[{room_name}] 启动推流,目标 YouTube Key: {youtube_key}")
|
|
||||||
threading.Thread(target=self._pull_thread, args=(real_url,), daemon=True).start()
|
|
||||||
threading.Thread(target=self._push_thread, args=(youtube_key, room_name), daemon=True).start()
|
|
||||||
threading.Thread(target=self._abr_thread, daemon=True).start()
|
|
||||||
|
|
||||||
def _pull_thread(self, real_url):
|
|
||||||
cmd = [
|
|
||||||
"ffmpeg",
|
|
||||||
"-rw_timeout", "50000000",
|
|
||||||
"-user_agent", "Mozilla/5.0",
|
|
||||||
"-headers", "Referer: https://www.douyin.com/",
|
|
||||||
"-fflags", "+nobuffer+genpts",
|
|
||||||
"-flags", "low_delay",
|
|
||||||
"-reconnect", "1",
|
|
||||||
"-reconnect_at_eof", "1",
|
|
||||||
"-reconnect_streamed", "1",
|
|
||||||
"-reconnect_delay_max", "10",
|
|
||||||
"-i", real_url,
|
|
||||||
"-c", "copy",
|
|
||||||
"-f", "mpegts",
|
|
||||||
"-"
|
|
||||||
]
|
|
||||||
try:
|
|
||||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
||||||
print("[拉流] FFmpeg 启动成功")
|
|
||||||
|
|
||||||
def read_stderr():
|
|
||||||
while proc.poll() is None:
|
|
||||||
line = proc.stderr.readline()
|
|
||||||
if line:
|
|
||||||
print(f"[拉流FFmpeg]: {line.decode(errors='ignore').strip()}")
|
|
||||||
threading.Thread(target=read_stderr, daemon=True).start()
|
|
||||||
|
|
||||||
while not self.stop_flag.is_set():
|
|
||||||
data = proc.stdout.read(188 * 5000) # 提升吞吐
|
|
||||||
if not data:
|
|
||||||
time.sleep(0.05)
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
self.buffer_queue.put_nowait(data)
|
|
||||||
except queue.Full:
|
|
||||||
continue
|
|
||||||
except Exception as e:
|
|
||||||
print(f"拉流异常: {e}")
|
|
||||||
|
|
||||||
def _push_thread(self, youtube_key, room_name):
|
|
||||||
min_buffer = max(1, self.delay_sec // self.segment_time)
|
|
||||||
while not self.stop_flag.is_set():
|
|
||||||
if self.buffer_queue.qsize() < min_buffer:
|
|
||||||
time.sleep(0.05)
|
|
||||||
continue
|
|
||||||
|
|
||||||
cmd = [
|
|
||||||
"ffmpeg",
|
|
||||||
"-re",
|
|
||||||
"-f", "mpegts",
|
|
||||||
"-i", "-",
|
|
||||||
"-c:v", "libx264",
|
|
||||||
"-preset", "veryfast",
|
|
||||||
"-tune", "zerolatency",
|
|
||||||
"-x264-params", "keyint=60:scenecut=0",
|
|
||||||
"-b:v", f"{self.current_bitrate}k",
|
|
||||||
"-maxrate", f"{self.current_bitrate}k",
|
|
||||||
"-bufsize", f"{self.current_bitrate*4}k",
|
|
||||||
"-r", "30",
|
|
||||||
"-g", "60",
|
|
||||||
"-s", "720x1280",
|
|
||||||
"-c:a", "aac",
|
|
||||||
"-b:a", f"{self.audio_bitrate}k",
|
|
||||||
"-ar", "44100",
|
|
||||||
"-ac", "2",
|
|
||||||
"-strict", "-2",
|
|
||||||
"-f", "flv",
|
|
||||||
"-rtmp_live", "live",
|
|
||||||
f"rtmp://a.rtmp.youtube.com/live2/{youtube_key}"
|
|
||||||
]
|
|
||||||
try:
|
|
||||||
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
||||||
self.processes[room_name] = proc
|
|
||||||
|
|
||||||
def read_stderr():
|
|
||||||
while proc.poll() is None:
|
|
||||||
line = proc.stderr.readline()
|
|
||||||
if line:
|
|
||||||
print(f"[{room_name} FFmpeg]: {line.decode(errors='ignore').strip()}")
|
|
||||||
threading.Thread(target=read_stderr, daemon=True).start()
|
|
||||||
|
|
||||||
while not self.stop_flag.is_set():
|
|
||||||
try:
|
|
||||||
data = self.buffer_queue.get(timeout=0.5)
|
|
||||||
try:
|
|
||||||
proc.stdin.write(data)
|
|
||||||
proc.stdin.flush()
|
|
||||||
except (BrokenPipeError, OSError):
|
|
||||||
print(f"[{room_name}] 推流管道断开,准备重启")
|
|
||||||
break
|
|
||||||
except queue.Empty:
|
|
||||||
continue
|
|
||||||
except Exception as e:
|
|
||||||
print(f"[{room_name}] 推流异常: {e}")
|
|
||||||
|
|
||||||
def _abr_thread(self):
|
|
||||||
while not self.stop_flag.is_set():
|
|
||||||
queue_len = self.buffer_queue.qsize()
|
|
||||||
if queue_len > 200:
|
|
||||||
new_bitrate = max(self.min_bitrate, self.current_bitrate - 500)
|
|
||||||
elif queue_len < 20:
|
|
||||||
new_bitrate = min(self.max_bitrate, self.current_bitrate + 500)
|
|
||||||
else:
|
|
||||||
new_bitrate = self.current_bitrate
|
|
||||||
if new_bitrate != self.current_bitrate:
|
|
||||||
print(f"[ABR] 调整码率: {self.current_bitrate}k -> {new_bitrate}k")
|
|
||||||
self.current_bitrate = new_bitrate
|
|
||||||
time.sleep(max(self.check_interval, 10))
|
|
||||||
|
|
||||||
def stop_all(self):
|
|
||||||
print("停止所有推流...")
|
|
||||||
self.stop_flag.set()
|
|
||||||
for proc in self.processes.values():
|
|
||||||
if proc.poll() is None:
|
|
||||||
proc.terminate()
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------- 抖音解析逻辑 -----------------
|
|
||||||
async def get_douyin_real_url(record_url, record_quality="原画"):
|
|
||||||
if 'v.douyin.com' not in record_url and '/user/' not in record_url:
|
|
||||||
json_data = await spider.get_douyin_stream_data(url=record_url)
|
|
||||||
else:
|
|
||||||
json_data = await spider.get_douyin_app_stream_data(url=record_url)
|
|
||||||
port_info = await stream.get_douyin_stream_url(json_data, record_quality, None)
|
|
||||||
return port_info.get("record_url")
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------- 启动推流 -----------------
|
|
||||||
def start_douyin_to_youtube(record_url, youtube_key, room_name=None, delay_sec=40):
|
|
||||||
try:
|
|
||||||
real_url = asyncio.run(get_douyin_real_url(record_url))
|
|
||||||
except Exception as e:
|
|
||||||
print(f"获取真实直播流失败: {e}")
|
|
||||||
return
|
|
||||||
if not real_url:
|
|
||||||
print("获取真实直播流失败")
|
|
||||||
return
|
|
||||||
print(f"实际直播流: {real_url}")
|
|
||||||
hls2yt = AdaptiveHLS2YouTube(delay_sec=delay_sec)
|
|
||||||
hls2yt.start_stream(real_url, youtube_key, room_name)
|
|
||||||
return hls2yt
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------- 控制台监控面板 -----------------
|
|
||||||
def monitor_panel_thread(hls_instance, interval=2, max_width=50):
|
|
||||||
term_width, _ = shutil.get_terminal_size()
|
|
||||||
bar_width = min(max_width, term_width - 30)
|
|
||||||
|
|
||||||
while not hls_instance.stop_flag.is_set():
|
|
||||||
queue_len = hls_instance.buffer_queue.qsize()
|
|
||||||
bitrate = hls_instance.current_bitrate
|
|
||||||
active_push = sum(1 for proc in hls_instance.processes.values() if proc and proc.poll() is None)
|
|
||||||
|
|
||||||
queue_bar_len = min(bar_width, queue_len)
|
|
||||||
queue_bar = "#" * queue_bar_len + "-" * (bar_width - queue_bar_len)
|
|
||||||
|
|
||||||
print("\r", end="")
|
|
||||||
print(f"[监控] 队列: [{queue_bar}] {queue_len:4} | 码率: {bitrate:4}k | 推流进程: {active_push}", end="")
|
|
||||||
time.sleep(interval)
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------- 示例 -----------------
|
|
||||||
if __name__ == "__main__":
|
|
||||||
DOUYIN_URL = "https://live.douyin.com/592179817312"
|
|
||||||
YOUTUBE_KEY = "qxvb-r47b-r5ju-6ud3-6k7z"
|
|
||||||
|
|
||||||
hls_instance = start_douyin_to_youtube(DOUYIN_URL, YOUTUBE_KEY, delay_sec=40)
|
|
||||||
if not hls_instance:
|
|
||||||
print("推流实例创建失败,程序退出")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
threading.Thread(target=monitor_panel_thread, args=(hls_instance,), daemon=True).start()
|
|
||||||
|
|
||||||
def signal_handler(sig, frame):
|
|
||||||
if hls_instance:
|
|
||||||
hls_instance.stop_all()
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, signal_handler)
|
|
||||||
signal.signal(signal.SIGTERM, signal_handler)
|
|
||||||
|
|
||||||
print("程序已启动,按 Ctrl+C 停止...")
|
|
||||||
while True:
|
|
||||||
time.sleep(60)
|
|
||||||
4
list
4
list
@@ -1,4 +0,0 @@
|
|||||||
https://live.douyin.com/525514386431
|
|
||||||
https://live.douyin.com/8687122573
|
|
||||||
https://live.douyin.com/642534242822
|
|
||||||
https://live.douyin.com/589037028237
|
|
||||||
154
live.py
154
live.py
@@ -11,16 +11,15 @@ import shutil
|
|||||||
import spider
|
import spider
|
||||||
import stream
|
import stream
|
||||||
|
|
||||||
|
|
||||||
class AdaptiveHLS2YouTube:
|
class AdaptiveHLS2YouTube:
|
||||||
def __init__(self, max_bitrate=5000, min_bitrate=3000, audio_bitrate=192,
|
def __init__(self, max_bitrate=2500, min_bitrate=1500, audio_bitrate=128,
|
||||||
delay_sec=40, segment_time=2, check_interval=5):
|
delay_sec=30, segment_time=2, check_interval=5):
|
||||||
self.processes = {}
|
self.processes = {}
|
||||||
self.stop_flag = threading.Event()
|
self.stop_flag = threading.Event()
|
||||||
self.delay_sec = delay_sec
|
self.delay_sec = delay_sec
|
||||||
self.segment_time = segment_time
|
self.segment_time = segment_time
|
||||||
self.check_interval = check_interval
|
self.check_interval = check_interval
|
||||||
self.buffer_queue = queue.Queue(maxsize=800)
|
self.buffer_queue = queue.Queue()
|
||||||
self.max_bitrate = max_bitrate
|
self.max_bitrate = max_bitrate
|
||||||
self.min_bitrate = min_bitrate
|
self.min_bitrate = min_bitrate
|
||||||
self.audio_bitrate = audio_bitrate
|
self.audio_bitrate = audio_bitrate
|
||||||
@@ -45,41 +44,22 @@ class AdaptiveHLS2YouTube:
|
|||||||
"-reconnect_at_eof", "1",
|
"-reconnect_at_eof", "1",
|
||||||
"-reconnect_streamed", "1",
|
"-reconnect_streamed", "1",
|
||||||
"-reconnect_delay_max", "10",
|
"-reconnect_delay_max", "10",
|
||||||
"-f", "hls", # 强制 HLS
|
|
||||||
"-i", real_url,
|
"-i", real_url,
|
||||||
"-c", "copy",
|
"-c", "copy",
|
||||||
"-f", "mpegts",
|
"-f", "mpegts",
|
||||||
"-"
|
"-"
|
||||||
]
|
]
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=10**8)
|
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
|
||||||
print("[拉流] FFmpeg 启动成功")
|
print("[拉流] FFmpeg 启动成功")
|
||||||
|
|
||||||
def read_stderr():
|
|
||||||
while proc.poll() is None:
|
|
||||||
try:
|
|
||||||
line = proc.stderr.readline()
|
|
||||||
if not line:
|
|
||||||
continue
|
|
||||||
print(f"[拉流FFmpeg]: {line.decode(errors='ignore').strip()}")
|
|
||||||
except Exception:
|
|
||||||
continue
|
|
||||||
threading.Thread(target=read_stderr, daemon=True).start()
|
|
||||||
|
|
||||||
while not self.stop_flag.is_set():
|
while not self.stop_flag.is_set():
|
||||||
try:
|
data = proc.stdout.read(188*50)
|
||||||
data = proc.stdout.read(188 * 5000)
|
if not data:
|
||||||
if not data:
|
time.sleep(0.05)
|
||||||
time.sleep(0.05)
|
|
||||||
continue
|
|
||||||
self.buffer_queue.put_nowait(data)
|
|
||||||
except queue.Full:
|
|
||||||
continue
|
continue
|
||||||
except Exception as e:
|
self.buffer_queue.put(data)
|
||||||
print(f"[拉流异常] {e}")
|
|
||||||
time.sleep(1)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"拉流进程异常: {e}")
|
print(f"拉流异常: {e}")
|
||||||
|
|
||||||
def _push_thread(self, youtube_key, room_name):
|
def _push_thread(self, youtube_key, room_name):
|
||||||
min_buffer = max(1, self.delay_sec // self.segment_time)
|
min_buffer = max(1, self.delay_sec // self.segment_time)
|
||||||
@@ -96,99 +76,74 @@ class AdaptiveHLS2YouTube:
|
|||||||
"-c:v", "libx264",
|
"-c:v", "libx264",
|
||||||
"-preset", "veryfast",
|
"-preset", "veryfast",
|
||||||
"-tune", "zerolatency",
|
"-tune", "zerolatency",
|
||||||
"-x264-params", "keyint=60:scenecut=0",
|
|
||||||
"-b:v", f"{self.current_bitrate}k",
|
"-b:v", f"{self.current_bitrate}k",
|
||||||
"-maxrate", f"{self.current_bitrate}k",
|
"-maxrate", f"{self.current_bitrate}k",
|
||||||
"-bufsize", f"{self.current_bitrate*4}k",
|
"-bufsize", f"{self.current_bitrate*2}k",
|
||||||
"-r", "30",
|
"-r", "30",
|
||||||
"-g", "60",
|
"-g", "60",
|
||||||
"-s", "720x1280",
|
|
||||||
"-c:a", "aac",
|
"-c:a", "aac",
|
||||||
"-b:a", f"{self.audio_bitrate}k",
|
"-b:a", f"{self.audio_bitrate}k",
|
||||||
"-ar", "44100",
|
"-ar", "44100",
|
||||||
"-ac", "2",
|
"-ac", "2",
|
||||||
"-strict", "-2",
|
|
||||||
"-f", "flv",
|
"-f", "flv",
|
||||||
"-rtmp_live", "live",
|
"-rtmp_live", "live",
|
||||||
f"rtmp://a.rtmp.youtube.com/live2/{youtube_key}"
|
f"rtmp://a.rtmp.youtube.com/live2/{youtube_key}"
|
||||||
]
|
]
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=10**8)
|
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
self.processes[room_name] = proc
|
self.processes[room_name] = proc
|
||||||
|
|
||||||
def read_stderr():
|
def read_stderr():
|
||||||
while proc.poll() is None:
|
while proc.poll() is None:
|
||||||
try:
|
line = proc.stderr.readline()
|
||||||
line = proc.stderr.readline()
|
if line:
|
||||||
if not line:
|
|
||||||
continue
|
|
||||||
print(f"[{room_name} FFmpeg]: {line.decode(errors='ignore').strip()}")
|
print(f"[{room_name} FFmpeg]: {line.decode(errors='ignore').strip()}")
|
||||||
except Exception:
|
|
||||||
continue
|
|
||||||
threading.Thread(target=read_stderr, daemon=True).start()
|
threading.Thread(target=read_stderr, daemon=True).start()
|
||||||
|
|
||||||
while not self.stop_flag.is_set():
|
while not self.stop_flag.is_set():
|
||||||
try:
|
if not self.buffer_queue.empty():
|
||||||
data = self.buffer_queue.get(timeout=0.5)
|
data = self.buffer_queue.get()
|
||||||
if not data:
|
proc.stdin.write(data)
|
||||||
continue
|
proc.stdin.flush()
|
||||||
try:
|
else:
|
||||||
proc.stdin.write(data)
|
time.sleep(0.01)
|
||||||
proc.stdin.flush()
|
|
||||||
except (BrokenPipeError, OSError):
|
|
||||||
print(f"[{room_name}] 推流管道断开,准备重启")
|
|
||||||
break
|
|
||||||
except queue.Empty:
|
|
||||||
continue
|
|
||||||
except Exception as e:
|
|
||||||
print(f"[{room_name}] 推流异常: {e}")
|
|
||||||
break
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[{room_name}] 推流进程启动失败: {e}")
|
print(f"[{room_name}] 推流异常: {e}")
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
def _abr_thread(self):
|
def _abr_thread(self):
|
||||||
while not self.stop_flag.is_set():
|
while not self.stop_flag.is_set():
|
||||||
try:
|
queue_len = self.buffer_queue.qsize()
|
||||||
queue_len = self.buffer_queue.qsize()
|
if queue_len > 100:
|
||||||
if queue_len > 200:
|
new_bitrate = max(self.min_bitrate, self.current_bitrate - 300)
|
||||||
new_bitrate = max(self.min_bitrate, self.current_bitrate - 500)
|
elif queue_len < 30:
|
||||||
elif queue_len < 20:
|
new_bitrate = min(self.max_bitrate, self.current_bitrate + 300)
|
||||||
new_bitrate = min(self.max_bitrate, self.current_bitrate + 500)
|
else:
|
||||||
else:
|
new_bitrate = self.current_bitrate
|
||||||
new_bitrate = self.current_bitrate
|
if new_bitrate != self.current_bitrate:
|
||||||
if new_bitrate != self.current_bitrate:
|
print(f"[ABR] 调整码率: {self.current_bitrate}k -> {new_bitrate}k")
|
||||||
print(f"[ABR] 调整码率: {self.current_bitrate}k -> {new_bitrate}k")
|
self.current_bitrate = new_bitrate
|
||||||
self.current_bitrate = new_bitrate
|
time.sleep(self.check_interval)
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
time.sleep(max(self.check_interval, 10))
|
|
||||||
|
|
||||||
def stop_all(self):
|
def stop_all(self):
|
||||||
print("停止所有推流...")
|
print("停止所有推流...")
|
||||||
self.stop_flag.set()
|
self.stop_flag.set()
|
||||||
for proc in self.processes.values():
|
for proc in self.processes.values():
|
||||||
try:
|
if proc.poll() is None:
|
||||||
if proc and proc.poll() is None:
|
proc.terminate()
|
||||||
proc.terminate()
|
|
||||||
except Exception:
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------- 抖音解析逻辑 -----------------
|
||||||
async def get_douyin_real_url(record_url, record_quality="原画"):
|
async def get_douyin_real_url(record_url, record_quality="原画"):
|
||||||
try:
|
if 'v.douyin.com' not in record_url and '/user/' not in record_url:
|
||||||
if 'v.douyin.com' not in record_url and '/user/' not in record_url:
|
json_data = await spider.get_douyin_stream_data(url=record_url)
|
||||||
json_data = await spider.get_douyin_stream_data(url=record_url)
|
else:
|
||||||
else:
|
json_data = await spider.get_douyin_app_stream_data(url=record_url)
|
||||||
json_data = await spider.get_douyin_app_stream_data(url=record_url)
|
port_info = await stream.get_douyin_stream_url(json_data, record_quality, None)
|
||||||
port_info = await stream.get_douyin_stream_url(json_data, record_quality, None)
|
return port_info.get("record_url")
|
||||||
return port_info.get("record_url")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"获取抖音真实地址失败: {e}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def start_douyin_to_youtube(record_url, youtube_key, room_name=None, delay_sec=40):
|
# ----------------- 启动推流 -----------------
|
||||||
|
def start_douyin_to_youtube(record_url, youtube_key, room_name=None, delay_sec=30):
|
||||||
try:
|
try:
|
||||||
real_url = asyncio.run(get_douyin_real_url(record_url))
|
real_url = asyncio.run(get_douyin_real_url(record_url))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -203,31 +158,30 @@ def start_douyin_to_youtube(record_url, youtube_key, room_name=None, delay_sec=4
|
|||||||
return hls2yt
|
return hls2yt
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------- 控制台监控面板 -----------------
|
||||||
def monitor_panel_thread(hls_instance, interval=2, max_width=50):
|
def monitor_panel_thread(hls_instance, interval=2, max_width=50):
|
||||||
term_width, _ = shutil.get_terminal_size(fallback=(80, 20))
|
term_width, _ = shutil.get_terminal_size()
|
||||||
bar_width = min(max_width, term_width - 30)
|
bar_width = min(max_width, term_width - 30)
|
||||||
|
|
||||||
while not hls_instance.stop_flag.is_set():
|
while not hls_instance.stop_flag.is_set():
|
||||||
try:
|
queue_len = hls_instance.buffer_queue.qsize()
|
||||||
queue_len = hls_instance.buffer_queue.qsize()
|
bitrate = hls_instance.current_bitrate
|
||||||
bitrate = hls_instance.current_bitrate
|
active_push = any(proc and proc.poll() is None for proc in hls_instance.processes.values())
|
||||||
active_push = sum(1 for proc in hls_instance.processes.values() if proc and proc.poll() is None)
|
|
||||||
|
|
||||||
queue_bar_len = min(bar_width, queue_len)
|
queue_bar_len = min(bar_width, queue_len)
|
||||||
queue_bar = "#" * queue_bar_len + "-" * (bar_width - queue_bar_len)
|
queue_bar = "#" * queue_bar_len + "-" * (bar_width - queue_bar_len)
|
||||||
|
|
||||||
print("\r", end="")
|
print("\r", end="")
|
||||||
print(f"[监控] 队列: [{queue_bar}] {queue_len:4} | 码率: {bitrate:4}k | 推流进程: {active_push}", end="")
|
print(f"[监控] 队列: [{queue_bar}] {queue_len:4} | 码率: {bitrate:4}k | 推流活跃: {active_push}", end="")
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
time.sleep(interval)
|
time.sleep(interval)
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------- 示例 -----------------
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
DOUYIN_URL = "https://live.douyin.com/97282309368"
|
DOUYIN_URL = "https://live.douyin.com/848698179845"
|
||||||
YOUTUBE_KEY = "qxvb-r47b-r5ju-6ud3-6k7z"
|
YOUTUBE_KEY = "qxvb-r47b-r5ju-6ud3-6k7z"
|
||||||
|
|
||||||
hls_instance = start_douyin_to_youtube(DOUYIN_URL, YOUTUBE_KEY, delay_sec=40)
|
hls_instance = start_douyin_to_youtube(DOUYIN_URL, YOUTUBE_KEY, delay_sec=30)
|
||||||
if not hls_instance:
|
if not hls_instance:
|
||||||
print("推流实例创建失败,程序退出")
|
print("推流实例创建失败,程序退出")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user