Introducing peerflixsrc

Some of you might have been following all the brouhaha over Popcorn Time. I won’t get into the arguments that can be made for and against at the moment.

While poking around at what it was that Popcorn Time was doing, I stumbled upon peerflix, a Node.js-based application that takes a .torrent file that points to one big video file, and presents that as an HTTP stream. It has its own BitTorrent implementation where it prioritises early chunks of the file so that it is possible to start watching the video before the entire file has been downloaded. It also seeds the file while the video is being watched locally.

Seeing as I was at the GStreamer Hackfest in Munich when this came up in discussions, it seemed topical to have a GStreamer element to wrap this neat bit of functionality. Thus was peerflixsrc born. This is a simple source element that takes a URI to a torrent file (something like torrent+, fires up peerflix in the background, and provides the data from the corresponding HTTP stream. Conveniently enough, this can be launched using playbin or Totem (hinting at the possibilities of what can come next!). Here’s what it looks like…

Screenshot of Totem playing a torrent file directly using peerflixsrc
Screenshot of Totem playing a torrent file directly using peerflixsrc

The code is available now. To use it, build this copy of gst-plugins-bad using your favourite way, make sure you have peerflix installed (sudo npm install -g peerflix), and you’re good to go.

This is not quite mature enough to go into upstream GStreamer. The ugliest part is firing up a Node.js server to make this work, not the least because managing child processes on Linux is not the prettiest code you can write. Maybe someone wants to look at rewriting the torrent bits from peerflix in C? There don’t seem to be any decent C-based libraries for this out there, though.

In the mean time, enjoy this, and comments / patches welcome!

GStreamer Hackfest 2014

Last weekend, I was at the GStreamer Hackfest in Munich. As usual, it was a blast — we got much done, and it was a pleasure to meet the fine folks who bring you your favourite multimedia framework again. Thanks to the conference for providing funding to make this possible!

My plan was to work on making Totem’s support for passthrough audio work flawlessly (think allowing your A/V receiver to decode AC3/DTS if it allows it, with more complex things coming the future as we support it). We’ve had the pieces in place in GStreamer for a while now, and not having that just work with Totem has been a bit of a bummer for me.

The immediate blocker so far has been that Totem needs to add a filter (scaletempo) before the audio sink, which forces negotiation to always pick a software decoder. We solved this by adding the ability for applications to specify audio/video filters for playbin to plug in if it can. There’s a now-closed bug about it, for the curious. Hopefully, I’ll get the rest of the work to make Totem use this done soon, so things just work.

Now the reason that didn’t happen at the hackfest is that I got a bit … distracted … at the hackfest by another problem. More details in an upcoming post!

Picking your battles

Most of you have no doubt already seen that Mozilla will be changing their position on H.264 support for HTML5 video in future releases. This is an extremely important decision that I’ve been hoping to see for a while now, and I am really glad this is being done.

There is no doubt that we need patent-unencumbered standards for web codecs (or as much as is possible given the dismal patent ecology today), and while much giddy anticipation followed Google/On2’s release of VP8 into the open, I don’t believe it ever made sense to expect the codec landscape to change drastically in the short timespan everyone expected. There’s a lot of the hardware and software out there that needs to change (see any SoCs with VP8 support yet?), not to mention the interests of the MPEG-LA mafconsortium.

I love Firefox, both as a product and what it means for an open web (for those of you that know me, this might be hard to believe given all my ranting, but it’s true!). I’m glad Mozilla chose to live to fight another day rather than go out in a blaze of glory and (or a flicker of irrelevance).

p.s.: these are my views and do not necessarily represent those of my employer

p.p.s.: Alessandro’s been doing some great work to get the GStreamer multimedia backend going again (this makes so much more sense than going the NIH route!)

More PulseAudio power goodness

[tl;dr — if you’re using GNOME or a GStreamer-based player, not using the Rhythmbox crossfading backend, and want to try to save ~0.5 W of power, jump to end of the post]

Lennart pointed to another blog post about actually putting PulseAudio’s power-saving capabilities to use on your system. The latter provides a hack-ish way to increase buffering in PulseAudio to the maximum possible, reducing the number of wakeups. I’m going to talk about that a bit.

Summarising the basic idea, we want music players to decode a large chunk of data and give it to PA so that we can then fill up ALSA’s hardware buffer, sleep till it’s almost completely consumed, fill it again, sleep, repeat. More details in this post from Lennart.

The native GNOME audio/video players don’t talk to PulseAudio directly — they use GStreamer, which has a pulsesink element that actually talks to PulseAudio. We could configure things so that we send a large amount (say 2 seconds’ worth) to PulseAudio, sleep, and then wake up periodically to push out more. Now in the audio player (say Rhythmbox), the user hits next, prev, or pause. We need to effect this change immediately, even though we’ve already sent out 2 seconds of data (it would suck if you hit pause and the actual pause happened 2 seconds later, wouldn’t it?). PulseAudio already solves because it can internally “rewind” the buffer and overwrite it if required. GStreamer can and does take advantage of this by sending pause and other control messages out of band from the data.

This all works well for relatively simple GStreamer pipelines. However, if you want to do something more complicated, like Rhythmbox’ crossfading backend, things start to break. PulseAudio doesn’t offer an API to do fades, and since we don’t do rewinds in GStreamer, we need to apply effects such as fades with a latency equal to the amount of buffering we’re asking PulseAudio to do. This makes for unhappy users.

Well, all is not as bleak as it seems. There was some discussion on the PA mailing list, and the need for a proper fade API (really, a generic effects API) is clear. There have even been attempts to solve this in GStreamer.

But you want to save 0.5 W of power now! Okay, if you’re not using the Rhythmbox crossfading backend (or are okay with disabling it), this will make Rhythmbox, Banshee, pre-3.0 Totem (and really any GNOMEy player that uses gconfaudiosink, which will soon be replaced by gsettingsaudiosink, I guess), you can run this on the command line:

gconftool-2 --type string \
    --set /system/gstreamer/0.10/default/musicaudiosink \
    "pulsesink latency-time=100000 buffer-time=2000000"

On my machine, this brings down the number of wakeups per second because of alsa-sink to ~2.7 (corresponding nicely to the ~350ms of hardware buffer that I have). With Totem 3.0, this may or may not work, depending on whether your distribution gives gconfaudiosink a higher rank than pulseaudiosink.

This is clearly just a stop-gap till we can get things done the Right Way™ at the system level, so really, if things break, you get to keep the pieces. If you need to, you can undo this change by running the same command without the latency-time=… and buffer-time=… bits. That said, if something does break, do leave a comment below so I can add it to the list of things that we need to test the final solution with.


Portage 2.1_pre1 is in portage and marked ~x86. Improvements include a revamped cache (why am I not seeing the difference), elog to help track einfo/ewarn/eerror messages better. Wheee!

And if you haven’t already, emerge ferringb‘s awesome confcache for caching the autoconf stuff.

Does anybody know a good place to get high-quality CS GATE practise papers?

Mobile * Mail

So There’s GMail Mobile now. Doesn’t work on my T630 (yet, I hope). Yahoo’s WAP access is pretty good. One wonders how long this mutual catch-up game will continue. Rather amusing.

Hope to have an AMD64 box in less than a month.

An interesting thing to note — tags – gotta love ’em. But most people just create random tags based on content. I try to keep a limited number and organize them instead. It’s a little painful too keep track of previous tags (unless you’re using, which gives you a list of existing tags (tangent — their Firefox plugins sucks. It’s too obtrusive. The existing one on MozDev r0x0xr5.)). Anyway, the point is that I see tags being used rather haphazardly, rather than to provide organizational metadata. Or maybe I’m just an order freak.

Reading Richard Dawkins’ The Selfish Gene. Got me thinking about my “everything is random” theory. Which now officially explains The State of Things. Assume that everything that happens is truly random. Thus basic things happen with equal probability. Good Things, as we know, are created by a combination of many factors. Even if a few of these are not in place, you have a Bad Thing. Given the first assumption, all events are equally likely. Thus, the probability of a Good Thing existing is the product of the probability of occurrence of all individual contributing events. Since each of these is less than 1 (considerably so, by observation), the product is going to be far less than 1. The probability of Bad Things happening, is just 1 – P(Good Thing). Corollary — it is the nature of the Universe for just about everything to suck. And there’s nothing you can do about it, even if you knew how.

There. Aren’t you happier, now that you know?

Need to update my book list with all the new bookses.

As I said

Do you really want this to happen?

Yes, yes, I know it’s an old article – I’m just caatching up with my reading ever so slowly now.

Cairo is in Egypt

Cairo, which GTK+ 2.8 uses, makes DejaVu Condensed fonts (kind of like Bitstream Vera, only more complete and not so fat) look noticeably sharper. Or am I just imagining things? Does font rendering get assisted by Cairo, or is it only Xft?

In other news, life goes on. Work is work. Play is … hardly. Scaled a mountain a few weeks back. Okay, so it had steps, and it was called Tirumalai, but it was painful and unnecessary. We live in masochistic times – it was fun.

More to come later.


So I was watching one of Scott Wheeler’s presentations (link) on what will (hopefully) be KDE4’s new metadata system. The idea is to create a system where you give up the hierarchical (directory-based) paradigm in favour of a search-based one. Maybe the solution is too simplistic for now, and a hybrid model with a shallow hierarchy and mostly search-assisted access will be an intermediate, but I think it’s the way of the future. Anybody who’s used ‘* Desktop Search’ will know. The KDE, Gnome, and Reiser4 folks are pulling in different directions, but the final solution will have to be a mix of all of these – approximately respectively: desktop environment support for metadata collection, full-text indexing of files, and filesystem-level support for metadata storage.

One of the ideas is that when you open the File->Open dialog box in an application, you get a search tool rather than a file browser. The Gnome folks were also talking about this a while back on the Beagle mailing list. But what do we do about saving files? There’s too much data for sorting to be effective – think about how much e-mail you get, and how many files you have to work with, if you work with a computer for more than an hour each day. Chances are that it’s a whole bunch of data.

So have you ever used Or any other system that basically lets you “tag” the item your storing/saving/publishing? This should be a viable solution for the files on your hard-disk too. The File->Save dialog would basically ask you for a file name, automatically extract metadata such as the file type, author, source, etc. and also give you an interface to tag the file. Once the system has been in use for a while, you’ll have a bunch of common tags. Just pick the tags you want to apply, and you’re done. Of course, this requires a huge amount of dependence on your desktop environment alone – bye bye command line. Something to be thought about – a number of solutions are possible. A real live example of this is the plugin for Firefox. It officially replaced my Firefox bookmarks manager a few months ago.

Exciting times ahead for the desktop world.


So I’m at my parent’s place in Gurgaon. They have an Airtel DSL connection for Internet access. I brought Fedora Core 4 along to install on my Dad’s laptop, and what I describe here is how I did it. Hopefully it’s useful to someone.

Assumption – you’re using a USB DSL modem provided by Airtel which contains the Conexant Accessrunner chip. Mine says Beetel 100CX on the outside.

  • The driver isn’t in the kernel yet, so you need to get the tarball from
  • Decompress this into the kernel source directory (the incomplete tree in /usr/src/kernels/2.6.xx-xx-xx (from the kernel-devel package) will do).
  • [Thanks to Arun (yet another one!) for pointing out that this is missing] Enable the modules for these drivers as instructed in the “Configuring kernel build” section here.
  • In the top-level kernel directory, do a make M=drivers/usb/atm. Copy cxacru.ko and usbatm.ko to /lib/modules/2.6.xx-xx-xx/drivers/usb/atm.
  • Extract the firmware from the Windows drivers as described in (I got the utils directory from CVS, did a make and then ran it on the [WINDOWS_DIR]\system32\drivers\CnxEtU.sys
  • Copy the extracted firmware to /lib/firmware/cxacru-fw.bin
  • That’s the driver setup – when you plug in the USB modem, hotplug should pick up the correct kernel moduel and firmware. Any issues, run dmesg.
  • Use the Network config GUI to set up a new xDSL connection using some ethX device or the other. Edit /etc/sysconfig/network-scripts/ifcfg-[name_of_connection] and remove the ETH= line. Add 3 lines: VPI=1 VCI=32 Note that the VPI and VCI settings might vary for you. These work for Airtel in Gurgaon and Chennai, apparently.
  • That’s about it – you can fire off the connection using /sbin/ifup [connection_name] and down using /sbin/ifdown [connection_name]. Or use the GUI. The Modem Lights Applet doesn’t work with this yet.
  • Pay me a consultation fee. *Wink*

Too lazy to fix typos. Off to gloat to myself now. :)