jetson gstream

# プラグインの動作確認
gst-inspect-1.0 プラグイン名の出力でプラグインの仕様を表示できる。
```
gst-inspect-1.0 nvvidconv
```

# csi cameraをソースに指定する
nvarguscamerasrc

gst-launch-1.0 nvarguscamerasrc \
! autovideosink

# 90度回転
参照:[NVIDIA Jetson Nano GStreamer example pipelines for video transforming](https://developer.ridgerun.com/wiki/index.php?title=Jetson_Nano/Gstreamer/Example_Pipelines/Streaming)

```
gst-launch-1.0 nvarguscamerasrc \
! 'video/x-raw(memory:NVMM)\
, width=640\
, height=480\
, format=NV12\
, framerate=30/1' \
!  nvvidconv flip-method=clockwise \
!  nvoverlaysink
```

# 180度回転
```
gst-launch-1.0 nvarguscamerasrc \
sensor-id=1 \
! 'video/x-raw(memory:NVMM)\
, width=640\
, height=480\
, format=NV12\
, framerate=30/1' \
!  nvvidconv flip-method=rotate-180 \
!  nvoverlaysink
```

# csiカメラを指定する
```
gst-launch-1.0 nvarguscamerasrc sensor-id=1 \
! autovideosink
```

# file出力
```
gst-launch-1.0 filesrc location=output.mp4 \
! qtdemux name=demux ! h264parse ! omxh264dec ! nvvidconv flip-method=1 ! 'video/x- raw(memory:NVMM), format=(string)I420' ! nveglglessink 
```

# csiカメラ入力、Tを使用して、output.mp4出力と、Xwindow出力
参照:[Jetsonビデオ処理プログラミング](https://www.macnica.co.jp/business/semiconductor/articles/nvidia/137049/)
参照:[MACNICA-CLAVIS-NV/nvgst-venc-pipes](https://github.com/MACNICA-CLAVIS-NV/nvgst-venc-pipes)

```
gst-launch-1.0 -e nvarguscamerasrc sensor-id=1 \
! "video/x-raw(memory:NVMM), format=(string)NV12" ! tee name=t t. \
! queue \
! nvv4l2h264enc \
 bitrate=4000000 \
 control-rate=1 \
 iframeinterval=30 \
 bufapi-version=false \
 peak-bitrate=0 \
 quant-i-frames=4294967295 \
 quant-p-frames=4294967295 \
 quant-b-frames=4294967295 \
 preset-level=1 \
 qp-range="0,51:0,51:0,51" \
 vbv-size=4000000 \
 MeasureEncoderLatency=false \
 ratecontrol-enable=true \
 maxperf-enable=false idrinterval=256 \
 profile=0 insert-vui=false \
 insert-sps-pps=false \
 insert-aud=false \
 num-B-Frames=0 \
 disable-cabac=false \
 bit-packetization=false \
 SliceIntraRefreshInterval=0 \
 EnableTwopassCBR=false \
 EnableMVBufferMeta=false \
 slice-header-spacing=0 \
 num-Ref-Frames=1 poc-type=0 \
! h264parse \
! qtmux \
! filesink location=output.mp4 t. \
! queue \
! nvegltransform \
! nveglglessink
```

# ファイル保存
FILE=videotestsrc.mp4
gst-launch-1.0 videotestsrc is-live=true ! video/x-raw, format=I420,width=1920, height=1080 ! omxh264enc ! qtmux ! filesink location=$FILE -e

FILE=filename.mp4
gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM), width=1920, height=1080,format=NV12, framerate=30/1' ! omxh264enc ! qtmux ! filesink location=$FILE -e 

# Dual H264 Encoding from Camera
```
FILE_A=filenameA.mp4
FILE_B=filenameB.mp4

gst-launch-1.0 -e nvarguscamerasrc ! 'video/x-raw(memory:NVMM), width=1920, height=1080, format=NV12, framerate=30/1' ! tee name=streams streams. ! queue ! omxh264enc bitrate=8000000 ! qtmux ! filesink location=$FILE_A streams. ! queue ! omxh264enc bitrate=8000000 ! qtmux ! filesink location=$FILE_B
```

# RTP Streaming
参照:[NVIDIA Jetson Nano GStreamer streaming pipelines](https://developer.ridgerun.com/wiki/index.php?title=Jetson_Nano/Gstreamer/Example_Pipelines/Streaming)

```
CLIENT_IP=<IP_ADDRESS>
gst-launch-1.0 -e nvarguscamerasrc \
! 'video/x-raw(memory:NVMM), width=1920, height=1080, format=NV12, framerate=30/1' \
! omxh265enc control-rate=2 bitrate=8000000  \
! video/x-h265, stream-format=byte-stream \
! rtph265pay mtu=1400 \
! udpsink host=$CLIENT_IP port=5000 sync=false async=false
```

```
CLIENT_IP=<IP_ADDRESS>
gst-launch-1.0 -e nvarguscamerasrc \
! 'video/x-raw(memory:NVMM), width=1920, height=1080, format=NV12, framerate=30/1' \
!  nvvidconv flip-method=rotate-180 \
! omxh265enc control-rate=2 bitrate=8000000  \
! video/x-h265, stream-format=byte-stream \
! rtph265pay mtu=1400 \
! udpsink host=$CLIENT_IP port=5000 sync=false async=false
```

client

```
gst-launch-1.0 udpsrc port=5000 \
! application/x-rtp,encoding-name=H265,payload=96 \
! rtph265depay ! h265parse ! queue ! avdec_h265 \
! xvimagesink sync=false async=false -e
```
# rtsp sever
参照:[Jetson Nano - その4: RTSPサーバーを立ち上げ](http://fanblogs.jp/nikmaniphonelife/archive/161/0)

```
./test-launch "nvarguscamerasrc sensor-id=1 ! video/x-raw(memory:NVMM), format=NV12, width=1280, height=720, framerate=30/1 ! nvvidconv flip-method=rotate-180 ! video/x-raw, width=640, height=360, format=NV12, framerate=30/1 ! omxh265enc ! rtph265pay name=pay0 pt=96 config-interval=1"
```

# rtsp sever
```
./test-launch "nvarguscamerasrc sensor-id=1 ! video/x-raw(memory:NVMM), format=NV12, width=1920, height=1080, framerate=30/1 ! nvvidconv flip-method=rotate-180 ! omxh265enc ! rtph265pay name=pay0 pt=96 config-interval=1"

```
# rtsp source
### rtspサーバの出力をファイルに保存
```
gst-launch-1.0 rtspsrc location=rtsp://hostname:8554/test ! \
	rtph264depay ! \
	h264parse ! \
	qtmux ! \
	filesink location=test1.mp4 -e 
```
### ディスプレイに表示
```
gst-launch-1.0 -e rtspsrc location=rtsp://jetcard.local:8553/live ! \
	rtph264depay ! \
	nvv4l2decoder ! \
	nvvideoconvert ! \
	"video/x-raw(memory:NVMM)",format=NV12 ! \
	nv3dsink
```