Audio only playback with playbin

hjuvi freedesktop-ml at
Fri Jan 6 08:18:11 UTC 2023


Thank you Stéphane for your answer.

I've had a look at gstplay, but it seems that gapless playback is not supported (it's in the TODO
list at the beginning of the file), and I do need it.
And also it comes from the bad plugins, so I think I'd better keep on trying with the playbin
solution, which already offers a good abstraction.

I have no clear conclusion for the moment, because it seems that the behaviour depends a lot on the video, but I
did reproduce some similar issues with gst-play-1.0:
- position increasing much too fast when using fakesink for video (but it's OK with fakevideosink)
- freezing after several seek commands

GST_DEBUG didn't help, because there are neither errors nor warnings, only info, debug, etc...

There are a few things I noticed in the source code of gstplay.c. But trying to implement them in my code didn't help.

- Seeking seems to require 'paused' state ("/* Only seek in PAUSED */").
=> I tried to set 'paused' state before calling gst_element_seek_simple, and set 'playing' state after, but it
didn't solve anything...
=> Anyway, the documentation says that it can be performed in either 'paused' or 'playing' state.

- Seeking is not permitted as long as the last seek request has not resulted in a "state changed"
event (or after 250ms timeout)
=> I tried to implement this (without the timeout), but I soon wasn't able to seek anymore, so I believe the timeout is really necessary (don't know why...)
=> Based on the documentation that I just mentioned above, it seems that I should (can?) wait for GST_MESSAGE_ASYNC_DONE before allowing another seek, but once again it didn't change anything (and in fact the message was always received before the next seek command was sent).

I've also already searched for examples on the internet, but I think that most media players do play the video. I'm trying to implement a very specific use case I believe.

I asked here, in case there was something I obviously did wrong, but if it's not the case, then I'll just make some further investigation, and either keep the feature with a this known issue ("seek at your own risk!") or remove the feature and filter out videos from the playlist.


3 janvier 2023 15:57 "Stephane Cerveau via gstreamer-devel" <gstreamer-devel at>
a écrit:

> Dear Cedric,
> 1) 2) 3)One option to solve your issue(s) would be to redesign a little bit your player to use the
> gst-player API, which will abstract a lot of facilities for you:
> st/player. You can check the code of gst-play-1.0
> You can give a try to `gst-play-1.0 YOUR_AV_FILE --videosink=fakesink` for example.
> 5) to debug I recommend you to read
> Best regards.
> Stéphane
> On 3/1/23 10:36, hjuvi via gstreamer-devel wrote:
>> Hello,
>> I'm writing a terminal-based audio player application based on GStreamer (currently testing with
>> version 1.20.4).
>> This is really intended to be an audio player only, but I'd like to be able to play the audio part
>> of an audio/video file.
>> For this purpose, I'm using a fake sink for the video, to avoid having a popup window with the
>> video.
>> My player works perfectly for pure audio files, but I have some problems with audio/video files. It
>> plays correctly if I just let it play, but:
>> - It seems that I don't receive the EOS message (only 'about-to-finish').
>> - If I try to seek, it works for a moment, but then it ends up getting lost, with strange
>> behaviours (position not updated, audio freeze or acceleration), and most of the time it freezes
>> completely (the main loop is blocked).
>> I'm seeking with (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT) flags.
>> My questions are:
>> 1) Is the playbin appropriate for this purpose? I find it very convenient, so I hope it is not
>> necessary to build the pipeline for audio only.
>> 2) Is the fake sink (fakesink or fakevideosink) the right solution to disable video? (I used
>> fakevideosink because the behaviour was even worse with fakesink).
>> 3) Does the fake sink just disable the output, or does it saves the video decoding (which would be
>> useless)?
>> 4) Am I using the right flags to seek? (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT)
>> 5) If there is no obvious error in what I've done, would you suggest any method to debug this?
>> (additional traces...)
>> In case it might help to understand, the source code is here:
>> And all the calls to GStreamer are done in this particular file:
>> Thanks a lot for your help.
>> --
>> Cédric

More information about the gstreamer-devel mailing list