HDMI Output with ffplay

This suggests the interface was not actually connected since if it was, this rule would be in the policy: /dev/fb[0-9]* rw, which would make the above policy violation go away.

I tried to use the snapcraft.yaml that you originally posted, but it fails to build (I tried on amd64). It also doesn’t list ‘framebuffer’ in any of the plugs. Perhaps you forgot to add it? If you provide a working snapcraft.yaml or an amd64 snap, I can look into this further.

Hi,
sorry for the late reply. Here is the snapcraft.yaml:

name: ffmpeg
version: 0.1.6
summary: ffmpeg test
description: ffmpeg test
grade: devel
confinement: devmode

apps:
  ffmpeg:
    command: bin/ffmpeg
    plugs: [home, opengl, framebuffer, process-control]

  ffplay:
    command: bin/ffplay
    plugs: [pulseaudio, x11, process-control, alsa, network, opengl, framebuffer]

parts:
  ffmpeg:
    source: git://source.ffmpeg.org/ffmpeg.git
    source-tag: n2.8.14
    plugin: autotools
    configflags:
      - --disable-ffprobe
      - --enable-gpl
      - --enable-libass
      - --enable-libfreetype
      - --enable-libmp3lame
      - --enable-libopus
      - --enable-libtheora
      - --enable-libvorbis
      - --enable-libvpx
      - --enable-libx264
      - --enable-libx265
      - --enable-nonfree
      - --enable-opengl
    build-packages:
      - autoconf
      - automake
      - build-essential
      - cmake
      - g++
      - git
      - libass-dev
      - libfreetype6-dev
      - libmp3lame-dev
      - libopus-dev
      - libsdl1.2-dev
      - libtheora-dev
      - libtool
      - libva-dev
      - libvdpau-dev
      - libvorbis-dev
      - libvpx-dev
      - libx264-dev
      - libx265-dev
      - libxcb-shm0-dev
      - libxcb-xfixes0-dev
      - libxcb1-dev
      - make
      - pkg-config
      - texinfo
      - yasm
      - zlib1g-dev
      - libsdl2-dev

  ffmpeg-launcher:
    plugin: dump
    source: ffmpeg/scripts
    organize:
      'ffplay': bin/
      'ffmpeg': bin/
    after: [ffmpeg]

The scripts are just like this:

#!/bin/bash

if [ "$SNAP_ARCH" == "amd64" ]; then
  ARCH="x86_64-linux-gnu"
elif [ "$SNAP_ARCH" == "armhf" ]; then
  ARCH="arm-linux-gnueabihf"
elif [ "$SNAP_ARCH" == "arm64" ]; then
  ARCH="aarch64-linux-gnu"
else
  ARCH="$SNAP_ARCH-linux-gnu"
fi

# Include architecture specific libraries
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SNAP/usr/lib/$ARCH

exec $SNAP/usr/local/bin/ffplay $@

The following logs I just get if I execute ffplay without connecting the framebuffer:

Jul  1 15:29:41 localhost kernel: [ 6073.919814] audit: type=1400 audit(1530458981.136:146): apparmor="ALLOWED" operation="open" profile="snap.ffmpeg.ffplay" name="/dev/fb0" pid=22752 comm="ffplay" requested_mask="wr" denied_mask="wr" fsuid=1000 ouid=0
Jul  1 15:29:41 localhost kernel: [ 6073.920048] audit: type=1400 audit(1530458981.136:147): apparmor="ALLOWED" operation="open" profile="snap.ffmpeg.ffplay" name="/dev/fb0" pid=22752 comm="ffplay" requested_mask="wr" denied_mask="wr" fsuid=1000 ouid=0

If I connect the framebuffer before and execute ffplay I do not see anything in the logs. Except for the error message being displayed directly with the ffplay command:

Could not initialize SDL - Unable to open a console terminal
(Did you set the DISPLAY variable?)

Thanks for helping

Now I thought ffplay might be hard to get working and it is not the best player anyway. So I tried to use the MPV player. I am successful in building the snap [1] but if I try to run it (after connecting the framebuffer plug) I run into the following problem:

mpv-casept.mpv TestVideoColorChange.mp4 --vo=opengl

Error:

Fontconfig error: Cannot load default config file
[osd/libass] No usable fontconfig configuration file found, using fallback.
Fontconfig error: Cannot load default config file
Playing: TestVideoColorChange.mp4
 (+) Video --vid=1 (*) (h264 1280x720 25.000fps)
