clapper icon indicating copy to clipboard operation
clapper copied to clipboard

Error opening a h264 video - Failed to connect stream: Invalid argument

Open baiywt opened this issue 3 years ago • 24 comments

  1. I open Clapper using command line.
  2. I enabled playbin3 option and disabled Pipewire audio support.
  3. Open a h264 video using Clapper using Open Files.
  4. Window is black and the error occurred. (com.github.rafostar.Clapper:11584): Clapper-CRITICAL **: 12:27:45.332: Error from element /GstPlayBin3:playbin3/GstPlaySink:playsink/GstBin:abin/GstAutoAudioSink:audiosink/GstPulseSink:audiosink-actual-sink-pulse: GStreamer encountered a general resource error. Failed to connect stream: Invalid argument ../ext/pulse/pulsesink.c(1078): gst_pulseringbuffer_acquire (): /GstPlayBin3:playbin3/GstPlaySink:playsink/GstBin:abin/GstAutoAudioSink:audiosink/GstPulseSink:audiosink-actual-sink-pulse

5.Do not close Clapper, open a h264 video again using Open Files, Then the video can be played.

Can someone help?

baiywt avatar Apr 19 '22 01:04 baiywt

GStreamer version is 1.20.1

baiywt avatar Apr 19 '22 02:04 baiywt

Does this also happen with playbin2 (disable playbin3 and restart the player)?

Rafostar avatar Apr 19 '22 06:04 Rafostar

Hello, if i disable playbin3, errors are always reported and window is black.

(com.github.rafostar.Clapper:3931): Clapper-CRITICAL **: 06:42:55.511: Error from element /GstPlayBin:playbin/GstPlaySink:playsink/GstBin:abin/GstPulseSink:pulsesink0: GStreamer encountered a general resource error. Failed to connect stream: Invalid argument ../ext/pulse/pulsesink.c(1078): gst_pulseringbuffer_acquire (): /GstPlayBin:playbin/GstPlaySink:playsink/GstBin:abin/GstPulseSink:pulsesink0

(com.github.rafostar.Clapper:3931): Clapper-CRITICAL **: 06:43:14.280: Error from element /GstPlayBin:playbin/GstPlaySink:playsink/GstBin:abin/GstPulseSink:pulsesink0: GStreamer encountered a general resource error. Failed to connect stream: Invalid argument ../ext/pulse/pulsesink.c(1078): gst_pulseringbuffer_acquire (): /GstPlayBin:playbin/GstPlaySink:playsink/GstBin:abin/GstPulseSink:pulsesink0

baiywt avatar Apr 19 '22 06:04 baiywt

Start with below:

GST_DEBUG_NO_COLOR=1 GST_DEBUG=*pulse*:5,3 GST_DEBUG_FILE="$HOME/Videos/gstreamer.log" clapper

Try to play something with failure and attach generated gstreamer.log file in comment.

Rafostar avatar Apr 19 '22 07:04 Rafostar

gstreamer.log

baiywt avatar Apr 19 '22 07:04 baiywt

This seems like pulseaudio is having problems opening a connection with GStreamer process. Probably either your pulseaudio configuration is broken (do you/your distro have some predefined/initial config files?) on your OS or this might be a hardware/driver specific bug.

You can also try with ALSA instead of pulseaudio if its broken on your system for some reason:

GST_PLUGIN_FEATURE_RANK=alsasink:300 clapper

This is unrelated, but I also see in your log that v4l2codecs fails to initialize h264 decoder, which leads me to believe that this is some kind of embedded ARM machine you are using. Make sure you are using a recent mainline kernel (if possible), as otherwise hardware accelerated decoding will not work anyway.

Rafostar avatar Apr 19 '22 09:04 Rafostar

Thank you for your reply ! Yes, I run Linux 5.16 kernel on RK3399 and the hardware decoding of H264 is ok after opening the video for the second time using Open Files.

baiywt avatar Apr 19 '22 09:04 baiywt

@baiywt

Please try with alsa sink using cmd I mentioned earlier.

hardware decoding of H264 is ok

If v4l2codecs h264 stateless decoder fails to register, which decoder is used then? :thinking:

