kivy audio provider error

156 views
Skip to first unread message

Degenerate Tech

unread,
Mar 11, 2024, 11:34:06 AMMar 11
to Kivy users support
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f03a8005980] Removing channel layout 0x3, redundant with 2 channels
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f038c007000] Removing channel layout 0x3, redundant with 2 channels
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f0364005980] Removing channel layout 0x4, redundant with 1 channels
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f0338005980] Removing channel layout 0x3, redundant with 2 channels
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f0310005980] Removing channel layout 0x3, redundant with 2 channels
[WARNING] [ffpyplayer  ] [wav @ 0x7f0314000cc0] Discarding ID3 tags because more suitable tags were found.
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f02ec005980] Removing channel layout 0x3, redundant with 2 channels
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f02c4005980] Removing channel layout 0x3, redundant with 2 channels
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f029c005980] Removing channel layout 0x3, redundant with 2 channels
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f0278005980] Removing channel layout 0x3, redundant with 2 channels
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f0250007000] Removing channel layout 0x3, redundant with 2 channels
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f0230005980] Removing channel layout 0x4, redundant with 1 channels
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f0204005980] Removing channel layout 0x3, redundant with 2 channels
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f01e8005980] Removing channel layout 0x3, redundant with 2 channels
[WARNING] [ffpyplayer  ] [wav @ 0x7f01dc000cc0] Discarding ID3 tags because more suitable tags were found.
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f01b8005980] Removing channel layout 0x3, redundant with 2 channels
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f0194005980] Removing channel layout 0x3, redundant with 2 channels
[WARNING] [ffpyplayer  ] SDL_OpenAudio (2 channels, 48000 Hz): Too many open audio devices
[WARNING] [ffpyplayer  ] SDL_OpenAudio (1 channels, 48000 Hz): Too many open audio devices
[WARNING] [ffpyplayer  ] SDL_OpenAudio (2 channels, 44100 Hz): Too many open audio devices
[WARNING] [ffpyplayer  ] SDL_OpenAudio (1 channels, 44100 Hz): Too many open audio devices
[ERROR  ] [ffpyplayer  ] No more channel combinations to try, audio open failed
[CRITICAL] [ffpyplayer  ] Failed to open file '/home/sahil/Math_Puzzle/res/level-up.wav' or configure filtergraph
[WARNING] [ffpyplayer  ] SDL_OpenAudio (2 channels, 44100 Hz): Too many open audio devices
[WARNING] [ffpyplayer  ] SDL_OpenAudio (1 channels, 44100 Hz): Too many open audio devices
[ERROR  ] [ffpyplayer  ] No more channel combinations to try, audio open failed

Stas Zytkiewicz

unread,
Apr 1, 2024, 1:11:06 PMApr 1
to Kivy users support
Hi, I also have this issue.
Did you find an solution?

elli...@cox.net

unread,
Apr 1, 2024, 4:52:48 PMApr 1
to kivy-...@googlegroups.com
What platform are you building for (Windows, Android, Mac...) and what is code doing?  Can you share a minimal runnable program that reproduces the problem?

From: kivy-...@googlegroups.com <kivy-...@googlegroups.com> on behalf of Stas Zytkiewicz <st...@btp.nl>
Sent: Monday, April 1, 2024 10:11 AM
To: Kivy users support <kivy-...@googlegroups.com>
Subject: [kivy-users] Re: kivy audio provider error
 
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5fc5e478-0af5-4d43-b59e-d818d0958778n%40googlegroups.com.

Degenerate Tech

unread,
Apr 4, 2024, 9:19:34 AMApr 4
to Kivy users support
ubuntu 22.04.3 LTS

Stas Zytkiewicz

unread,
May 31, 2024, 4:49:22 AMMay 31
to Kivy users support
Ok, a bit late but here is the demo code.
This problem occurs on Ubuntu 22.04 but also on Ubuntu 18.04 (Both tested)

When playing a ogg sound file while using ffpyplayer as the audio provider after 15 times playing the ffpyplayer will crash:

[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f99b0006a80] Removing channel layout 0x4, redundant with 1 channels
[WARNING] [ffpyplayer  ] [ffpyplayer_abuffersink @ 0x7f99b001fac0] Removing channel layout 0x4, redundant with 1 channels

