Present Perfect


Picture Gallery
Present Perfect

GStreamer, appsink and CRC32

Filed under: GStreamer,Hacking,Python — Thomas @ 10:50 am

10:50 am

Slowly flexing my GStreamer muscles again in preparation for a real application.

Yesterday I wanted something that allowed me to calculate CRC’s of decoded audio files, to be able to calculate the CRC of a ripped file.

There’s a few ways to do this using GStreamer, none of them code-free.

I assume the ‘correct’ way would be to write a filter element that calculates the CRC as buffers come in. In the olden days this would involve a lot of boiler plate code in C, and a small processing function.

Today, in C, this would be easier, since you could probably simply subclass basetransform.

You could write either in Python as well these days.

Then there’s the ‘get data out of GStreamer’ approach. This used to be done using identity and the handoff signal.

The new, approved, API-stable way is to do this using appsink, one of two elements (with a helper library, of which I don’t yet see the point) recently moved to gst-plugins-base.

Using appsink is probably the approach that involves the least code to write. You can set up a pipeline, set it to PLAYING, and just pull buffers in a blocking fashion (which is easier code to write, but harder to slap a GUI on later)

Here’s the example code. You might note that there is an ugly try/except which I suspect is some bad handling inside gst-python or pygtk for errors during signal handling/emission.

It is a deceptively simple way to get data out of a pipeline and processed, and I’m glad we have a guaranteed way of doing this sort of operation now for the many people who want to dip their toes into GStreamer instead of diving in. I do hope they will at least consider the full dive still though.

Side note 1: GStreamer heads are free to share their opinion on what *should* be the correct way for data analysis operations like this. Years of brainwashing still lead me to believe that the answer would be ‘write a filter element’.

Side note 2: I’ve been toying with the idea of making a python class for ‘asynchronous operations’ that would wrap a GObject main loop doing the processing, and implementations can then subclass and implement some simple methods. This would make it easy to attach that operation to a GUI element (for example, a progress bar) automatically, or adapt it into a linear, blocking operation for command line applications. I can’t imagine this would be a novel idea, I’m sure someone else has done this already, anyone know what I’m talking about or have any suggestions ?


Filed under: Fluendo,GStreamer,Hacking,Life,Music,Python,Spain — Thomas @ 7:10 pm

7:10 pm

Hard to believe that next week it will be Five Full Years I live and work in Barcelona.

It seems like only yesterday that I closed the door on the empty house I then shared with three good friends, and drove our truck through the icy mist on to a new life. That night where we had no place to live I passed by my grandmother’s house for dinner, a few hours late. My grandmother’s not here anymore. Neither is her house. At least part of her floor is now the floor of my apartment.

Originally we planned to give it a try and see after a year. And then one turned into two, then two-and-a-half, and now five.

When I left there wasn’t even a company yet to give me a contract. Now we’re three companies, and our fifth move has taken us to an office of around 50 people now, and already people are complaining again about space. Par for the course.

I also guess I never actually publically informed about my move from Fluendo to Flumotion – it was just a logistical confirmation of a practical situation. Today Julien is managing Fluendo (the GStreamer/codecs/DVD company), and Elisa was always managed by Lionel anyway. And Flumotion is a full-blown commercial company.

Meanwhile, after a bit of a hiatus on my GStreamer involvement, I am slowly coming back to my plans of using GStreamer – the plans I had originally when I discovered GStreamer more than 7 years ago. I just reread my first post the mailing list, from April 10th 2001 – at least it wasn’t a completely stupid question.

My original plan was to write some code that would play your music just like a radio would. Nicely mixed, correctly levelled, a good flow between songs, and playing what you like to hear. An extension of the thesis project I did a long time ago which I used in our student radio at the time.

