Added working tcp stream. Only issue is that it stops after a couple of minutes

This commit is contained in:
2026-05-20 12:30:55 +02:00
parent 6bdfeb68db
commit 269ff4ee2f
3 changed files with 37 additions and 3 deletions
+8 -2
View File
@@ -15,12 +15,13 @@ load_config() {
[ -f "$CONFIG_FILE" ] || return
SOURCE_TYPE=$(grep -o '"source_type":"[^"]*"' "$CONFIG_FILE" 2>/dev/null | cut -d'"' -f4)
RTSP_URL=$(grep -o '"rtsp_url":"[^"]*"' "$CONFIG_FILE" 2>/dev/null | cut -d'"' -f4)
TCP_URL=$(grep -o '"tcp_url":"[^"]*"' "$CONFIG_FILE" 2>/dev/null | cut -d'"' -f4)
MP4_PATH=$(grep -o '"mp4_path":"[^"]*"' "$CONFIG_FILE" 2>/dev/null | cut -d'"' -f4)
RES_W=$(grep -o '"res_w":[0-9]*' "$CONFIG_FILE" 2>/dev/null | cut -d: -f2)
RES_H=$(grep -o '"res_h":[0-9]*' "$CONFIG_FILE" 2>/dev/null | cut -d: -f2)
FPS=$(grep -o '"fps":[0-9]*' "$CONFIG_FILE" 2>/dev/null | cut -d: -f2)
ROTATION=$(grep -o '"rotation":[0-9]*' "$CONFIG_FILE" 2>/dev/null | cut -d: -f2)
: ${SOURCE_TYPE:=mp4} ${RTSP_URL:=rtsp://192.168.1.100:8554/stream}
: ${SOURCE_TYPE:=mp4} ${RTSP_URL:=rtsp://192.168.1.100:8554/stream} ${TCP_URL:=tcp://192.168.1.100:5000}
: ${MP4_PATH:=/sdcard/Movies/2.mp4} ${RES_W:=1920} ${RES_H:=1080} ${FPS:=30} ${ROTATION:=0}
}
@@ -128,6 +129,11 @@ case "${1:-help}" in
nohup "$FF" -rtsp_transport tcp -i "$RTSP_URL" \
-vf "${VFILTER}scale=${RES_W}:${RES_H},fps=${FPS:-30}" \
-f v4l2 -pix_fmt yuv420p /dev/video0 > /dev/null 2>&1 &
elif [ "$SOURCE_TYPE" = "tcp" ]; then
nohup "$FF" -fflags nobuffer -flags low_delay -analyzeduration 0 -use_wallclock_as_timestamps 1 \
-i "$TCP_URL" \
-vf "${VFILTER}scale=${RES_W}:${RES_H},fps=${FPS:-30}" \
-f v4l2 -pix_fmt yuv420p /dev/video0 > /dev/null 2>&1 &
elif [ "$SOURCE_TYPE" = "mp4" ] && [ -f "$MP4_PATH" ]; then
nohup "$FF" -stream_loop -1 -re -i "$MP4_PATH" \
-vf "${VFILTER}scale=${RES_W}:${RES_H},fps=${FPS:-30}" \
@@ -150,7 +156,7 @@ case "${1:-help}" in
;;
get_config)
load_config
echo "{\"source_type\":\"$SOURCE_TYPE\",\"rtsp_url\":\"$RTSP_URL\",\"mp4_path\":\"$MP4_PATH\",\"res_w\":${RES_W:-1920},\"res_h\":${RES_H:-1080},\"fps\":${FPS:-30},\"rotation\":${ROTATION:-0}}"
echo "{\"source_type\":\"$SOURCE_TYPE\",\"rtsp_url\":\"$RTSP_URL\",\"tcp_url\":\"$TCP_URL\",\"mp4_path\":\"$MP4_PATH\",\"res_w\":${RES_W:-1920},\"res_h\":${RES_H:-1080},\"fps\":${FPS:-30},\"rotation\":${ROTATION:-0}}"
;;
validate)
PROVIDER_PID=$(pgrep -f "/virtual_camera_provider" | head -1)