# -*- coding: utf-8 -*- """Publish a short test stream to SRS and confirm HTTPS FLV proxy responds.""" from __future__ import annotations import time import paramiko c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect( "82.157.112.245", username="ubuntu", password="Xiao4669805", timeout=60, allow_agent=False, look_for_keys=False, ) cmd = r""" set -e # ffmpeg available? which ffmpeg || sudo apt-get install -y -qq ffmpeg >/tmp/ffinstall.log 2>&1 || true which ffmpeg # publish 8s color bars in background nohup ffmpeg -re -f lavfi -i color=c=black:s=320x240:d=12 -f lavfi -i sine=f=440:d=12 \ -c:v libx264 -tune zerolatency -preset ultrafast -pix_fmt yuv420p -g 30 \ -c:a aac -f flv rtmp://127.0.0.1/live/smoke_test \ >/tmp/ff_push.log 2>&1 & FFPID=$! echo "ffmpeg pid $FFPID" sleep 3 echo '=== local flv code ===' curl -s --max-time 4 -o /tmp/chunk.flv -w 'local %{http_code} size %{size_download}\n' \ 'http://127.0.0.1:1985/live/smoke_test.flv' || true file /tmp/chunk.flv 2>/dev/null || ls -la /tmp/chunk.flv echo '=== public flv code ===' curl -sk --max-time 4 -o /tmp/chunk2.flv -D /tmp/chunk2.hdr -w 'public %{http_code} size %{size_download}\n' \ 'https://nomadro.cn/live/smoke_test.flv' || true head -20 /tmp/chunk2.hdr || true ls -la /tmp/chunk2.flv || true kill $FFPID 2>/dev/null || true sleep 1 tail -5 /tmp/ff_push.log || true """ _, stdout, _ = c.exec_command(cmd, timeout=180, get_pty=True) while not stdout.channel.exit_status_ready(): if stdout.channel.recv_ready(): print(stdout.channel.recv(65536).decode("utf-8", "replace"), end="", flush=True) time.sleep(0.05) while stdout.channel.recv_ready(): print(stdout.channel.recv(65536).decode("utf-8", "replace"), end="", flush=True) print("[exit", stdout.channel.recv_exit_status(), "]", flush=True) c.close()