But GStreamer being what it was at the time, I got sucked into the vortex and didn’t really work on these ideas for a long time. I took a quick stab at it during 0.8 in the form of gst-python’s gst.extend.jukebox which worked quite well already on the mixing front, but when it got ported to 0.10 using gnonlin it just never worked for me and was left abandoned.

So third time’s a charm. After close to 10 years of random hacking, it’s about time to decide on one good personal project to invest my time in before life takes over. And this time I think I want to write something that not only Linux people can use. I want to write something that my friends can use too, and that means it has to work on Windows.

My motivation comes from being annoyed at not being able to listen to my music the way I should want to. I’ve been lax at ripping my new CD’s over the last 5 years, and a 300 CD backlog to show for it. My automatic playlists reflect my tastes of five years ago, and only once in a while do I bother to get some new tracks on one of my three computers or my Nokia, to which I then listen only in certain conditions. And every player I deal with annoys me to some extent. And none of them do any kind of decent crossfading, if at all.

I’m not promising anything yet, and I’m only at the beginning, but my experience makes me a happier hacker, advancing quicker from the idea to the code stage than way back when. That’s a nice feeling. Over a few two hour nightly sessions, I’ve put together some code that analyzes tracks, calculates RMS and attack/decay envelopes, and puts together a half decent mix. I’ve written a simple example using gnonlin which allows me to pre-listen these mixes, playing 5 seconds of the first track alone, then the mix, then 5 seconds of the second track alone.

This makes it a lot easier to evaluate different mixing strategies, making them easier to tune later on. I’ll have a fun plane trip with my laptop, earphones, and three batteries.

If you happen to be adventurous and interested, you can always check out the repository and play around a bit and see if it can mix your tracks at all.

So, I’m celebrating my Lustrum of Fluendo and Barcelona with a bit of code for a new project!

Sadly, the names I was considering a few years ago were already taken – pyjama is now a jamendo python application (mine would have been Just Another Music Application – in Python), and Orpheus, which also exists. So for now I recycled a name of a previous project that handled another aspect of the problem.

8 hours of plane hacking baby! Here I go.

Random updates

Filed under: Belgium,Conference,GNOME,GStreamer,Life,Spain — Thomas @ 11:59 am

11:59 am

Looks like I caught part of the flu my Barcelonan flat mate was having. It started – as these things usually do – on Friday evening. My psyche knows when it’s the weekend and when I want to relax, and schedules diseases breaking out accordingly. I’d feel guilty about getting ill on working days, I’m sure.

We had a BBQ planned on Sunday with our old sport club – our yearly meeting. A simple flu wouldn’t stop me from having it, even though we took over organizing it from the original instigator (and used Doodle to do so – do yourself a favor and use it every time you’re planning something with friends to avoid fifteen thousand mails going “I can’t on that date, how about that date” – I wish I had thought of that site)

BBQ was excellent, save for the fact that the ten-year-old-but-still-in-a-box-deluxe-barbecook was missing a whole bag of nuts and bolts. Peter to the rescue by going to the hardware store and getting some basics to at least allow us to have the BBQ itself working. And affected as I was by the flu apparently I didn’t bring home charcoal but vineyard branches – not a good fit for the barbecook.

But all was well after a short wait and the meat was excellent, as was the company. And we even got some sports done.

Today being San Joan in Barcelona – my least favourite holiday, 6 year old kids running around at night shooting off fireworks without regards for their own or my life – I decided to stay home this week. I’m happy I decided to stay here because it’s no fun travelling while ill. This also allows me to focus on setting up our new virtualized development platform at work, because we’re working on a near-seamless migration from our old platform code to the new version. Flipping the big red switch just isn’t a responsible way of migrating customers anymore.

Kristien took advantage of me staying to work from home this week and went out yesterday to get a new kitten. His name’s Tonie (staying with the cat meme we started with Lunya), he’s mostly black but with white paws, a white jaw, and a bit of white across his face. As far as kittens go, this is one of the more active I’ve seen – up and about and trying to break free from his temporary “get-used-to-a-new-place” area in two hours. Usually a kitten takes about a day hiding behind some couch in a corner to adjust. Also, this kitten hardly made a peep while Kristien drove him home – an hour car ride and only six meows. Lunya would wail like a baby the whole drive.

