Cannot link gstreamer plugins to gst-launch in snap

Hi,

I am trying to use a gstreamer plugin called “v4l2src” to live stream webcam images as a snap

I have managed to build gstreamer in snapcraft and launch gst-launch. However, gst-launch is unable to link any of the plugins.

  1. I have tried copying everything to the prime directory and setting the environment variables using the environment in the apps
parts:
 gstreamer:
    plugin: autotools
    source: https://gstreamer.freedesktop.org/src/gstreamer/gstreamer-1.5.2.tar.xz
    configflags:
      - --prefix=/usr
      - --with-install-plugins-helper=/path/to/installer
    prime:
      - usr
    build-attributes: [no-system-libraries]

 gst-plugins-base:
    after:
      - gstreamer
    plugin: autotools
    source: https://gstreamer.freedesktop.org/src/gst-plugins-base/gst-plugins-base-1.5.2.tar.xz
    configflags:
      - --prefix=/usr
    build-attributes: [no-system-libraries]

 gst-plugins-good:
    after:
      - gstreamer
      - gst-plugins-base
    plugin: autotools
    source: http://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-1.5.2.tar.xz
    configflags:
     - --prefix=/usr
    prime:
      - usr
    build-attributes: [no-system-libraries]

apps:
  gst-launch:
    environment:
      GST_PLUGIN_PATH: usr/lib/gstreamer-1.0
      GST_PLUGIN_SYSTEM_PATH: usr/lib/gstreamer-1.0
      GST_PLUGIN_SCANNER: usr/libexec/gstreamer-1.0/gst-plugin-scanner
      # LD_LIBRARY_PATH: usr/lib
      PATH: $SNAP/usr/local/bin:$PATH
    command: usr/bin/gst-launch-1.0

However, the plugins are not seen by gst-launch.

$ gstreamer.gst-launch v4l2src device=/dev/video0 ! video/x-h264,width=1920,height=1080,framerate=24/1 ! h264parse ! rtph264pay ! udpsink host=xxx.xxx.xxx.xxx port=5000
ERROR: pipeline could not be constructed: no element "v4l2src".

I tried creating a app that echos the environment variables and have checked that the environment variables are indeed there.

I was wondering if I am misunderstanding the accessibility of the prime directory on runtime. Should the libraries be copied to the $SNAP_DATA rather than the prime directory?

How can I link the plugins to the gst-launch?

Thank you in advance

Your paths in the GST environment variables are not anchored. Therefore they are relative to whatever the current directory happens to be when the user launches the app. e.g. if I am in $HOME and I run your application then it will look for the gstreamer assets in $HOME/usr/lib/gstreamer-1.0. You simply need to prefix with $SNAP/ to ensure the paths are correctly pointing into your snap’s root filesystem:

apps:
  gst-launch:
    environment:
      GST_PLUGIN_SCANNER: $SNAP/usr/libexec/gstreamer-1.0/gst-plugin-scanner
      ... # etc...
2 Likes

@lucyllewy

Thanks, I the snap currently works setting the path as you have suggested