Sfoglia il codice sorgente

update to current status

David 9 anni fa
parent
commit
ea8e3db374
6 ha cambiato i file con 14 aggiunte e 99 eliminazioni
  1. 0 53
      camera1/cam-to-udp.sh
  2. 6 23
      camera1/cam.py
  3. 3 1
      camera1/fb-to-udp.sh
  4. 0 17
      camera1/mic-to-udp.sh
  5. 1 1
      camera1/play-cam2.sh
  6. 4 4
      camera1/restart-servo.py

+ 0 - 53
camera1/cam-to-udp.sh

@@ -1,53 +0,0 @@
-#!/bin/bash
-
-HOST="224.1.1.1"
-HOST="192.168.2.255"
-set -e
-
-fps=24
-gop=$((fps*2))
-qp=12
-
-w=1296
-h=972
-
-w=800
-h=600
-
-roi="roi-x=0.00 roi-y=0 roi-w=1.00 roi-h=1.00"
-bitrate=600000
-
-novideo="-n"
-PREVIEW="preview=0"
-
-while [ $# -gt 0 ]; do
-	if [ "$1" == "proj" ]; then
-		echo "proj!"
-		novideo=""
-		PREVIEW="preview=1 preview-encoded=0"
-	fi
-	if [ "$1" == "trat" ]; then
-		echo "trat!"
-		roitrat="roi-x=0.12 roi-y=0.12 roi-w=0.75 roi-h=0.75"
-		roitrat="roi-x=0.25 roi-y=0.25 roi-w=0.50 roi-h=0.50"
-		roitrat="roi-x=0.19 roi-y=0.19 roi-w=0.62 roi-h=0.62"
-		roi=$roitrat
-	fi
-	shift
-done
-
-#raspivid $novideo -roi $roi -vs -ih -rot 125 -pf high -t 0 -awb fluorescent --brightness 55 -w $w -h $h -fps $fps -g $gop -qp $qp -o - |
-#	gst-launch-1.0 -v -e fdsrc do-timestamp=1 ! h264parse ! rtph264pay config-interval=10 pt=96 ! udpsink host=$1 port=5000
-
-FORMAT="video/x-h264, width=$w, height=$h, framerate=24/1, profile=high"
-#annotation-mode=0x8 
-rotation=180
-
-HOST="192.168.2.120:5000,192.168.2.155:5000,192.168.2.68:5000"
-echo gst-launch-1.0 rpicamsrc rotation=$rotation $PREVIEW $roi bitrate=$bitrate do-timestamp=true ! queue ! $FORMAT ! h264parse ! rtph264pay config-interval=1 ! multiudpsink clients=$HOST
-     gst-launch-1.0 rpicamsrc rotation=$rotation $PREVIEW $roi bitrate=$bitrate do-timestamp=true ! queue ! $FORMAT ! h264parse ! rtph264pay config-interval=1 ! multiudpsink clients=$HOST
-#echo gst-launch-1.0 rpicamsrc rotation=$rotation $PREVIEW $roi bitrate=$bitrate do-timestamp=true ! queue ! $FORMAT ! h264parse ! rtph264pay config-interval=1 ! udpsink host=$HOST port=5000
-#     gst-launch-1.0 rpicamsrc rotation=$rotation $PREVIEW $roi bitrate=$bitrate do-timestamp=true ! queue ! $FORMAT ! h264parse ! rtph264pay config-interval=1 ! udpsink host=$HOST port=5000
-
-#echo gst-launch-1.0 rpicamsrc rotation=$rotation $PREVIEW $roi bitrate=$bitrate do-timestamp=true ! queue ! $FORMAT ! h264parse ! rtph264pay config-interval=1 ! udpsink host=$HOST auto-multicast=true port=5000
-#     gst-launch-1.0 rpicamsrc rotation=$rotation $PREVIEW $roi bitrate=$bitrate do-timestamp=true ! queue ! $FORMAT ! h264parse ! rtph264pay config-interval=1 ! udpsink host=$HOST auto-multicast=true port=5000

+ 6 - 23
camera1/cam.py

@@ -57,19 +57,7 @@ def set_zoom(target):
 		videosrc.set_property("roi-h", zoom)
 		time.sleep(0.03)
 
-def add_client(c):
-	if "192.168" not in c or ":" not in c:
-		print("Invalid client! format is 192.168.Y.Z:XXXX")
-		return
-	cur_clients=sink.get_property("clients").split(",")
-	print(cur_clients)
-	if c in cur_clients:
-		print("Client exists!")
-		return
-	cur_clients.append(c)
-	strclients = ",".join(cur_clients)
-	sink.set_property("clients", strclients)
-	
+
 def control():
 	FIFO="/tmp/picamfifo"
 	if os.path.exists(FIFO):
@@ -97,9 +85,6 @@ def control():
 			if key == "zoom":
 				set_zoom(float(val))
 
-			if key == "client" :
-				add_client(val)
-
 			
 if __name__ == "__main__":
 	if 'LD_LIBRARY_PATH' not in os.environ:
@@ -108,8 +93,9 @@ if __name__ == "__main__":
 	# initialization
 	Gst.init(None)
 
-	videocodec = "queue ! video/x-h264, width=%d, height=%d, framerate=25/1, profile=high ! h264parse ! rtph264pay mtu=1360 config-interval=1" % (WIDTH, HEIGHT)
-	p = "rpicamsrc sensor-mode=4 do-timestamp=true name=src ! "+videocodec+" ! multiudpsink name=out"
+	videocodec = "video/x-h264, width=%d, height=%d, framerate=25/1, profile=high ! h264parse" % (WIDTH, HEIGHT)
+	p = "rpicamsrc sensor-mode=4 do-timestamp=true name=src ! "+videocodec+" ! matroskamux ! tcpserversink host=0.0.0.0 port=5000 sync-method=burst-keyframe"
+	print(p)
 	pipeline = Gst.parse_launch (p)
 	if pipeline == None:
 		print ("Failed to create pipeline")
@@ -120,14 +106,11 @@ if __name__ == "__main__":
 	videosrc.set_property("preview-w", WIDTH)
 	videosrc.set_property("preview-h", HEIGHT)
 	videosrc.set_property("fullscreen", False)
-	videosrc.set_property("bitrate", 16000000)
+	# videosrc.set_property("bitrate", 16000000)
+	videosrc.set_property("bitrate", 25000000)
 	videosrc.set_property("rotation", 180)
 	set_preview(0)
 
-	sink = pipeline.get_by_name ("out")
-	# sink.set_property("clients", ",".join(["192.168.2.120:5000", "192.168.2.21:5000", "192.168.2.84:5000"]))
-	sink.set_property("clients", ",".join(["192.168.2.21:5000"]))
-	print(sink.get_property("clients"))
 
 	# run
 	pipeline.set_state(Gst.State.PLAYING)

+ 3 - 1
camera1/fb-to-udp.sh

@@ -2,6 +2,7 @@
 
 HOST="192.168.2.84"
 HOST="192.168.2.21"
+HOST="192.168.2.123"
 #5001"
 #HOST="192.168.1.7:5001"
 #HOST="192.168.20.2:5001"
@@ -14,7 +15,8 @@ HOST="192.168.2.21"
 #~/code/telepi/telepi - | pv | netcat $HOST 5001
 while [ true ]; do
     date
-	~/code/telepi/telepi - 2>/dev/null | netcat $HOST 5001
+	#~/code/telepi/telepi - 2>/dev/null | netcat $HOST 5001
+	~/code/telepi/telepi - 2>/dev/null | nc $HOST 5001
 	sleep 3
 	echo "the fb grabber died"
 done

+ 0 - 17
camera1/mic-to-udp.sh

@@ -1,17 +0,0 @@
-#!/bin/bash
-
-HOST="224.1.1.1"
-HOST="192.168.2.255"
-enc="vorbisenc"
-enc="volume volume=0.8 ! mulawenc ! rtppcmupay"
-enc="opusenc ! rtpopuspay"
-# 
-SRC="audiotestsrc wave=sine freq=400 "
-SRC="alsasrc slave-method=resample do-timestamp=true"
-
-HOST="192.168.1.7:5001"
-HOST="192.168.2.120:5001"
-#HOST="192.168.2.120:5001,192.168.2.155:5001" #,192.168.2.68:5001"
-
-echo gst-launch-1.0 $SRC ! audioconvert ! audioresample ! $enc ! multiudpsink clients=$HOST
-gst-launch-1.0 $SRC ! audioconvert ! audioresample ! $enc ! multiudpsink clients=$HOST

+ 1 - 1
camera1/play-cam2.sh

@@ -1 +1 @@
-LD_LIBRARY_PATH=/usr/local/lib  gst-launch-1.0 -ve udpsrc port=5002 do-timestamp=true ! queue ! application/x-rtp, payload=96 ! rtpjitterbuffer latency=20 ! rtph264depay ! h264parse ! omxh264dec! queue ! glimagesink 
+LD_LIBRARY_PATH=/usr/local/lib gst-launch-1.0 -qe udpsrc port=5002 do-timestamp=true ! application/x-rtp, payload=96 ! rtpjitterbuffer latency=50 ! rtph264depay ! h264parse ! omxh264dec ! glimagesink 

+ 4 - 4
camera1/restart-servo.py

@@ -8,15 +8,15 @@ min=900
 max=1750
 
 servo = 0
-percentage = 75
+percentage = 66
 filename = "/tmp/servo_%d" % servo
 print("%d=%d%%" % (servo, percentage) , file=servoblaster)
 print( int((max-min) * (percentage/100)) + min, file=open(filename, "w") )
 
-servoblaster.flush()
-sleep(0.5)
+#servoblaster.flush()
+#sleep(0.2)
 servo = 1
-percentage = 55
+percentage = 61
 filename = "/tmp/servo_%d" % servo
 print("%d=%d%%" % (servo, percentage) , file=servoblaster)
 print( int((max-min) * (percentage/100)) + min, file=open(filename, "w") )