Gstreamer Output

Peter Maersk-Moller

Output via GStreamer

This page has been obsoleted by the GStreamer Output Page on the new Snowmix website.

Updated for Snowmix 0.4.4 and GStreamer 1.x.

Snowmix Configuration

For snowmix to send the mixed video frames to output, Snowmix must have a configuration similar to the configuration shown below.

    port 9999
    geometry 1024 576 ARGB
    frame rate 24
    socket /tmp/mixer1
    feed idle 0 1
    stack 0

The first line tells Snowmix to listen for command and control connections on port 9999. The second line sets the system geometry, the geometry of the mixer to 1024x576 and use the internal pixel format ARGB (actually BGRA internally, but lets not get confused over this). The third line sets the mixer frame rate to 24 fps. The fourth line instructs Snowmix to use the socket /tmp/mixer1 for communicating with an external program using a GStreamer shmsrc interface for getting the mixed frames from Snowmix. Obviously your system must support shared memory. The fifth line sets the idle time for feed 0 to 1 frame. The fifth line instructs Snowmix to use stack or mix feed 0 onto the mixers output frame for every frame it will produce. Feed 0 provides a black background as the basis for the entire mixed frame unless configured for something different.

Obviously you will for most cases also want to add inputs and display them as shown in the GStreamer Input examples.

Getting mixed frames from Snowmix

The main loop of Snowmix, the mixing of video frames, is skipped until data is read on its output interface. No need to mix a frame that is never read. The output interface of Snowmix is compatible with GStreamer shared memory module shmsrc. The examples below shows how GStreamer can be used to read frames from Snowmix.

The first example will display the mixed frame on the local machine running Snowmix assuming it has a graphical display. It has been tested with GStreamer 0.10, 1.0.0 through 1.4.1 and 1.5.0.

    #!/bin/sh
    # Deliver mixer1 output to screen.
    # The geometry and framerate are from your system settings in Snowmix
    width=1024
    height=576
    framerate='24/1'
    which gst-launch-1.0 2>/dev/null 1>&2
    if [ $? -eq 0 ] ; then
      gstlaunch=gst-launch-1.0
      VIDEOCONVERT=videoconvert
      MIXERFORMAT='video/x-raw, format=BGRA, pixel-aspect-ratio=1/1, interlace-mode=progressive'
    else
      gstlaunch=gst-launch-0.10
      VIDEOCONVERT=ffmpegcolorspace
      MIXERFORMAT='video/x-raw-rgb, bpp=32, depth=32, endianness=4321, red_mask=65280, green_mask=16711680, blue_mask=-16777216, pixel-aspect-ratio=1/1, interlaced=false'
    fi
    $gstlaunch -v             \
        shmsrc socket-path=/tmp/mixer1 do-timestamp=true is-live=true      !\
        $MIXERFORMAT", framerate=$framerate, width=$width, height=$height" !\
        queue                !\
        $VIDEOCONVERT        !\
        queue                !\
        autovideosink

If the autovideosink fails for your system depending on your setup, then try one of the other videosinks such as xvimagesink, ximagesink, glimagesink etc. There are many to choose from depending on your system.

Stream RTP UDP from Snowmix

The example below encodes the output from Snowmix with x264 and send it to another host using RTP over UDP.

    #!/bin/bash
    # The geometry and frame rate are from your system settings in Snowmix
    width=1024
    height=576
    framerate='24/1'
    which gst-launch-1.0 2>/dev/null 1>&2
    if [ $? -eq 0 ] ; then
      gstlaunch=gst-launch-1.0
      VIDEOCONVERT=videoconvert
      MIXERFORMAT='video/x-raw, format=BGRA, pixel-aspect-ratio=1/1, interlace-mode=progressive'
    else
      gstlaunch=gst-launch-0.10
      VIDEOCONVERT=ffmpegcolorspace
      MIXERFORMAT='video/x-raw-rgb, bpp=32, depth=32, endianness=4321, red_mask=65280, green_mask=16711680, blue_mask=-16777216, pixel-aspect-ratio=1/1, interlaced=false'
    fi
    SRC='shmsrc socket-path=/tmp/mixer1 do-timestamp=true is-live=true'
    X264SETTINGS='bitrate=3000 tune=zerolatency speed-preset=5'
    $gstlaunch -v              \
        $SRC                  !\
        $MIXERFORMAT", framerate=$framerate, width=$width, height=$height" !\
        queue                 !\
        $VIDEOCONVERT         !\
        queue                 !\
        x264enc $X264SETTINGS !\
        h264parse             !\
        rtph264pay            !\
        queue                 !\
        udpsink clients=192.168.254.150:4012 sync=true

Obviously you will have to set the IP address and port to match your requirements.

Instead of the udpsink your could also replace it with a tcp server like this:

    queue ! tcpserversink host=0.0.0.0 port=4012 sync-method=2 recover-policy=keyframe

For more examples on outputting from Snowmix, please see the following scripts in the scripts directory of Snowmix:

  • output2dummy - reads video frames from Snowmix and discards them.
  • output2screen - reads video frames from Snowmix and displays them locally on screen.
  • output2file - reads video frames from Snowmix, encodes them and saves encoded stream in a file.
  • output2rtp - reads video frames from Snowmix, encodes them and stream them as RTP packets over the network.
  • av_output2dummy - as output2dummy, but also reads audio from Snowmix.
  • av_output2screen - as output2screen, bus also reads audio and plays audio.
  • av_output2tcpserver - reads video frames and audio, encodes video and audio and makes the muxed stream available on a tcp server.

Related

Wiki: Gstreamer
Wiki: Home