Rafostar avatar Apr 19 '22 09:04 Rafostar

share gstreamer.log I think it worked

baiywt avatar Apr 19 '22 09:04 baiywt

GST_DEBUG_NO_COLOR=1 GST_DEBUG=pulse:5,3 GST_DEBUG_FILE="$HOME/Videos/gstreamer.log" GST_PLUGIN_FEATURE_RANK=alsasink:300 clapper

The window is still black using alsa sink gstreamer.log

baiywt avatar Apr 19 '22 10:04 baiywt

Does the problem appears only with AC-3 audio? Have you tried with a video that has a different audio codec?

Rafostar avatar Apr 19 '22 10:04 Rafostar

No, let me try

baiywt avatar Apr 19 '22 10:04 baiywt

@Rafostar Hello, vp8 and VP9 videos do not have this problem.

baiywt avatar Apr 19 '22 10:04 baiywt

@Rafostar Hello, vp8 and VP9 videos do not have this problem.

The problem here is with audio, what audio codec do those streams that work use? Please check the name of used audio decoder (in next popover button to video one) for both streams that work on the first try and the one that works only on second opening for comparison.

Rafostar avatar Apr 19 '22 10:04 Rafostar

As you say, the problem appears only with AC-3 audio, I tried to play the h264 video with mp3 audio is ok.

baiywt avatar Apr 19 '22 10:04 baiywt

Please check the name of used audio decoder (in next popover button to video one)

If it fail, that button does not show.

baiywt avatar Apr 19 '22 10:04 baiywt

If it fail, that button does not show.

Even on second file open when you manage to actually play video?

Rafostar avatar Apr 19 '22 10:04 Rafostar

Also if this is some non-flatpak installation of Clapper, please make sure you have gstreamer1.0-plugins-ugly package installed or compiled with liba52 if you were compiling gstreamer yourself.

Rafostar avatar Apr 19 '22 11:04 Rafostar

Even on second file open when you manage to actually play video?

No, decoder is avdec_aac on second file open. QQ截图20220419192257

baiywt avatar Apr 19 '22 11:04 baiywt

If the audio has AC-3 codec but second file open uses avdec_aac then this is wrong and might be the cause of this problem. Can you share the link to the video in question?

Rafostar avatar Apr 19 '22 11:04 Rafostar

Oh, get it wrong, my audio format of h264 video is acc, the codec format is correct.

https://user-images.githubusercontent.com/50469989/163997515-ff5a26e9-e4cb-4085-bfd8-b4470317358a.mp4

baiywt avatar Apr 19 '22 11:04 baiywt

OK. I am able to reproduce this here with your video. Seems to be caused by setting volume (in this case restoring last volume) on startup for some reason for this particular video. A workaround like this fixes (avoids) this problem on my end:

diff --git a/src/controls.js b/src/controls.js
index b74b2f1..04f250b 100644
--- a/src/controls.js
+++ b/src/controls.js
@@ -374,7 +374,7 @@ class ClapperControls extends Gtk.Box
             ? settings.get_int('volume-value') / 100
             : settings.get_double('volume-last');
 
-        clapperWidget.player.volume = initialVolume;
+        //clapperWidget.player.volume = initialVolume;
         clapperWidget.player.bind_property('mute', this.volumeButton, 'muted',
             GObject.BindingFlags.DEFAULT
         );

Rafostar avatar Apr 19 '22 12:04 Rafostar

Definitely a GStreamer bug related to setting/changing initial volume. I can easily reproduce the same issue with gst-play-1.0 tool.

This works:

gst-play-1.0 "your_sample_video.mp4"

but this does not work:

gst-play-1.0 --volume=0 "your_sample_video.mp4"

@baiywt

If you can confirm those, please open this as an issue on GStreamer gitlab (https://gitlab.freedesktop.org/gstreamer/gstreamer) instead with same video attached. Should be fixed there instead of relaying on some workarounds inside the player.

Rafostar avatar Apr 19 '22 12:04 Rafostar

Ok, thank you very much for your help.

baiywt avatar Apr 19 '22 13:04 baiywt