GStreamer Raspberry Pi

Hey! I have gotten myself Raspberry Pi and want to use it to run gstreamer applications (audio only), could raspberry run it without huge delays and I mostly have a question about which OS is the best to install for it? Just go for simple Raspberry Pi OS or do I install something like debian (i need console only as it will run gstreamer only)

What kind of audio processing applications / pipelines do you want to run?

I’d expect most audio pipelines to work just fine on RPis, but it always depends on the details of course.

Raspberry Pi OS is basically Debian under the hood, and should be good for starters, especially since there’s a lot of community support for it, but the GStreamer versions on it might not be the most recent (which may or may not matter for your use case).

1 Like

Hey! Thanks for your reply, im looking for a simple pipeline get audio from udpsrc and play it synced with other RPis and PC that will be udpsink, maybe at later day i will not stream pure raw audio but also add encoder and decoder to use less network, but for now raw audio is enough.

Pipeline example:

    // Create elements
    source = gst_element_factory_make("udpsrc", "source");
    parser = gst_element_factory_make("rawaudioparse", "parser");
    queue = gst_element_factory_make("queue", "queue");
    converter = gst_element_factory_make("audioconvert", "converter");
    resample = gst_element_factory_make("audioresample", "resample");
    vol = gst_element_factory_make("volume", "volume");
    sink = gst_element_factory_make("wasapi2sink", "sink");

    if (!m_pipeline || !source || !parser || !queue || !converter || !resample ||  !vol || !sink) {
        std::cerr << "Failed to create elements." << std::endl;

    // Set properties on the elements
    g_object_set(source, "port", arg_port, nullptr);
    g_object_set(source, "multicast-group", arg_multicast_ip.c_str(), nullptr);
    g_object_set(source, "buffer-size", 128, nullptr);
    g_object_set(parser, "use-sink-caps", false, nullptr);
    g_object_set(parser, "sample-rate", sampleRate, nullptr);
    g_object_set(parser, "num-channels", 1, nullptr);
    g_object_set(queue, "min-threshold-time", (guint64)10000000, nullptr);
    g_object_set(vol, "name", "streamVolume-Client", nullptr);
    g_object_set(sink, "device", m_deviceId.c_str(), nullptr);

Pipeline could probably be more optimised and stuff, but this is all POC only for now.

Edit: I am aware wasapi2sink wont work on RPi this was my POC for windows before getting RPi

This looks like something that should work on any RPi, and the distro / GStreamer version probably doesn’t matter too much (newer is always better ofc).

I assume you have control over both the sender and the receivers?

If so I would recommend using a session protocol like RTSP here, which should be quite easy to implement with gst-rtsp-server. The advantage of that is that you can distribute an NTP/PTP clock and timing info for client synchronisation as well that way, and gstreamer clients can just pick it up automatically. Transport can still be via multicast/UDP.

If you want to hand-roll it I’d still recommend using RTP at least (i.e. rtpL16pay / udpsrc ! rtpjitterbuffer latency=50 ! rtpL16depay etc)

1 Like

I do have access to both correct, I will check out RTSP server, thank you for answers and tips!

There are some minimal examples in the gst-rtsp-server git repository for what it’s worth:

(need to be tweaked for audio obviously, but should work in principle, hopefully)

I have a Pi 4B running GStreamer from Mopidy, decoding flac files up to 6 channel 96kHz 24 bit, performing 10-band equalisation and producing a 96kHz 32 bit stereo stream - a lot of work to do in real-time. In my case GStreamer is run by Mopidy.
To do synchronised playback to multiple devices have a look at Snapcast. I run Snapserver on the same Pi as Mopidy & GStreamer and multiple Snapclients running on another Pi. All works well. Still refining my pipeline.