README covers YouTube RTMPS relay, time-slot mode, ops/Netdata, and global SOCKS plan. Relay pipeline keeps FFmpeg alive across probe flicker, stabilizes time-slot source selection, and fixes misleading start-button copy in the UI. Co-authored-by: Cursor <cursoragent@cursor.com>
52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
from app.youtube_relay import build_ffmpeg_relay_cmd
|
|
from app.youtube_relay_presets import (
|
|
DEFAULT_RELAY_QUALITY_PRESET,
|
|
VPS_4C_RELAY_QUALITY_PRESET,
|
|
resolve_relay_encoding,
|
|
)
|
|
|
|
|
|
def test_default_preset_is_720p():
|
|
enc = resolve_relay_encoding({})
|
|
assert enc["preset_id"] == DEFAULT_RELAY_QUALITY_PRESET
|
|
assert enc["width"] == 720
|
|
assert enc["height"] == 1280
|
|
assert enc["fps"] == 30
|
|
assert enc["x264_preset"] == "veryfast"
|
|
|
|
|
|
def test_vps_ultra_preset_low_cpu():
|
|
enc = resolve_relay_encoding({"youtube_relay_quality_preset": VPS_4C_RELAY_QUALITY_PRESET})
|
|
assert enc["preset_id"] == "vps_ultra"
|
|
assert enc["width"] == 480
|
|
assert enc["height"] == 854
|
|
assert enc["fps"] == 24
|
|
assert enc["x264_preset"] == "ultrafast"
|
|
assert enc["bitrate_kbps"] == 1500
|
|
assert enc["x264_threads"] == 2
|
|
|
|
|
|
def test_ffmpeg_cmd_uses_preset_params():
|
|
cmd = build_ffmpeg_relay_cmd(
|
|
"http://example.com/a.flv",
|
|
"rtmps://a.rtmps.youtube.com/live2/key",
|
|
bitrate_kbps=1500,
|
|
width=480,
|
|
height=854,
|
|
fps=24,
|
|
x264_preset="ultrafast",
|
|
gop=48,
|
|
profile="main",
|
|
level="3.1",
|
|
audio_bitrate_kbps=96,
|
|
x264_threads=2,
|
|
scale_flags="fast_bilinear",
|
|
)
|
|
joined = " ".join(cmd)
|
|
assert "ultrafast" in joined
|
|
assert "-threads 2" in joined
|
|
assert "96k" in joined
|
|
assert "fps=24,scale=480:854" in joined
|