#!/bin/bash

gst-launch-1.0 -e \
rtspsrc location=rtsp://admin:quopin1234@115.94.118.69/Streaming/Channels/101 latency=200 protocols=tcp ! queue ! \
rtph264depay ! h264parse config-interval=-1 ! \
v4l2h264dec capture-io-mode=4 ! queue ! \
v4l2h264enc output-io-mode=5 \
extra-controls='controls,video_bitrate_mode=0,video_bitrate=2000000,vbv_buffer_size=3000,frame_level_rate_control_enable=1,video_gop_size=30,h264_mb_level_rate_control=1' ! \
h264parse config-interval=1 ! rtph264pay pt=96 config-interval=1 ! \
udpsink host=192.168.1.156 port=8000 sync=false &
PID1=$!
gst-launch-1.0 -e \
rtspsrc location=rtsp://admin:quopin1234@115.94.118.69/Streaming/Channels/102 latency=200 protocols=tcp ! queue ! \
rtph264depay ! h264parse config-interval=-1 ! \
v4l2h264dec capture-io-mode=4 ! queue ! \
v4l2h264enc output-io-mode=5 \
extra-controls='controls,video_bitrate_mode=0,video_bitrate=2000000,vbv_buffer_size=3000,frame_level_rate_control_enable=1,video_gop_size=30,h264_mb_level_rate_control=1' ! \
h264parse config-interval=1 ! rtph264pay pt=96 config-interval=1 ! \
udpsink host=192.168.1.156 port=9000 sync=false &
PID2=$!

echo "both pipelines are running"
echo "Pipeline 1 rtsp stream101 PID: $PID1"
echo "Pipeline 2 rtsp stream102 PID: $PId2"

echo "Press Ctrl+C to stop the pipelines"

wait