[WARNING] [ffpyplayer  ] SDL_OpenAudio (1 channels, 48000 Hz): Too many open audio devices
[WARNING] [ffpyplayer  ] SDL_OpenAudio (1 channels, 44100 Hz): Too many open audio devices
[ERROR  ] [ffpyplayer  ] No more channel combinations to try, audio open failed
[CRITICAL] [ffpyplayer  ] Failed to open file '/mnt/nvme0n1p1/Github/btp-kivy/test_opus.ogg' or configure filtergraph

If you 'unload' the file after it plays the crash doesn't occur.

It doesn't matter if we install kivy with pip on python 3.8 or 3.10 or compile kivy for those platforms. Ffpyplayer will always crash after a few times playing if you don't unload the file.
We also tried using different versions of ffmpeg but it makes no difference.
This problem occurs on all kind of hardware, we have thousands of systems in use in about 10 different hardware configurations and all experiences this problem if we don't unload the sound after playing. This was also the reason we compiled our own kivy with gstreamer support the last few years but unfortunately newer python/kivy versions don't compile anymore with gtreamer support on Ubuntu 22.04 so we needed a hack to prevent the ffpyplayer from crashing.

(test code and soundfile is also attached)
The test code starts with playing without unloading and when you set the global var 'do_unload' to True it will start and unload each file after it plays.
---- The code -----
soundfile = 'test_opus.ogg'
do_unload = False

import os
os.environ['KIVY_NO_FILELOG'] = "1"
os.environ['KIVY_GL_BACKEND'] = 'sdl2'
os.environ['KIVY_VIDEO'] = 'ffpyplayer'   #'gstplayer'
os.environ['KIVY_AUDIO'] = 'ffpyplayer' #gstplayer'

from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.app import App
from kivy.core.audio import SoundLoader

Builder.load_string("""
<Content>:
    Button:
        text: "Press me to start playing sound"
        size_hint: (0.5, 0.5)
        on_press: root.start_play()
""")

class Content(BoxLayout):

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.current_sound = None

    def start_play(self, *args):
        if self.current_sound and do_unload:
            print("Unloading previous sound")
            self.current_sound.unload()
        self.play()

    def play(self, *args):
        sound = SoundLoader.load(soundfile)
        self.current_sound = sound
        sound.bind(on_stop=self.start_play)
        sound.play()

class TestApp(App):

    def build(self):
        fl = Content()
        return fl

TestApp().run()
test_soundplay.py
test_opus.ogg

ElliotG

unread,
May 31, 2024, 11:35:26 AMMay 31
to Kivy users support
Looks like a bug, I suggest you report it to: https://github.com/kivy/kivy/issues

Stas Zytkiewicz

unread,
Jun 1, 2024, 2:39:19 AMJun 1
to Kivy users support

Stas Zytkiewicz

unread,
Jun 7, 2024, 5:10:38 AMJun 7
to Kivy users support
As there's not much intrest in the bug report I will just post our solution to this bug here for reference.
We use a patched version of the kivy/core/audio/ffpyplayer by adding self.unload() to the 'stop' method of the SoundFFPy class. (By using from kivy.resources import resource_add_path, we patch more stuff like opencv)

The simple fix is this:
$ diff -c kivy/core/audio/audio_ffpyplayer.py patches/core/audio/audio_ffpyplayer.py
*** kivy/core/audio/audio_ffpyplayer.py 2024-06-01 15:01:31.164866738 +0200
--- patches/core/audio/audio_ffpyplayer.py 2024-06-01 14:33:53.903464418 +0200
***************
*** 154,159 ****
--- 154,160 ----
              self._ffplayer.toggle_pause()
              self._state = 'paused'
              self.state = 'stop'
+         self.unload()
          super(SoundFFPy, self).stop()
 
      def seek(self, position):

So we have:
our-tree/patches/core/audio/audio_ffpyplayer.py (The patched version)

And in our toplevel code before any kivy imports we have:
from os import environ
environ['KIVY_DATA_DIR'] = 'patches/data'
from kivy.resources import resource_add_path
resource_add_path('patches')

Now kivy will use the patched version of audio_ffpyplayer.
Reply all
Reply to author
Forward
0 new messages