# GStreamer

GStreamer is a powerful tool which allows streaming complex video pipes over network. Simple pipelines to stream and receive video provided below.

#### Stream h.264@30fps over network

##### Show MJPEG stream on the LCD

```shell
gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg, width=1920, height=1080, framerate=30/1 ! jpegdec ! videoconvert ! queue ! autovideosink
```

##### Stream h.264 compressed video over UDP socket

```shell
gst-launch-1.0 -v v4l2src device=/dev/video2 do-timestamp=true ! video/x-h264, width=1920, \ 
height=1080, framerate=30/1 ! h264parse ! queue ! \ 
rtph264pay config-interval=10 pt=96 ! udpsink \ 
host=192.168.0.111 port=5600 sync=false
```

##### Receive stream and display on monitor

```shell
gst-launch-1.0 -e -v udpsrc port=5600 ! application/x-rtp, encoding-name=H264,payload=96 ! \ 
rtpjitterbuffer ! rtph264depay ! avdec_h264 ! autovideosink
```

#### Some other helpful pipelines

##### Receive, display and record video

```shell
gst-launch-1.0 -e -v udpsrc port=5600 ! tee name=STREAMOUT ! \ 
tee name=VIDEOWINDOW ! queue ! application/x-rtp, encoding-name=H264, payload=96 ! \ 
rtph264depay ! h264parse ! mp4mux ! filesink location=myvideo.mp4 STREAMOUT. ! \ 
queue ! udpsink port=5700 VIDEOWINDOW. ! queue ! application/x-rtp, \ 
payload=96 ! rtph264depay ! avdec_h264 ! autovideosink
```

##### Display h.264 stream (Windows)

```shell
gst-launch-1.0.exe ksvideosrc ! \ 
video/x-raw,format=H264,width=1920 ! \ 
capssetter caps=video/x-h264,format=byte-stream join=false ! \ 
queue ! \ 
h264parse ! \ 
avdec_h264 ! \ 
autovideosink
```

<p class="callout info">Not all firmware modifications are supported by gstreamer. If you experiencing streaming issues, feel free to [contact](https://www.kurokesu.com/shop/about_us) us. Update procedure is detailed [here](https://wiki.kurokesu.com/books/c1-family-camera-firmware-update-tool).</p>

#### Inspect video device capabilities

Video device details can be inspected with video4linux command `v4l2-ctl --device /dev/video2 --all` Video device should support H.264 pixel format. Various firmware modifications can have different configuration parameters and

```shell
Driver Info:
        Driver name      : uvcvideo
        Card type        : KurokesuC1_536     : Kurokesu C
        Bus info         : usb-0000:01:00.0-1.3
        Driver version   : 5.10.11
        Capabilities     : 0x84a00001
                Video Capture
                Metadata Capture
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps      : 0x04200001
                Video Capture
                Streaming
                Extended Pix Format
Media Driver Info:
        Driver name      : uvcvideo
        Model            : KurokesuC1_536     : Kurokesu C
        Serial           : SN000000
        Bus info         : usb-0000:01:00.0-1.3
        Media version    : 5.10.11
        Hardware revision: 0x00000100 (256)
        Driver version   : 5.10.11
Interface Info:
        ID               : 0x03000008
        Type             : V4L Video
Entity Info:
        ID               : 0x00000007 (7)
        Name             : KurokesuC1_536     : Kurokesu C
        Function         : V4L2 I/O
        Pad 0x01000011   : 0: Sink
          Link 0x0200001e: from remote pad 0x1000010 of entity 'Extension 4': Data, Enabled, Immutable
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
        Width/Height      : 1920/1080
        Pixel Format      : 'H264' (H.264)
        Field             : None
        Bytes per Line    : 3840
        Size Image        : 2073600
        Colorspace        : sRGB
        Transfer Function : Rec. 709
        YCbCr/HSV Encoding: ITU-R 601
        Quantization      : Default (maps to Full Range)
        Flags             :
Crop Capability Video Capture:
        Bounds      : Left 0, Top 0, Width 1920, Height 1080
        Default     : Left 0, Top 0, Width 1920, Height 1080
        Pixel Aspect: 1/1
Selection: crop_default, Left 0, Top 0, Width 1920, Height 1080, Flags:
Selection: crop_bounds, Left 0, Top 0, Width 1920, Height 1080, Flags:
Streaming Parameters Video Capture:
        Capabilities     : timeperframe
        Frames per second: 30.000 (30/1)
        Read buffers     : 0
                     brightness 0x00980900 (int)    : min=-64 max=64 step=1 default=0 value=0
                       contrast 0x00980901 (int)    : min=0 max=64 step=1 default=32 value=32
                     saturation 0x00980902 (int)    : min=0 max=128 step=1 default=52 value=52
                            hue 0x00980903 (int)    : min=-40 max=40 step=1 default=0 value=0
 white_balance_temperature_auto 0x0098090c (bool)   : default=1 value=1
                          gamma 0x00980910 (int)    : min=72 max=500 step=1 default=100 value=100
                           gain 0x00980913 (int)    : min=0 max=100 step=1 default=0 value=0
           power_line_frequency 0x00980918 (menu)   : min=0 max=2 default=2 value=2
      white_balance_temperature 0x0098091a (int)    : min=2800 max=9300 step=1 default=4600 value=4600 flags=inactive
                      sharpness 0x0098091b (int)    : min=0 max=6 step=1 default=3 value=3
         backlight_compensation 0x0098091c (int)    : min=0 max=2 step=1 default=1 value=1
                  exposure_auto 0x009a0901 (menu)   : min=0 max=3 default=3 value=3
              exposure_absolute 0x009a0902 (int)    : min=1 max=5000 step=1 default=156 value=156 flags=inactive
         exposure_auto_priority 0x009a0903 (bool)   : default=0 value=0

```

#### Debugging

Useful commands:

- `gst-launch-1.0 --gst-version` - read gstreamer version (tested with **GStreamer Core Library version 1.14.4**)