Builder / Flatpak : no audio out

I’m loading a video file like this:

def load_video_file(self, file):

    file_ok = False

    if isinstance(file, Gio.File):
        file_ok = True
        stream = Gtk.MediaFile.new_for_file(file)
    else:
        if os.path.exists(file):
            stream = Gtk.MediaFile.new_for_filename(file)
            file_ok = True

    if file_ok:
        self.video.set_media_stream(stream)
        stream.play()

And it works, but the stream is silent ; Of course I double-checked the various video files that I test with and they all have an audio track, sometimes even several ; I tried basically every combination of codec / container that I can find, and yes, they all play fine, but no sound.

I checked pavucontrol (the Pulse Audio control app, tab “Playback” select “All streams”) during the playback and there is effectively no audio stream / sink ever created and / or playing.

This, both within Builder “run” and after building & flatpak run. Oh, and no warning or error in both cases, too.

Outside of Builder / Flatpak however, my Gtk4VideoExample test script (which uses the same load_video_file() func) is playing the same test files with sound without problem.

What could be preventing the app (full Builder project code here) from producing audio?

Note that for sound of MP4 videos you may need gst-plugins-faad. One of my boxes was lacking that, so totem video player had no sound recently.

Yes, thank you Stefan, I checked that too, in fact I ran all my test video through Totem too, to make sure ; Every codec / container runs fine, and into my test script too. It’s only inside Builder / Flatpak that I can get any sound at all, it’s a very strange situation.

Platform details:

Ubuntu 22.4 ; GNOME Builder 43.2 (43.2) from channel “flatpak-stable” ABI 43 GTK+ 4.8.2.

Also

I ran into quite a serious problem trying to open files with the build executable (ie: not within Builder) when os.path.exists(filepath) would always return false…?

I found an explanation and a workaround in this SO answer :

sudo flatpak override org.yphil.matinee --filesystem=/home/

But shouldn’t it be something that Builder sets up? Maybe in the startup wizard “This app will read files on the user disk YES / NO” because now as it is, I would have to put this in a post-install script, which defeats the whole Flatpak purpose :confused:

And if I have to request access to the disk / File System, maybe (probably) I have to request access to the audio output, too? That sounds consistent to me.

So the question is, well, are:

  1. How to inform Flatpak (before the build) that the executable will open files / URIs ; and
  2. How to do the same for the audio out?
1 Like

Did you add permission to access pulseaudio in the json flatpak?

1 Like

Flatpak Permissions: Sandbox Permissions — Flatpak documentation

Example json: build-aux/flatpak/org.gnome.Evince.json · main · GNOME / evince · GitLab

That seems to be exactly what I need, thanks!

That is weird ; I have sound but not on all video / codecs, when my test script (using the same Gtk.Video() functions) plays everything with audio out… I have every finish-arg in the book…

    "app-id" : "org.yphil.matinee",
    "runtime" : "org.gnome.Platform",
    "runtime-version" : "43",
    "sdk" : "org.gnome.Sdk",
    "command" : "matinee",
    "finish-args" : [
        "--share=network",
        "--share=ipc",
        "--socket=fallback-x11",
        "--device=dri",
        "--socket=pulseaudio",
        "--socket=system-bus",
        "--filesystem=host",
        "--talk-name=org.gnome.SettingsDaemon.MediaKeys",
        "--talk-name=org.gtk.vfs.*",
        "--filesystem=xdg-run/gvfsd",
        "--talk-name=org.gnome.SessionManager",
        "--talk-name=org.freedesktop.FileManager1",
        "--socket=session-bus",
        "--socket=wayland"
    ],

This looks (well, sounds) pretty serious, I’m going to investigate and if the problem persists I’ll post a detailed topic with reproducible examples.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.