GStreamer command examples - MDHSRobotics/TeamWiki GitHub Wiki

Home / Tutorials

GStreamer command examples

Start off:

  • Sample command to display a video from the default camera to the video player:

    • in linux:
       gst-launch-1.0 v4l2src ! autovideosink 
    
    • in Windows
       gst-launch-1.0 autovideosrc ! autovideosink
    

Commands to save recorded videos:

  • Sample command to record test video to a file

    • in both linux and Windows
        gst-launch-1.0 -e -v videotestsrc ! videoconvert ! jpegenc ! avimux! filesink location=output.avi
    

    (You should find your recorded video in your bin.)

  • Sample command to record video from a specified camera to a specified file video

    • in both linux and Windows
       gst-launch-1.0 -e -v autovideosrc ! videoconvert ! jpegenc ! avimux! filesink location=output.avi
    

    (You should find your recorded video in your bin. Keep in mind that this does not record audio.)

Commands to playback video or images from file

  • Sample command to play a specified file to the video player

       gst-launch-1.0 filesrc location=output.avi ! decodebin ! videoconvert ! autovideosink
       gst-launch-1.0 filesrc location=~/Desktop/gearfunctiontest.avi ! decodebin ! videoconvert ! xvimagesink
    

    (This will display your recorded video file output.avi)

  • Sample command to play back a specified image to the video player.

    • in both linux and Windows
       gst-launch-1.0 filesrc location=IMG_7099.JPG ! jpegdec ! imagefreeze ! autovideosink
    

Manipulating video format

  • Sample command to convert video format from color to black and white using a cap filter.

    • in both linux and Windows
       gst-launch-1.0 autovideosrc ! videoconvert ! video/x-raw,format=GRAY8 ! videoconvert  ! autovideosink
    

Streaming mjpeg over udp multicast

  • Sample command to stream a mjpeg stream over UDP multicast. IP address range designates this as a local multicast.

    • in linux
       gst-launch-1.0 v4l2src ! jpegenc ! mpegtsmux ! rtpmp2tpay ! udpsink host=239.255.41.41 port=5806
    
Revisions from Gstreamer-0.10 to Gstreamer-1.0: https://gstreamer.freedesktop.org/documentation/application-development/appendix/porting-1.0.html
Sample command to test custom lidar gstreamer plug in elements
   gst-launch-1.0 --gst-plugin-path=. lidarsrc device=/dev/ttyUSB0 simulate=true ! lidarimg ! video/x-raw, format=GRAY8, framerate=5/1, widht=640, height=480  ! videoconvert ! xvimagesink

Camera playback on the Tegra TX1
   gst-launch-1.0 nvcamerasrc fpsRange="30 30" ! 'video/xraw(memory:NVMM),width=(int)3840, height=(int)2160,format=(string)I420, framerate=(fraction)30/1' ! nvtee ! nvivafilter cuda-process=true customer-lib-name="libnvsample_cudaprocess.so" ! 'video/x-raw(memory:NVMM), format=(string)NV12' ! nvoverlaysink -e 
Augmented Reality filter on the Tegra TX1 camera
   gst-launch-1.0 --gst-plugin-path=. nvcamerasrc ! 'video/x-raw(memory:NVMM), width=(int)640, height=(int)480,format=(string)NV12, framerate=(fraction)24/1' ! nvvidconv flip-method=2 ! 'video/x-raw, format=(string)BGRx' ! arfilter filter=steamAR ! videoconvert ! 'video/x-raw, format=(string)I420' ! xvimagesink



   gst-launch-1.0 --gst-plugin-path=/usr/local/msee filesrc location=~/Desktop/gearfunctiontest.avi ! decodebin ! videoconvert ! arfilter filter=gearAR ! video/x-raw,format=BGR ! videoconvert ! xvimagesink 

Command to convert a video file to a series of images

gst-launch-1.0 filesrc location=~/Desktop/gearfunctiontest.avi ! decodebin ! queue ! videoconvert ! pngenc ! multifilesink location=~/Desktop/Pics/gear%d.png

Image Freeze by gstreamer

gst-launch-1.0 -v -e filesrc location=~/Desktop/Pics/gear190.png ! decodebin ! imagefreeze ! videoconvert ! xvimagesink

Augmented Reality filter on Image

gst-launch-1.0 --gst-plugin-path=/usr/local/msee -v -e filesrc location=~/Desktop/Pics/gear190.png ! decodebin ! imagefreeze ! videoconvert ! arfilter filter=gearAR ! video/x-raw,format=BGR ! videoconvert ! xvimagesink