[vo/opengl/x11] couldn't open the X11 display ()!
[vo/opengl/x11] couldn't open the X11 display ()!
[vo/opengl/x11] couldn't open the X11 display ()!
[vo/opengl/wayland] failed to connect to a wayland server: check if a wayland compositor is running
[vo/opengl] VT_GETMODE failed: Inappropriate ioctl for device
[vo/opengl] Failed to set up VT switcher. Terminal switching will be unavailable.
[vo/opengl] Cannot open card "0": No such file or directory.
[vo/opengl] Failed to create KMS.
[vo/opengl] 'drm-egl' is deprecated, use 'drm' instead.
[vo/opengl] Can't handle VT release - signal already used
[vo/opengl] Failed to set up VT switcher. Terminal switching will be unavailable.
[vo/opengl] Cannot open card "0": No such file or directory.
[vo/opengl] Failed to create KMS.
[vo/opengl/x11] couldn't open the X11 display ()!
Error opening/initializing the selected video_out (--vo) device.
Video: no video
No video or audio streams selected.


Exiting... (Errors when loading file)

Maybe you have any suggestions for this problem or my initial ffplay problem. Thanks a lot and best regards

[1]

name: mpv-casept
version: '0.27.0'
summary: a free, open source, and cross-platform media player. Unofficial snap.
description: |
  mpv is a media player based on MPlayer and mplayer2.
  It supports a wide variety of video file formats,
  audio and video codecs, and subtitle types.
grade: devel
confinement: devmode

apps:
  mpv:
    command: usr/local/bin/mpv
    plugs: [framebuffer, x11, opengl, unity7, pulseaudio, home, network, removable-media, optical-drive]

parts:
  mpv:
    source: ./mpv-0.27.0.tar.gz
    plugin: waf
    prepare: |
     ./bootstrap.py
    stage-packages:
      - libasound2
      - libass5
      - libatomic1
      - libbluray1
      - libc6
      - libcdio-cdda1
      - libcdio-paranoia1
      - libcdio13
      - libdrm2
      - libdvdnav4
      - libdvdread4
      - libegl1-mesa
      - libgbm1
      - libgl1-mesa-glx
      - libjack-jackd2-0
      - libjpeg8
      - liblcms2-2
      - liblua5.2-0
      - libpulse0
      - librubberband2v5
      - libsdl2-2.0-0
      - libsmbclient
      - libsndio6.1
      - libuchardet0
      - libv4l-0
      - libva-drm1
      - libva-wayland1
      - libva-x11-1
      - libva1
      - libvdpau1
      - libwayland-client0
      - libwayland-cursor0
      - libwayland-egl1-mesa
      - libx11-6
      - libxext6
      - libxinerama1
      - libxkbcommon0
      - libxrandr2
      - libxss1
      - libxv1
      - zlib1g
    build-packages:
      - build-essential
      - libasound2-dev
      - libass-dev
      - libbluray-dev
      - libcdio-paranoia-dev
      - libdvdnav-dev
      - libdvdread-dev
      - libegl1-mesa-dev
      - libenca-dev
      - libgbm-dev
      - libgl1-mesa-dev
      - libguess-dev
      - libjack-dev
      - libjpeg-dev
      - liblcms2-dev
      - liblua5.2-dev
      - libpulse-dev
      - librubberband-dev
      - libsdl2-dev
      - libsmbclient-dev
      - libsndio-dev
      - libswscale-dev
      - libuchardet-dev
      - libv4l-dev
      - libva-dev
      - libvdpau-dev
      - libwayland-dev
      - libx11-dev
      - libxinerama-dev
      - libxkbcommon-dev
      - libxrandr-dev
      - libxss-dev
      - libxv-dev
      - pkg-config
      - python
      - python-docutils
    after: [ffmpeg]
  ffmpeg:
    source: git://source.ffmpeg.org/ffmpeg.git
    source-tag: n3.2.4
    plugin: autotools
    configflags:
      - --disable-ffprobe
      - --enable-gpl
      - --enable-libass
      - --enable-libfreetype
      - --enable-libmp3lame
      - --enable-libopus
      - --enable-libtheora
      - --enable-libvorbis
      - --enable-libvpx
      - --enable-libx264
      - --enable-libx265
      - --enable-nonfree
      - --enable-opengl
      - --enable-static
      - --enable-omx
      - --enable-omx-rpi
      - --enable-libxcb
      - --enable-libfreetype
      - --enable-gnutls
      - --disable-opencl
    build-packages:
      - autoconf
      - automake
      - build-essential
      - cmake
      - g++
      - git
      - libass-dev
      - libfreetype6-dev
      - libmp3lame-dev
      - libopus-dev
      - libsdl2-dev
      - libtheora-dev
      - libtool
      - libva-dev
      - libvdpau-dev
      - libvorbis-dev
      - libvpx-dev
      - libx264-dev
      - libx265-dev
      - libxcb-shm0-dev
      - libxcb-xfixes0-dev
      - libxcb1-dev
      - make
      - pkg-config
      - texinfo
      - yasm
      - zlib1g-dev
      - libluajit-5.1-dev
      - libfontconfig1-dev
      - libfribidi-dev
      - python-docutils
      - libjpeg-dev
      - libgnutls28-dev
      - libomxil-bellagio-dev
    stage-packages:
      - libssl-dev
    organize:
      usr/local/bin: usr/bin

