Developer Guide

  • 2022.3
  • 10/25/2022
  • Public Content
Contents

GStreamer* Video Pipeline with libv4l2

Run a GStreamer* video pipeline using libv4l2 in a Docker* container.

Run the Sample Pipeline

  1. Connect a video camera compatible with libv4l2, such as a webcam (an Intel® RealSense™ camera is not compatible).
  2. Check if your installation has the amr-gstreamer Docker* image.
    docker images |grep amr-gstreamer #if you have it installed, the result is: amr-gstreamer
    If the image is not installed, continuing with these steps
    triggers a build that takes longer than an hour
    (sometimes, a lot longer depending on the system resources and internet connection).
  3. If the image is not installed, Intel recommends installing the Robot Base Kit or Robot Complete Kit with the Get Started Guide for Robots.
  4. Go to the
    AMR_containers
    folder:
    cd <edge_insights_for_amr_path>/Edge_Insights_for_Autonomous_Mobile_Robots_<version>/AMR_containers
  5. Prepare the environment setup:
    source ./01_docker_sdk_env/docker_compose/common/docker_compose.source export CONTAINER_BASE_PATH=`pwd` export ROS_DOMAIN_ID=27 sudo chmod a+rw /dev/video*
  6. Get the stream from the webcam using GStreamer*:
    CHOOSE_USER=eiforamr docker-compose -f 01_docker_sdk_env/docker_compose/05_tutorials/gstreamer_libv4l2.tutorial.yml up
    Expected output: The stream from the webcam is displayed.
  7. To close this, do one of the following:
    • Type
      Ctrl-c
      in the terminal where you did the up command.
    • Run this command in another terminal:
    CHOOSE_USER=eiforamr docker-compose -f 01_docker_sdk_env/docker_compose/05_tutorials/gstreamer_libv4l2.tutorial.yml down
  8. For an explanation of what happened, open the yml file:
    • The first 23 lines are from the EI for AMR infrastructure.
    • Line 26 plays the stream from the webcam using GStreamer*.

Troubleshooting

If the following error is encountered:
eiforamr@edgesoftware:~/workspace$ gst-launch-1.0 v4l2src ! autovideosink Setting pipeline to PAUSED ... Pipeline is live and does not need PREROLL ... Setting pipeline to PLAYING ... ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error. Additional debug info: gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: streaming stopped, reason not-negotiated (-4) Execution ended after 0:00:00.000028689 Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... Freeing pipeline ...
GStreamer* may want the type of decoding added. For example, for a Logitech* C922 webcam, the command is:
$ gst-launch-1.0 v4l2src ! jpegdec ! autovideosink
If the following error is encountered:
amr-gstreamer | Setting pipeline to PAUSED ... amr-gstreamer | error: XDG_RUNTIME_DIR not set in the environment.
Try this:
mkdir -pv ~/.cache/xdgr export XDG_RUNTIME_DIR=$PATH:~/.cache/xdgr
For general robot issues, go to: Troubleshooting for Robot Tutorials.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.