-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathimx296_gst.sh
executable file
·44 lines (41 loc) · 1.64 KB
/
imx296_gst.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/bash
#
# Streams one cameras using Gstreamer.
#
# Set the type of output
# Default to screen (will fail if connected over SSH)
#
# Override on the command line with (for example):
#
# OUTPUT=file ./imx296_gst.sh
#
# Valid values: file, rtsp or screen
OUTPUT=${OUTPUT:-screen}
camera_num=${WHICH_CAMERA:-0}
. imx296_constants.sh
if [ $OUTPUT == "rtsp" ]; then
# This asumes a mediamtx instance is already running on the nano:
#
# docker run --rm -it --network=host bluenviron/mediamtx:latest
#
# The stream can then be played with an RTSP client on a desktop, for example:
#
# ffplay -rtsp_transport udp rtsp://<ip address of nano>:8554/mono
#
# Note this requires "h264parse" which is in gstreamer1.0-plugins-bad
# and "rtspclientsink" which is in gstreamer1.0-rtsp
#
# which might need to be installed: sudo apt-get install -y gstreamer1.0-rtsp gstreamer1.0-plugins-bad
#
GST_OUTPUT="x264enc speed-preset=veryfast tune=zerolatency ! h264parse ! rtspclientsink location=rtsp://localhost:8554/mono"
elif [ $OUTPUT == "screen" ]; then
# Output to the screen
GST_OUTPUT="nveglglessink"
elif [ $OUTPUT == "file" ]; then
# Save to a file
GST_OUTPUT="x264enc speed-preset=veryfast tune=zerolatency ! \
h264parse ! mp4mux ! filesink location=test.mp4 -e"
fi
gst-launch-1.0 -ev nvarguscamerasrc sensor-id=$camera_num $NVARGUS_CONFIG ! \
"video/x-raw(memory:NVMM),width=$IMG_WIDTH,height=$IMG_HEIGHT,framerate=$IMG_RATE/1" ! \
nvvidconv ! 'video/x-raw' ! queue ! $GST_OUTPUT