Using ffmpeg-2204 content snap: missing shared library

Hello, I’m trying to implement the ffmpeg-2204 content snap because my python application needs it to perform some operations.

When trying to execute ffmpeg inside the snap environment, I get the following error: ffmpeg: error while loading shared libraries: libxcb.so.1: cannot open shared object file: No such file or directory

When running find $SNAP/ -name 'libxcb*' I get:

/snap/rackety-nuc-script/x11/ffmpeg-platform/usr/lib/aarch64-linux-gnu/libxcb-shape.so.0
/snap/rackety-nuc-script/x11/ffmpeg-platform/usr/lib/aarch64-linux-gnu/libxcb-shape.so.0.0.0

So it seems like the “libxcb.so.1” is missing in ffmpeg-2204

My snapcraft.yaml looks like this:

name: rackety-nuc-script
summary: firmware for rackety nucs
description: firmware that lets nucs connect to the rackety network and record videos
version: 1.0.0
base: core22
grade: stable
confinement: strict
architectures:
    - build-on: [amd64, arm64]
      build-for: [arm64]
    - build-on: [amd64, arm64]
      build-for: [amd64]
plugs:
    ffmpeg-2204:
        interface: content
        target: ffmpeg-platform
        default-provider: ffmpeg-2204
parts:
    rackety-nuc-script:
        plugin: python
        source: .
apps:
    rackety-nuc-script:
        environment:
            PATH: $SNAP/ffmpeg-platform/usr/bin:$PATH
            LD_LIBRARY_PATH: $SNAP/ffmpeg-platform/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:$LD_LIBRARY_PATH
        command: bin/rackety-nuc-script
        plugs:
            - network
            - network-observe
        daemon: simple

Of course, after installing the snap I’m running sudo snap connect rackety-nuc-script:ffmpeg-2204 ffmpeg-2204

Can someone help on how to solve this issue?

Hi ! @alemosa .

Perhaps, you should search libxcb and its dependencies, then add them in the stage-packages section at the level of your *.yaml file.

Here a command allowing to search libxcb and its dependencies :

apt-cache search libxcb

Otherwise, you can just add the following libs in your stage-packages section :

libxcb-randr0-dev
libxcb-xtest0-dev
libxcb-xinerama0-dev 
libxcb-shape0-dev 
libxcb-xkb-dev
1 Like

Hi, @alemosa thanks for using the content snap. The content snap was made with the content snaps like gnome-42-2204 in mind. So, it lacks a lot of desktop related libraries like libxcb. You’ll need to add those here as @baldeuniversel suggested. I’ll try to create a documentation on this. If your snap can, you can use the gnome extension. It’ll simplify these.

EDIT: stage this package also libxcb1

1 Like

Hello, @soumyaDghosh @baldeuniversel

Thanks for the suggestions. When trying to add the stage-packages @baldeuniversel said, I get a new shared error: ffmpeg: error while loading shared libraries: libxcb-shm.so.0: cannot open shared object file: No such file or directory If I try then to add libxcb-shm or libxcb-shm-dev as a stage-package, snapcraft says that it can’t find that stage-package.

If I follow the suggestion of @soumyaDghosh of adding the gnome extension, ffmpeg works inside the snap (I can shell into it and run ffmpeg successfully), but I get a new error on my python app: mkdir: cannot create directory ‘/run/user/0. This leads into running with issues for the python app, because it can’t for example create the logs directory and files, as well as other directories needed.

Need to mention that the objective of this snap is running into a raspberry-pi-4B with ubuntu core 22 installed, I don’t know if installing the gnome extension is the best approach.

The connections of rackety-nuc-script in the raspberry look as follows:

content[ffmpeg-2204]    rackety-nuc-script:ffmpeg-2204      ffmpeg-2204:ffmpeg-2204         manual
content[gnome-42-2204]  rackety-nuc-script:gnome-42-2204    gnome-42-2204:gnome-42-2204     -
content[gtk-3-themes]   rackety-nuc-script:gtk-3-themes     gtk-common-themes:gtk-3-themes  -
content[icon-themes]    rackety-nuc-script:icon-themes      gtk-common-themes:icon-themes   -
content[sound-themes]   rackety-nuc-script:sound-themes     gtk-common-themes:sound-themes  -
desktop                 rackety-nuc-script:desktop          -                               -
desktop-legacy          rackety-nuc-script:desktop-legacy   -                               -
gsettings               rackety-nuc-script:gsettings        -                               -
network                 rackety-nuc-script:network          :network                        -
network-observe         rackety-nuc-script:network-observe  :network-observe                manual
opengl                  rackety-nuc-script:opengl           :opengl                         -
wayland                 rackety-nuc-script:wayland          -                               -
x11                     rackety-nuc-script:x11              -                               -