Anyway, I’m sure you all know kittens are cute and heartbreaking. This one’s up and about and alternating between discovering this new place and resting on my lap.

In the end I’ve decided not to go to GUADEC this year, and go to Europython instead. It’s not really a very calculated or well-thought out decision – I was hung up on deciding ever since I realized they were on at the same time. I probably would have booked for both months ago if they had been separate.

It’s not that I don’t want to go to Istanbul – I do, but holy shit, is it expensive – and it’s not that I don’t want to see all my GNOME friends again. I’m interested in the debate our dear rabble rouser has started, though I doubt people will get anywhere on that.

Maybe it’s simply fatigue – I have to agree with some people that there isn’t that much variety compared to other years looking at the schedule. Possibly it’s also the fact that I haven’t contributed much of anything at all to GNOME over the last year. I’m sure that’s largely due to my focus having changed a lot. My involvement in GStreamer as well has waned over the last year, for various reasons I’ll save for a possible other post.

Europython was fun last year, it’s nice to see a different community interact once in a while. Breaks the entrenchment one gets into. It’s also more work-related – we’re looking for people with Python skills, so it makes more sense to go to Europython.

In the end, it wasn’t a single thing that made me decide, it’s really just a flip of a coin decision, and I’m sure I’ll regret it somewhere down the line. Chosing is losing.

So, with my birthday coming up (and now having decided to have it in Vilnius) I’ve cleaned up my Amazon wish lists and ordered myself some goodies off of it already. Which leads me to wonder two things related to Amazon.

First of all, why does Amazon even *have* different frontend sites for different regions ? And why do these sites not interact in any way at all ? Every link on the web to an amazon item are always to the US version, so I always end up having a US wish list, though it is weird to order stuff from the US if it’s also available on any of their regional sites.

Which leads me to point two – how is it still possible that ordering the same stuff from the US just comes out huge chunks cheaper than ordering it from the .uk or .fr sites ? And that’s even when I choose priority air shipping. Shouldn’t it be a hell of a lot cheaper to ship from their European warehouses ? Is this just the weak dollar ? Should I delete my UK wish list entirely anyway (which I only started for DVD’s because of region coding and PAL vs NTSC) ?

Anyway, enough influenced posting for today. Time to do some non-work work.

catching up

Filed under: Fluendo,GStreamer — Thomas @ 2:17 pm

2:17 pm

on some old slashdot headlines – I never make any more time for this these days.

But this snippet (from this article) was awesome to read:

Marlin says that that CoreCodec has established a new internal process for handling intellectual property issues so that they won’t improperly use the DMCA again in the future. CoreCodec will also be assisting Nisota with his ongoing development efforts to ensure that coreavc-for-linux users can continue buying and using the CoreAVC codec. In the long-term CoreCodec also hopes to release a GStreamer-based CoreAVC codec so that they can officially support Linux users.

Or to put it in Catherine Wheel terms – I’ve finally arrived. It’s awesome to see codec companies equate “officially supporting Linux users” with “release a GStreamer codec”.


Filed under: Fluendo,GStreamer — Thomas @ 3:39 pm

3:39 pm

I have yet to try Second Life myself (it’s for work, honest – I need to see whether we can stream out of the box to it!), but the next version of the Linux client will use GStreamer.  The fact that I can’t recall seeing any linden labs email addresses asking questions on the list is probably a testament to how far GStreamer has come over the years.  They don’t even need to ask questions anymore!

In unrelated news, this afternoon a single one of our customers managed to peak over 1 GBit/sec on our platform.  Kaching.  Next stop, 5 Gbit/sec.

« Previous PageNext Page »