GStreamer SDK for Windows


Fluendo and Collabora announced GStreamer SDK for several platforms in November last year. I have written in the past about live streaming of WebM over HTTP using GStreamer and Node.js. I decided to see what adaptations would be required on Windows with the new SDK.

Fortunately, the GStreamer pipeline in that post mostly works. The only element missing from the SDK is tcpclientsink. I was able to replace that with udpsink. Besides, GStreamer on Windows has some useful elements for capturing video and audio from devices:

  • dshowvideosrc
  • dshowaudiosrc

Modified source code that uses these elements and works on Windows follows. You’ll need to install the Windows version of the GStreamer SDK. You’ll also need Node.js and the express module to be able to execute the script below. After executing the script, access http://localhost:9001 in any browser capable of WebM playback. A media player such as VLC will also work.

var http = require('http')
var express = require('express')
var dgram = require('dgram')
var child = require('child_process');
 
var app = express();
var httpServer = http.createServer(app);
 
app.get('/', function(req, res) {
  var date = new Date();
 
  res.writeHead(200, {
    'Date':date.toUTCString(),
    'Connection':'close',
    'Cache-Control':'private',
    'Content-Type':'video/webm',
    'Server':'CustomStreamer/0.0.1',
    });
 
  var udpServer = dgram.createSocket('udp6');
    
  udpServer.on('message', function(msg, info) {
    res.write(msg);
  });
  
  udpServer.on('close', function() {
    res.end();
  });
 
  udpServer.on('error', function(error) {
    res.end();
  });
  
  udpServer.on('listening', function() {
    var cmd = 'gst-launch-0.10';
    var address = udpServer.address();
    var args =
      ['dshowvideosrc', 
      '!', 'ffmpegcolorspace',
      '!', 'vp8enc', 'speed=2',
      '!', 'queue2',
      '!', 'm.', 'dshowaudiosrc',
      '!', 'audioconvert',
      '!', 'vorbisenc',
      '!', 'queue2',
      '!', 'm.', 'webmmux', 'name=m', 'streamable=true',
      '!', 'udpsink', 'clients=localhost:'+address.port];
    var options = null;
 
    var gstMuxer = child.spawn(cmd, args, options);
 
    gstMuxer.stderr.on('data', onSpawnError);
    gstMuxer.on('exit', onSpawnExit);
 
    res.connection.on('close', function() {
      gstMuxer.kill();
      udpServer.close();
    });
  });
  
  udpServer.bind(0, 'localhost');
});
 
httpServer.listen(9001)
 
function onSpawnError(data) {
  console.log(data.toString());
}
 
function onSpawnExit(code) {
  if (code != null) {
    console.error('GStreamer error, exit code ' + code);
  }
}
 
process.on('uncaughtException', function(err) {
  console.debug(err);
});

The video has no audio though. It may have something to do with my PC, a simple pipeline such as:

gst-launch-0.10 dshowaudiosrc ! autoaudiosink

Produces the following messages and does not work:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstAudioSrcClock
WARNING: from element /GstPipeline:pipeline0/GstDshowAudioSrc:dshowaudiosrc0: Can't record audio fast enough
Additional debug info:
gstbaseaudiosrc.c(840): gst_base_audio_src_create (): /GstPipeline:pipeline0/GstDshowAudioSrc:dshowaudiosrc0:
Dropped 22050 samples. This is most likely because downstream can't keep up and is consuming samples too slowly.

Keep you posted on a fix when I find one.

2 thoughts on “GStreamer SDK for Windows

  1. I tried this on linux, substituting ‘dshowvideosrc’ with ‘videotestsrc’ and ‘dshowaudiosrc’ with ‘audiotestsrc’, but unlike the tcpclientsink example, this does not work. How can it be?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s