Not being able to connect to desktop, desktop-legacy, gsettings, wayland and x11 because snapd doesn’t have those slots.

Please, show the content of your *.yaml file.

Hey @baldeuniversel ,

This is the snapcraft.yaml right now:

name: rackety-nuc-script
summary: firmware for rackety nucs
description: firmware that lets nucs connect to the rackety network and record videos
version: 1.0.0
base: core22
grade: stable
confinement: strict
architectures:
    - build-on: [amd64, arm64]
      build-for: [arm64]
    - build-on: [amd64, arm64]
      build-for: [amd64]
plugs:
    ffmpeg-2204:
        interface: content
        target: ffmpeg-platform
        default-provider: ffmpeg-2204
parts:
    rackety-nuc-script:
        plugin: python
        source: .
        stage-packages:
            - libxcb-randr0-dev
            - libxcb-xtest0-dev
            - libxcb-xinerama0-dev
            - libxcb-shape0-dev
            - libxcb-xkb-dev
            - libxcb1
apps:
    rackety-nuc-script:
        environment:
            PATH: $SNAP/ffmpeg-platform/usr/bin:$PATH
            LD_LIBRARY_PATH: $SNAP/ffmpeg-platform/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:$LD_LIBRARY_PATH
        extensions: [gnome]
        command: bin/rackety-nuc-script
        plugs:
            - network
            - network-observe
        daemon: simple

Well ! In the stage-packages section, add the lib

libxcb-shm0

@alemosa, do you still have errors ?

Yes @baldeuniversel , now I have this one:

ffmpeg: error while loading shared libraries: libxcb-xfixes.so.0: cannot open shared object file: No such file or directory

Fixed last one with stage-package libxcb-xfixes0, now got new one with libasound, I’ll try with staging libasound2

Okay. Otherwise, the @soumyaDghosh scenario could work if you solve the problem shown above mkdir .... .

Yea, it would be the other way to go… but I can’t seem to find a way to be able to run “mkdir” when using the gnome extension.

Right now I’m trying to iterate trhough the stage-packages that I need installed, so far:

        stage-packages:
            - libxcb-randr0-dev
            - libxcb-xtest0-dev
            - libxcb-xinerama0-dev
            - libxcb-shape0-dev
            - libxcb-xkb-dev
            - libgl1-mesa-dev
            - libxcb1
            - libxcb-shm0
            - libxcb-xfixes0
            - libasound2
            - libcaca0

Do want to have write access in run/user ?

If this is the case, why ?

No, I actually just want to have write permission on the $SNAP_DATA folder, but it seems like my python app doesn’t have write permission even there after using the “gnome” extension… Normally the python app would create some directories inside the $SNAP_DATA folder, but when running with the gnome extension the directory is completely empty, so It’s not being able to create any dirs. Maybe with the error trace you can see better what is happening:

