Play local file

https://gstreamer.freedesktop.org/documentation/tutorials/basic/hello-world.html?gi-language=c

Play local file

I tried the following tutorial and it works.
I changed the following line. But unfortunately it doesn’t work,

// old
("playbin uri=https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm",
// new
("playbin uri=sintel_trailer-480p.webm",
// or
("/home/tux/Schreibtisch/gstreamer_3/test.mp3",

When I try it with the MP3, I get the following message, including a SIGSEV.


(main:3964): GStreamer-CRITICAL **: 13:35:28.891: gst_element_set_state: assertion 'GST_IS_ELEMENT (element)' failed

(main:3964): GStreamer-CRITICAL **: 13:35:28.891: gst_element_get_bus: assertion 'GST_IS_ELEMENT (element)' failed

(main:3964): GStreamer-CRITICAL **: 13:35:28.891: gst_bus_timed_pop_filtered: assertion 'GST_IS_BUS (bus)' failed
Memory access error (memory dump written)

What am I doing wrong?

the uri needs to be an uri. For local files, use file:// followed by absolute filesystem path.

You need to actually pass a URI to the uri property here.

Local file URIs should look like e.g. file:///home/tux/Schreibtisch/gstreamer_3/test.mp3.

There’s a gst_filename_to_uri() convenience function to turn a filename into a URI (with proper escaping etc.)

My guess is that the pipeline wasn’t actually constructed and you got a NULL pointer back perhaps (although I’m not sure why that would be the case here).

1 Like

Thanks, now something is happening.
("playbin uri=file:/home/tux/desk/gstreamer_3/test.flac",
One slash is enough, you don’t need three.
But now the console is blocked until I press [CTRL-C].
I also suspect that there is something else besides loading a file via a URI?

I’m looking for an example where a FLAC or MP3 is played locally.
So far I’ve only seen examples that take the detour via URI.
Is this even possible, or does everything go via URI?

Not sure I understand the question.

It will depend on the elements involved. The reason most examples “take the detour” via URIs is that that’s the way their API is defined, e.g. playbin(3), uridecodebin(3) etc.

You can build pipelines with filesrc of course that don’t take a URI, such as:

$ gst-launch-1.0 filesrc location=foo.flac ! decodebin3 ! audioconvert ! audioresample ! autoaudiosink`
1 Like

@tpm

Now I understand what you meant. What you have in the command line can also be passed to gst_parse_launch(...).

Here is the solution for an MP3.

    pipeline = gst_parse_launch("filesrc location=test.mp3 !  mpegaudioparse ! mpg123audiodec ! audioconvert ! audioresample ! pulsesink", 0);