did you connect the opengl interface (looks like you didnt, else /dev/dri/card0 should have been accessible) …

Hi ogra,
thanks for your quick reply. The opengl plug is connected (I also connected the framebuffer plug).
Thanks

looks like you might need special build options for gles (though the bug only mentions intel)

you might also need libegl1-mesa-drivers in stage-packages since you do not have an X11 server or wayland compositor … alternatively you could install mir-kiosk alongside to get a wayland compositor/server to connect to and use the wayland-socket-dir and x11 plugs like in:

some more details are at:

and if you look for a completely quiet boot with splash screen there is:

EDIT: and i forgot to link the full tutorial (see step 12):

Sorry for the late reply. I was away for a while. Thanks for your support.

So I found out a few things but I am still having trouble:

  • I was using Ubuntu Core stable version which was the problem why I was not able to see anything on the screen. Seems that the edge version is required to get mir-kiosk and graphical snaps running.

  • I’ve installed mir-kiosk for wayland support and I can also see something on my screen when I try out mir-kiosk-apps

  • My mpv snap is here [1]

  • When executing the mpv snap “mpv-casept.mpv SampleVideo.mp4 --vo=wayland” I get the following message:
    [vo/wayland/wayland] failed to connect to a wayland server: check if a wayland compositor is running Error opening/initializing the selected video_out (--vo) device.

  • Executing the mpv snap with sudo gets me further and I see the first frame of the video on the screen. Afterwards no further frames are shown and in the logs the following is shown:
    [vo/wayland/wayland] can't draw, back buffer is busy

Some additional information:

  • I’ve tried to build mpv with the --enable-rpi flag but I am running into:
    You manually enabled the feature 'rpi', but the autodetection check failed. Failed to run './waf configure --enable-rpi' for 'mpv': Exited with code 1. Verify that the part is using the correct parameters and try again.

  • Do I need to follow the approach described in https://www.raspberrypi.org/forums/viewtopic.php?t=199775 and install the GLES and EGL files from the official raspberry pi github page + change the wscript file?

I am trying further to get mpv running on rpi with Ubuntu Core but maybe you have some advices for me. Thanks.

[1] MPV snap

name: mpv-casept
version: '0.27.0'
summary: a free, open source, and cross-platform media player. Unofficial snap.
description: |
  mpv is a media player based on MPlayer and mplayer2.
  It supports a wide variety of video file formats,
  audio and video codecs, and subtitle types.
grade: devel
confinement: devmode

apps:
  mpv:
    command: usr/local/bin/mpv
    environment:
      XDG_RUNTIME_DIR: $SNAP_DATA/wayland
      LIBGL_DRIVERS_PATH: $SNAP_DATA/usr/lib/arm-linux-gnueabihf/dri
      WAYLAND_SOCKET_DIR: $SNAP_DATA/wayland
    plugs: [framebuffer, x11, opengl, unity7, pulseaudio, home, network, removable-media, optical-drive, wayland, alsa]

plugs:
  wayland-socket-dir:
    content: wayland-socket-dir
    interface: content
    target: $SNAP_DATA/wayland
    default-provider: mir-kiosk:wayland-socket-dir