2024-02-29T09:56:59Z systemd[1]: Started Service for snap application rackety-nuc-script.rackety-nuc-script.
2024-02-29T09:56:59Z rackety-nuc-script.rackety-nuc-script[7090]: mkdir: cannot create directory ‘/run/user/0’: Permission denied
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]: Traceback (most recent call last):
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]:   File "/snap/rackety-nuc-script/17/bin/rackety-nuc-script", line 5, in <module>
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]:     from src.__main__ import main
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]:   File "/snap/rackety-nuc-script/17/lib/python3.10/site-packages/src/__main__.py", line 2, in <module>
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]:     from .Logging import printRackety as print, Logging,printAndLog,launchThreadUploadFtpLogs, moveLogFiles
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]:   File "/snap/rackety-nuc-script/17/lib/python3.10/site-packages/src/Logging.py", line 22, in <module>
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]:     fileHandler = RotatingFileHandler("logs/app.log", mode='a', maxBytes=5*1024*1024,
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]:   File "/usr/lib/python3.10/logging/handlers.py", line 155, in __init__
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]:     BaseRotatingHandler.__init__(self, filename, mode, encoding=encoding,
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]:   File "/usr/lib/python3.10/logging/handlers.py", line 58, in __init__
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]:     logging.FileHandler.__init__(self, filename, mode=mode,
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]:   File "/usr/lib/python3.10/logging/__init__.py", line 1169, in __init__
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]:     StreamHandler.__init__(self, self._open())
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]:   File "/usr/lib/python3.10/logging/__init__.py", line 1201, in _open
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]:     return open_func(self.baseFilename, self.mode,
2024-02-29T09:57:00Z rackety-nuc-script.rackety-nuc-script[7057]: FileNotFoundError: [Errno 2] No such file or directory: '/var/snap/rackety-nuc-script/17/logs/app.log'
2024-02-29T09:57:00Z systemd[1]: snap.rackety-nuc-script.rackety-nuc-script.service: Main process exited, code=exited, status=1/FAILURE
2024-02-29T09:57:00Z systemd[1]: snap.rackety-nuc-script.rackety-nuc-script.service: Failed with result 'exit-code'.
2024-02-29T09:57:00Z systemd[1]: snap.rackety-nuc-script.rackety-nuc-script.service: Scheduled restart job, restart counter is at 4.

This is a shortcoming of the gnome extension since it is not really designed to run as root … which you have to do when using ubuntu core (i.e. your apps usually are daemons/services, not enduser apps in this case) …

you could try to use the gnome snap as a stage snap and then mangle the wrapper scripts to suppress the mkdir and have the scripts use /tmp or so … but that is likely as much work as to simply figure out what you need via deb packages in stage-package entries … looking at the gnome extension snap might give you some clues what to do to get all font/theme/whatever bits in order though …

PS: the last error in your log seems to indicate that you want a “mkdir $SNAP_DATA/logs” somewhere (perhaps in the install hook) …

1 Like

Yea @ogra , right now what I’m trying to achieve is to get all the deb packages needed via stage-packages. So far I had to add this packages:

        stage-packages:
            - libxcb-randr0-dev
            - libxcb-xtest0-dev
            - libxcb-xinerama0-dev
            - libxcb-shape0-dev
            - libxcb-xkb-dev
            - libgl1-mesa-dev
            - libxcb1
            - libxcb-shm0
            - libxcb-xfixes0
            - libasound2
            - libcaca0
            - libv4l-0
            - libva-dev
            - libfontconfig1
            - libvpx-dev
            - libvpx7
            - libwebpmux3
            - librsvg2-2
            - librsvg2-dev
            - librsvg2-common
            - libglu1-mesa
            - libopenjp2-7
            - freeglut3
            - libspeex-dev
            - libtheora0
            - libtwolame-dev
            - libpulse-dev
            - libpulse0
            - libraw1394-dev

But I got stuck right now with this one:

ffmpeg: error while loading shared libraries: libpulsecommon-15.99.so: cannot open shared object file: No such file or directory

libpulse0 and libpulse-dev are installed, any idea on what is missing here?

that they do not install to your standard LD_LIBRARY_PATH :wink: they live in a subdir … you should use an environment: entry to extend the search path

1 Like

Yeah, I was just having a look at that, it’s installed under $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/pulseaudio, compiling it right now let’s see

EDIT: It would be amazing that I could detect all missing libraries for ffmpeg in one shot, right now I have to go 1 by 1 compiling the whole snap and installing it to see if it works, I wonder if there’s a faster way…

Finally I got it working, had to add all this stage-packages:

        stage-packages:
            - libxcb-randr0-dev
            - libxcb-xtest0-dev
            - libxcb-xinerama0-dev
            - libxcb-shape0-dev
            - libxcb-xkb-dev
            - libgl1-mesa-dev
            - libxcb1
            - libxcb-shm0
            - libxcb-xfixes0
            - libasound2
            - libcaca0
            - libv4l-0
            - libva-dev
            - libfontconfig1
            - libvpx-dev
            - libvpx7
            - libwebpmux3
            - librsvg2-2
            - librsvg2-dev
            - librsvg2-common
            - libglu1-mesa
            - libopenjp2-7
            - freeglut3
            - libspeex-dev
            - libtheora0
            - libtwolame-dev
            - libpulse-dev
            - libpulse0
            - libraw1394-dev
            - libxcursor-dev
            - libxinerama-dev
            - libxrandr-dev
            - libxkbcommon-dev
            - libarchive-dev
            - libmpg123-0
            - libsamplerate-dev
            - libgomp1

Thanks to all for your help!

2 Likes