From df8d12d0f26201d8e266beed28e91c1f7730daa2 Mon Sep 17 00:00:00 2001 From: Florian Schlegel Date: Wed, 12 Aug 2020 02:45:03 +0200 Subject: [PATCH] neue Startscripte begonnen --- cam1/start.sh | 42 ++++++++++++++++++++++++++ {cam2 => cam2_alt}/Start.sh | 0 {cam2 => cam2_alt}/interfaces | 0 terminal1/{Start.sh => Start_alt.sh} | 0 terminal1/start.sh | 45 ++++++++++++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100755 cam1/start.sh rename {cam2 => cam2_alt}/Start.sh (100%) rename {cam2 => cam2_alt}/interfaces (100%) rename terminal1/{Start.sh => Start_alt.sh} (100%) create mode 100755 terminal1/start.sh diff --git a/cam1/start.sh b/cam1/start.sh new file mode 100755 index 0000000..cfd5671 --- /dev/null +++ b/cam1/start.sh @@ -0,0 +1,42 @@ +#! /bin/bash + +trap do_exit INT + +PIDS="" +do_exit() { + kill $PIDS >/dev/null 2>&1 + sleep 10 + kill -9 $PIDS >/dev/null 2>&1 + pkill -9 gst-launch-1.0 +} + +v4l2-ctl -d /dev/video0 --set-ctrl=power_line_frequency=1 + +# provide video stream +( + while true; do + gst-launch-1.0 -e rtpbin name=b rtp-profile=avpf uvch264src device=/dev/video0 name=src auto-start=true src.vidsrc ! video/x-raw,framerate=30/1,profile=high ! videoscale ! video/x-raw,width=1920,height=1080 ! videoconvert ! x264enc tune=zerolatency bitrate=7000 speed-preset=superfast key-int-max=15 ! rtph264pay ! rtpulpfecenc percentage=50 percentage-important=75 ! rtprtxqueue max-size-packets=1000 ! b.send_rtp_sink_0 b.send_rtp_src_0 ! udpsink host=terminal1 port=5001 udpsrc address=:: port=5002 ! b.recv_rtcp_sink_0 b.send_rtcp_src_0 ! udpsink host=terminal1 port=5003 sync=false async=false + sleep 1 + done +) & +PIDS="$PIDS $!" + +# send audio stream +( + while true; do + gst-launch-1.0 alsasrc device=plughw:2,0 ! audioconvert ! audioresample ! opusenc ! rtpopuspay ! udpsink host=terminal2 port=5003 + sleep 1 + done +) & +PIDS="$PIDS $!" + +# receive audio stream +( + while true; do + gst-launch-1.0 udpsrc port=5002 caps="application/x-rtp" ! rtpjitterbuffer latency=20 do-lost=True ! rtpopusdepay ! opusdec plc=true ! alsasink device=hw:1 + sleep 1 + done +) & +PIDS="$PIDS $!" + +wait $PIDS diff --git a/cam2/Start.sh b/cam2_alt/Start.sh similarity index 100% rename from cam2/Start.sh rename to cam2_alt/Start.sh diff --git a/cam2/interfaces b/cam2_alt/interfaces similarity index 100% rename from cam2/interfaces rename to cam2_alt/interfaces diff --git a/terminal1/Start.sh b/terminal1/Start_alt.sh similarity index 100% rename from terminal1/Start.sh rename to terminal1/Start_alt.sh diff --git a/terminal1/start.sh b/terminal1/start.sh new file mode 100755 index 0000000..99e9dda --- /dev/null +++ b/terminal1/start.sh @@ -0,0 +1,45 @@ +#! /bin/bash + +trap do_exit INT + +PIDS="" +do_exit() { + kill $PIDS >/dev/null 2>&1 + sleep 10 + kill -9 $PIDS >/dev/null 2>&1 + pkill -9 gst-launch-1.0 +} + +export DISPLAY=:0 +(sleep 60; export DISPLAY=:0; xset s off; xset -dpms; xset s noblank) & + +# receive video stream from cam1 +( + while true; do + gst-launch-1.0 -e rtpbin name=b rtp-profile=avpf do-retransmission=true \ + udpsrc address=:: port=5001 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! b.recv_rtp_sink_0 b. ! rtpulpfecdec ! rtph264depay ! decodebin ! videoconvert ! videoscale ! video/x-raw,width=1024,height=786 ! glimagesink \ + udpsrc address=:: port=5003 ! b.recv_rtcp_sink_0 \ + b.send_rtcp_src_0 ! udpsink host=cam1 port=5002 sync=false async=false & + GSTPID=$! + + while true; do + # rename window (FIXME: possible race condition with window for cam 2) + GSTXID="$(wmctrl -l | grep "OpenGL renderer" | cut -d" " -f1)" >/dev/null 2>&1 + wmctrl -i -r "$GSTXID" -e 0,0,0,1000,1000 >/dev/null 2>&1 + # wmctrl -i -r "$GSTXID" -e 0,1500,0,1000,1000 >/dev/null 2>&1 + wmctrl -i -r "$GSTXID" -b add,fullscreen >/dev/null 2>&1 + wmctrl -i -r "$GSTXID" -b add,above >/dev/null 2>&1 + wmctrl -i -r "$GSTXID" -N gst-cam1 >/dev/null 2>&1 && break + kill -s 0 $GSTPID || break + sleep .2 + done + + wait $GSTPID + sleep .2 + done +) & +PIDS="$PIDS $!" + + + +wait $PIDS