parts:
  mpv:
    source: https://github.com/mpv-player/mpv/archive/v0.27.0.tar.gz
    plugin: waf
    prepare: |
      ./bootstrap.py
    stage-packages:
      - libasound2
      - libass5
      - libatomic1
      - libbluray1
      - libc6
      - libcdio-cdda1
      - libcdio-paranoia1
      - libcdio13
      - libdrm2
      - libdvdnav4
      - libdvdread4
      - libegl1-mesa
      - libgbm1
      - libgl1-mesa-glx
      - libgles2-mesa-dev
      - libjack-jackd2-0
      - libjpeg8
      - liblcms2-2
      - liblua5.2-0
      - libpulse0
      - librubberband2v5
      - libsdl2-2.0-0
      - libsmbclient
      - libsndio6.1
      - libuchardet0
      - libv4l-0
      - libva-drm1
      - libva-wayland1
      - libva-x11-1
      - libva1
      - libvdpau1
      - libwayland-client0
      - libwayland-cursor0
     - libwayland-egl1-mesa
      - libx11-6
      - libxext6
      - libxinerama1
      - libxkbcommon0
      - libxrandr2
      - libxss1
      - libxv1
      - zlib1g
    build-packages:
      - build-essential
      - libasound2-dev
      - libass-dev
      - libbluray-dev
      - libcdio-paranoia-dev
      - libdvdnav-dev
      - libdvdread-dev
      - libegl1-mesa-dev
      - libenca-dev
      - libgbm-dev
      - libgl1-mesa-dev
      - libguess-dev
      - libjack-dev
      - libjpeg-dev
      - liblcms2-dev
      - liblua5.2-dev
      - libpulse-dev
      - librubberband-dev
      - libsdl2-dev
      - libsmbclient-dev
      - libsndio-dev
      - libswscale-dev
      - libuchardet-dev
      - libv4l-dev
      - libva-dev
      - libvdpau-dev
      - libwayland-dev
      - libx11-dev
      - libxinerama-dev
      - libxkbcommon-dev
      - libxrandr-dev
      - libxss-dev
      - libxv-dev
      - libgles2-mesa-dev
      - pkg-config
      - python
      - python-docutils
    after: [ffmpeg]
  ffmpeg:
    source: git://source.ffmpeg.org/ffmpeg.git
    source-tag: n3.2.4
    plugin: autotools
    configflags:
      - --disable-ffprobe
      - --enable-gpl
      - --enable-libass
      - --enable-libfreetype
      - --enable-libmp3lame
      - --enable-libopus
      - --enable-libtheora
      - --enable-libvorbis
      - --enable-libvpx
      - --enable-libx264
      - --enable-libx265
      - --enable-nonfree
      - --enable-opengl
      - --enable-static
      - --enable-omx
      - --enable-omx-rpi
      - --enable-libxcb
      - --enable-libfreetype
      - --enable-gnutls
      - --disable-opencl
    build-packages:
      - autoconf
      - automake
      - build-essential
      - cmake
      - g++
      - git
      - libass-dev
      - libfreetype6-dev
      - libmp3lame-dev
      - libopus-dev
      - libsdl2-dev
      - libtheora-dev
      - libtool
      - libva-dev
      - libvdpau-dev
      - libvorbis-dev
      - libvpx-dev
      - libx264-dev
      - libx265-dev
      - libxcb-shm0-dev
      - libxcb-xfixes0-dev
      - libxcb1-dev
      - make
      - pkg-config
      - texinfo
      - yasm
      - zlib1g-dev
      - libluajit-5.1-dev
      - libfontconfig1-dev
      - libfribidi-dev
      - python-docutils
      - libjpeg-dev
      - libgnutls28-dev
      - libomxil-bellagio-dev
    stage-packages:
      - libssl-dev
   organize:
      usr/local/bin: usr/bin

I am not sure if mir-kiosk actually allows apps that are not running as service (i assume you need write access to the socket, which likely is root owned), probably someone from the mir team can clearify this … @greyback @alan_g ?

The socket is owned by root, but the permissions allow any user to connect.

Hmm, then it should theoretically find the socket if the wayland-socket-dir interface has been properly connectded…

That ought to be easy to verify with:

snap run --shell mpv-casept

and

ls -hl $XDG_RUNTIME_DIR

@getty23 I can’t help much with RPi (don’t have one), but I understand there are some oddities with its graphics. It might be better to isolate those issues by getting this working on amd64 first. (Use the Ubuntu Core VM from https://community.ubuntu.com/t/snaps-to-develop-a-web-kiosk-on-ubuntu-core-using-wayland/).

There are no oddities with RPi graphics regarding “just running” GL/GLES stuff on mir, glamour works perfectly fine here …

there might be issues with HW acceleration though (specfically for video playback and decoding), and this might need some special work later. but the snap should still start and run fine (despite the possibility of it being a slideshow like experience) as long as everything is properly connected …

Thanks for your replies.
I checked on the permissions:

snap run --shell mpv-casept.mpv
getty23@localhost:/home/getty23$ ls -hl $XDG_RUNTIME_DIR
ls: cannot open directory '/var/snap/mpv-casept/x1/wayland': Permission denied

While with sudo I get:

sudo snap run --shell mpv-casept.mpv
root@localhost:/home/getty23# ls -hl $XDG_RUNTIME_DIR
total 4.0K
drwx------ 2 root root 4.0K Aug  2 04:22 pulse
srw-rw-rw- 1 root root    0 Aug  7 05:09 wayland-0
-rw-r----- 1 root root    0 Aug  6 04:50 wayland-0.lock

My snap plugs are connected:

mir-kiosk:wayland             mpv-casept 
mir-kiosk:wayland-socket-dir  mpv-casept

Regarding the graphics I am also puzzled because even if hw acceleration is not yet working it should play the video slow but I just see the first frame and afterwards for each frame in the log it is printed: [vo/wayland/wayland] can't draw, back buffer is busy. The frames are not dropped but just this message is shown.

Hey,
you will need to run the snap as root, to get access to the directory containing the wayland socket - I’m refactoring the snap interface design to make this problem go away.

It looks like MPV is getting a wayland connection when you run as root, but something is wrong when swapping frames. Could be a Mir/wayland issue.

Trying mpv with Mir on stock Xenial is crashing for me, need to figure that out first. Why it isn’t crashing for you is a curiosity for me!
-G

Thanks for the support. Let me know if I can support in this issue.

Currently I am trying to integrate mmal, libEGL and libGLESv2 in my snap directly from the raspberry firmware (as described here https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=199775 in step12) because mmal is needed if I build ffmpeg with --enable-mmal and I think the EGL and GLESv2 libraries will help mvp. Though I am having trouble how to integrate it in my snap:

Could you advice me what the best method?

i started playing with the vc libs before (note though that this is all fully untested but it builds):

name: vc-libs
version: '0.1'
summary: Raspberry Pi VC4 libs
description: |
  userspace libs, typically found in /opt/vc

grade: stable
confinement: strict

architectures:
  - build-on: amd64
    run-on: armhf

passthrough:
  layout:
    /opt/vc:
      bind: $SNAP/opt/vc

parts:
  vclibs:
    plugin: nil
    override-build: |
      git clone --depth=1 https://github.com/raspberrypi/userland.git .
      ./buildme "$SNAPCRAFT_PART_INSTALL"
    build-packages:
      - cmake
      - g++-arm-linux-gnueabihf

using the part should put the libs into $SNAP/opt/vc … note that layouts are still an experimental feature (i.e. it will cause a manual review in the store and you need to explicitly enable it on your core image) in case you want to use the fancy layouts re-mapping i use above … but perhaps it helps to just add $SNAP/opt/vc/lib to LD_LIBRARY_PATH in a wrapper of your app.

Thanks for providing the part. This really helped to integrate it into my snap.

I just have a library reference problem. For my ffmpeg part I enabled mmal (–enable-mmal) but I am still running into the error “ERROR: mmal not found” (more information here: https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/ffb9025f39b274abfc4ad2b264205a44cc0238a4:/configure line 4680).

I build the ffmpeg part after vclibs, I have the layout included (though I am not sure if it applies to the build process already) and I tried multiple things to set additional paths for the ffmpeg part. For example

   prepare: |
      export LD_LIBRARY_PATH=$SNAPCRAFT_STAGE/opt/vc/lib:$LD_LIBRARY_PATH

Maybe you have a hint for me how to make the libs for mmal available for the ffmpeg build. Sorry for asking so many questions but I am still learning on snap ;). Thanks for your great support!

i think the vc libs will actually only help at runtime mmal.h should actually be shipped with the kernel headers, try adding linux-headers-raspi2 to your build-packages

for openmax support (i.e. if you also want to set --enable-omx-rpi, you also want libomxil-bellagio-dev in build-packages)

I tried that before but with this library I am running in the same problem. Although in this post they are also stating that this might be the right library: https://stackoverflow.com/questions/40175644/ffmpeg-hardware-acceleration-on-raspberry-pi/40182218#40182218

I now got it compiled with libraspberrypi-dev by adding the optional ppa: ppa:ubuntu-raspi2/ppa (https://wiki.ubuntu.com/ARM/RaspberryPi)

The ‘libomxil-bellagio-dev’ I already included.

Now I am facing two problems:

  • I added the optional ppa manually (not via snap). What’s the best way to do it via snap?
  • When I run mpv now I get
[vo/rpi] Could not get DISPMANX objects.
* failed to add service - already in use?

I am currently trying to analyse it. If you already have an idea, just let me know.
Thanks

if you include the -dev libs in build-packages you need their non-dev equivalents in stage-packages

also see: