Tuesday, August 28, 2012

Cheese live from GStreamer Conference 2012

Greetings from San Diego!

Had a good time at the GStreamer Conference, seeing folks from Collabora, chatting, having a few beers, watching talks and some hacking. Good days :)

That's not what I want to talk about. I just want to announce this picture:


It is (likely) the first picture taken with Cheese using GStreamer 1.0 :)

Here's a fast wrap up on the changes:

  • Camerabin2 is now mostly ported, just a annoying bug left on video recording.
  • I believe most video effects were already ported some months ago (and they work, see the picture ^)
  • Very easy to port Cheese to 1.0. Seriously, application's API hasn't changed much.
  • There will be bugs and there are still some critical asserts being printed, but the hardest part is over now.
The ported version is in a branch at http://cgit.collabora.com/git/user/thiagoss/cheese.git/, I'll get it reviewed by Cheese developers before putting it into the official repository.

That's it, time for the last talk of the conference and then have some fun. o/

Tuesday, January 18, 2011

A renegotiate event for GStreamer

Currently we have a problem at GStreamer that we can only make an element renegotiate using pad buffer allocs. Check the function documentation for understanding how it works.

By using pad buffer allocs, one element can ask downstream if it wants a new caps, but it can't tell upstream to pick a new caps. This would help in dynamic pipelines and applications that do element hot-swapping, which might happen on camerabin(2).

So I started a first attempt at creating a new upstream event to make the pipeline (or a part of it) do a new caps negotiation, trying to pick optimal caps.

I had 2 basic use cases in mind:
  • videotestsrc ! capsfilter name=cf ! fakesink
  • videotestsrc ! capsfilter caps="" ! ffmpegcolorspace ! videoscale ! capsfilter name=cf ! fakesink
In both cases, the capsfilter named 'cf' would change its caps property periodically, making the pipeline renegotiate to pick a new compatible and optimal caps.

The resulting patches were really simple and I only modified basetransform and basesrc (other than adding the new event to core). Keep in mind that I'm still experimenting and we should search for regressions that this might cause. Next I'd like to go for a scenario with elements with multiple src/sink pads (demuxer/tee/selector).

The patches are on a gstreamer branch here and the test cases were added on a branch on my -base clone.

Thursday, December 2, 2010

Camerabin2

As some of you might know, there has been some plans for a new camerabin design on the wiki for some time.

Current camerabin uses a single pad to output data for the viewfinder, video recording and image capture. Two problems on this:

* Requires a mix of input/output-selectors and tricky switch handling code to keep buffers on their correct paths.
* Managing different caps on each output type (images/videos/viewfinder) isn't simple.

Those were the main reasons motivating us to rewrite this in a simpler way. So our adventure with camerabin2 begun. Long story short, we already have a prototype on gitorious and it has the minimum basic features: image capture, video recording and a viewfinder.

Here's a summary on the important changing parts, for more details refer to the wiki.

The key change
The big change is to have a source element (from now on called camera source) that has 3 source pads, one for each task: viewfinder, image capture, video recording.

Why doing camerabin2 and not refactoring camerabin?
The short answer is that it's a major design change we're taking here, writing from the ground up is probably safer and faster and won't bother people using current camerabin. Also, as it requires a new source element, we would cause major incompatibility with current sources.

Modules
We are aiming at a more modularized approach this time, so we have a viewfinderbin, a videorecordingbin and imagecapturebin, those are public elements that can be used outside of camerabin2.

The new 3 pad source
Thanks to Rob Clark's work from some time ago (he refactored camerabin into the new design as a proof of concept), we already got a working 3 pad source for testing our prototype. Truth be told, I haven't got really deep into the source internals working, but our goal is to provide a basecamerasrc which will make it easy (or at least, easier) to develop source elements with 3 pads.


Those are the main things I'd like to post here. I'm trying to schedule a meeting with developers interested on using camerabin2 (or that use camerabin) to discuss features, problems, requests and any camerabin2 related topic. Somewhere in the next days would be great. Nokia, Empathy and Cheese developers already showed interest on this. If you do, too, ping me on IRC (thiagoss at #gstreamer at freenode)

[Edited] Forgot to mention that the camerabin2 branch on gitorious already contains an example application under tests/examples/camerabin2.

Tuesday, May 11, 2010

gst-opencv design choices

While continuing wrapping new OpenCV functions into GstElements yesterday, I faced an interesting design choice on the mappings of OpenCV functions' parameters to GstElement's properties.

Take a look at cvSmooth docs. You can see that it has a type parameter, followed by param1, param2, param3 and param4 that have different semantics if different type is used. The question is how to expose those in the 'cvsmooth' GstElement?

I could think of 3 different choices here:

1) Go straightforward and use the same API as OpenCV
As a result, we should have an element with the properties named after the OpenCV parameters:
"cvsmooth type=blur param1=5 param2=3 param3=0.0 param4=0.0"

This results in a very not intuitive API, but we keep it aligned with OpenCV's, making it easy to people that already know one API to use the other one. The element docs would mostly point to OpenCV's docs. Resulting code is simple and easy to maintain.

2) Have multiple elements: cvsmoothblur, cvsmoothgaussian, cvsmooth...
We could have each smooth algorithm (type) into a separate element and have its properties reflect the semantics of this type. For example, we would have cvsmoothblur, cvsmoothmedian and one for each type. The properties of each one would named accordingly to its semantics, instead of some paramX.

This provides a nice API but might increase the number of elements for every function that has this type or a similar parameter. I don't know how common this is. This might be a good solution if there are a few of those. A downside is that switching the type has to use hot-swapping but I don't think this is a common use case.

3) Expose properties for each semantics and use them only if their type is selected.
We still keep it to one element, but we add one property for each semantic a parameter can assume. Those would only be used it we have its corresponding type is selected.

For example: param3 might be the "gaussian standard deviation" or the "color sigma" if type is gaussian or bilateral respectively. We add those 2 properties (standard-deviation and color-sigma) that are only going to be used if their types are selected.

This makes those lines possible:
"cvsmooth type=gaussian standard-deviation=5.0" or
"cvsmooth type=bilateral color-sigma=1.0"

Code is a little messier than options above.


Given those options, I really don't like option 3. I'm considering 1 or 2. From a quick look at some pages of OpenCV's transformations API I could see that this is not very common, and when it happens, only one parameter has a 'variable semantic', looks like I picked the trickiest one as my example.

So, which option would you chose?

Thursday, May 6, 2010

Hacking in gst-opencv

It has been years since I last used OpenCV. We (me and friends working on a lab at the university) used it to process images on batches or to process frames live from a webcam. Things could have been much easier if I knew GStreamer back then. Said so, I decided to take a look at gst-opencv to see what we already can do with it.

There are a few features wrapped as elements at this moment and they work quite well, but it could have a much larger feature set and it seems no one has been recently working on this. Given those and having a little spare time these days, I decided to start hacking on gst-opencv and trying to put it together with the other modules. I'd prefer to have a gst-opencv module, but adding it as a new plugin into gst-plugins-bad is also an option. What do you think?


Current features

[Edited: It seems the videos can only be seen directly on the post at blogspot]

Some nice stuff can already be done with the current elements. Let me show some.

I recorded this video outside some minutes ago:


We can use edgedetect on it and see its edges:
Command: gst-launch uridecodebin uri=youruri ! queue ! ffmpegcolorspace ! edgedetect ! ffmpegcolorspace ! theoraenc ! oggmux ! filesink location=result.ogg



Or we can segment it with pyramidsegment and have a nice effect (some people would enjoy this in PiTiVi?) or use it in machine vision stuff?
Command: gst-launch uridecodebin uri=youruri ! queue ! ffmpegcolorspace ! pyramidsegment ! ffmpegcolorspace ! theoraenc ! oggmux ! filesink location=result.ogg




OpenCV already ships some face detection profiles for you (at Ubuntu, it goes into /usr/share/opencv/haarcascades/), so you can use them with facedetect element, or train your own classifiers to use with it. I stood with the default and tried on some pictures, here are 2 of them:




I think it works pretty well :)
You can disable the circles and just get messages with the faces' positions and do whatever you want with them.

Other than those, there's also 'textwrite', 'templatematch' and 'faceblur' elements.


Current work

I've been working on a simple base class that will make it easier to map simple 1 to 1 OpenCV functions into elements and providing some common properties (like ROI and COI) and GstBuffer-IplImage conversion. This will help covering more functions and should be enough to get me acquainted again to the API, after it I can go for the fancier stuff.

For example, take cvSmooth function, we should only have to write code to map its parameters into properties and a simplified chain function that already works on IplImages instead of GstBuffers.


Repositories

gst-opencv's main repository is at github, I have my personal branches here. From time to time I ping Elleo to upgrade at github, but I hope we can get this upstream in the next weeks.

Monday, November 9, 2009

Trying GStreamer at Windows

Since I've started working with GStreamer I had never tried it out on Windows and tonight I decided to try it out. Edward pointed me to the winbuilds and it took no more than pressing 'next' 4 or 5 times to have default applications (gst-launch, gst-inspect...) and lots of plugins. Easy enough.

That must be the reason it has been some time since I've heard complaints about installing/using GStreamer on Windows. I wonder if there are any other builds out there like these?

Thanks ylatuya!

Wednesday, August 12, 2009

GstCollectPads2 branch

This week I decided to grab the GstCollectPads2 patch (from bug #415754) and start a branch in my freedesktop repository for porting muxers to it. So far we've got:
  • oggmux
  • avimux
  • matroskamux (patch by Mark)
  • asfmux
  • qtmux
If you always wanted GStreamer to be able to mux subtitles into your movies, now is the time to provide specs/samples/patches for it. And installing from this branch (I try to keep them up-to-date with current git master) and test it a lot in you favorite applications would help to find regressions from the porting process.

Suggestions to improve GstCollectPads2 or other use cases are also welcome.

Friday, July 24, 2009

asfmux is now at gstreamer-plugins-bad

I just pushed asfmux plugin into gstreamer-plugins-bad. So, forget the old repository, the recent code will now be at -bad.

And it now has mp3, wmv3 and wma3 support!

Thursday, July 16, 2009

Live streaming of ASF content

Just pushed a couple of changes to ASF muxer plugin that enable streaming live content of ASF media. Basically it contains some fixes to timestamping and a new boolean property to asfmux called "is-live". When enabled, asfmux won't attempt to push indexes at the end of the file (as this has no sense in live streams) and also won't try to seek back to the headers to rewrite some values that it couldn't predict when started the file.

Here is the simplest example of its use in gst-launch commands:

The sender:
  • gst-launch-0.10 -ve videotestsrc ! ffenc_wmv2 ! asfmux name=m is-live=true ! rtpasfpay ! udpsink host=127.0.0.1 port=3333 audiotestsrc ! ffenc_wmav2 ! m.
  • gst-launch-0.10 udpsrc port=3333 ! "put the caps here" ! rtpasfdepay ! decodebin2 name=d ! queue ! ffmpegcolorspace ! autovideosink d. ! queue ! audioconvert ! autoaudiosink
Remember to replace the caps after udpsrc with the caps of the srcpad of the rtpasfpay element in the first pipeline. If you have any problems using it, please report!

The asf plugin can be found here.

Tuesday, June 23, 2009

ASF: we need a parser

While developing rtpasfpay I found out that I can't just do (in gst-launch syntax):

somesrc ! asfmux ! rtpasfpay ! udpsink

because the ASF headers need to be updated after the stream ends and those values are needed by rtpasfpay.

Additionally, I can't get an ASF from a file and feed it to rtpasfpay because the buffers would be unaligned with the ASF objects and packets, requiring rtpasfpay to parse the data before doing anything related to RTP. I'd say we need a parser.

The idea is to do all the parsing at the parser (obvious) and only some checks of conformance at the rtp payloader. As I had already started developing the payloader, I took it as farther as I could (without using a parser) and its current state is now at the repository. It is still unfinished (read: doesn't work).

The parser
Now I'm starting to develop the asfparse element. ASF files have 3 main parts: first there are headers, then the data (where the packets are) and lastly a series of indexes objects. The parser would, sequentially:
  1. Group all the headers into a single buffer and push it
  2. Push the "Data object" header (everything but the packets)
  3. Put each packet into a separate buffer and push them
  4. Put each of the indexes object into a separate buffer and push them
  5. EOS
The parser should work both in pull or push mode, I'll start with push mode.

Monday, June 15, 2009

asfmux: index fixed, new formats

Latest asfmux changes:
  • fixed simple index (seeking works)
  • Support for wma version 1
  • Support for wmv version 1
  • Preroll time property
  • Packet size property
  • file id generation (instead of a previous hardcoded all zeroes)
I'd consider it ready to be called a basic asf muxer.
Feature suggestions are welcome.

Tuesday, June 9, 2009

ASFMux progress report

I ran some tests with asfmux yesterday and it is now capable of muxing wma2 and wmv2 nicely. Played the resulting files at totem, mplayer and media player.

The file indexes are still badly broken, so trying to seek might result in unexpected behaviours or crashing. I'm trying to fix that.

Monday, May 25, 2009

GSoC Status

GSoC's coding period started saturday and, as I've been coding a little since the accepted students announcements, I've got some results.

With a lot of help from Mike, that is also working with ASF, asfmux currently is capable of muxing WMAv2 and WMVv2, which means that most of the base code of the muxer is ready. It still lacks the indexes, but that's what I'm working on these days.

Unfortunately, I still won't be working full speed at GSoC 'till the end of next week, when I'll be on university vacation.

If you'd like to take a look at the code, my repository is here.

Wednesday, May 6, 2009

ASF Inspect Tool

So, if you are learning/working on ASF media, Microsoft has this tool[1] for Windows (it's free) that might help you, I just found it and haven't really tested it, just explored some files and it is much better than opening them in ghex.

[1] http://www.microsoft.com/windows/windowsmedia/forpros/format/asfviewer.aspx

Wednesday, April 29, 2009

GSoC '09 Start up

Finally got some time to post here about me getting accepted into GSoC this year! Yay!!!

The project
Basically, develop ASFMux and RTPASFPay (or something more readable than this). ASFMux will be featureful, supporting stream prioritization, stream mutual exclusion and timed scritpting. David Schleef will be my mentor this year.

I'll be hosting my code in my personal freedesktop git repositories. Initially I thought on using a branch out of -plugins-bad, but then I thought that it would be better to have a single plugin tree, because people can build and install without destroying their -plugins-bad install.

Current stage
So far I got a basic muxer stub and started working on sending the header bytes. The code at git has a trunk base folder, but that's because I started working with svn and them migrated to git, I'll remove that in my next push.

I just wanted to make the project start public. I'll be updating the status of it here regularly.

Now I need to get some sleep, it's getting late here. Good night!

Wednesday, April 22, 2009

GSoC '09 UFCG Status

UFCG (Universidade Federal de Campina Grande) is the university I study at, and last year it seems that I was the only one that applied to GSoC

This year, I decided to spread the word about it and motivate people to participate. When the program was announced I kept sending information and tips on the students mailing lists and giving short presentations about the program. Happily, we got 5 students accepted this year! Much better than only 1 last year. They are (name - project - course):
  • André Dieb Martins - Enlightenment - Electrical Engineering
  • Danilo Araújo de Freitas - Python - Computer Science
  • Felipe Ribeiro Nogueira Barbosa - PHP - Computer Science
  • Thiago de Freitas Oliveira Araújo - NuiGroup - Electrical Engineering
  • Thiago Sousa Santos (me) - GStreamer - Computer Science
Congrats you all and to all other accepted students. Time to work hard and complete your projects!

Thursday, April 9, 2009

Telepathy tutorial

That was the search I tried at google while I started to study telepathy, but it was amazing and funny the amount of tutorials I found on telepathy (the psychic stuff). I didn't try them, if someone feels up to it, please tell me how did it go :-P

After reading telepathy wiki, I went to #telepathy and davyd pointed me to the book they're writing, and so far it was the better source of information about it. If you are willing to learn about telepathy, try it out and give them feedback.

Friday, March 27, 2009

New feature on gst-launch

Now you can add the flag --eos-on-shutdown (or simply -e), meaning that you want it to send EOS to the pipeline even when you stop it by sending a sigint (ctrl + c). This way, the EOS will travel through the elements, and they can finish properly their work. This is important for muxers.

When -e is enabled, if you press ctrl+c and it hangs while waiting for the EOS, just press again and the default behaviour will be executed (shut down the pipeline immediately and quit).

A example use case for the feature: to receive and mux live streams using gst-launch.

For the devels: the commit - the bug

Thursday, March 12, 2009

Happy new year!

This year had a slow start, but it seems that things are heating up.

1) I decided to be back on bikes (after 5 years), going twice a week for about 30km, starting at 5 AM. Surprisingly, I'm riding with the same group I used to and they remember me (I was 15 by that time!). Note: I need a new bike.

2) Google's Summer of Code is starting again this year and I'll try to participate again for GStreamer. From the tasklist, ASF muxing support and mpeg2ts interested me the most. But I'm open to suggestions.
Also, I've been asked to do a small presentation at the university to the Computer Science department (students and teachers) next wednesday. And I've already started reading ASF spec.

3) University classes are back (1 year to finish it!)

4) As my undergraduation is almost over, the amount of requests for small parallel projects has increased, which is good, most of them are simple web-based CRUD applications. They take little time and are a good source of money for a student.

Finally it is starting! Happy new year, everyone!

Thursday, September 18, 2008

mpeg4 trouble

Expanding qtmux to support mpeg4 was going all well, everything was almost ready! Then the ES Descriptor appeared. For .mov files it was only used for AAC description atoms. For mpeg4 it has to be used for every format, and:
  1. This ES Descriptor has a DecoderConfigDescriptor that has 'objecttype' and 'streamtype' integer fields that would identify the stream format and I can find no info on how to map the formats to those values (other than AAC).
  2. The DecoderConfigDescriptor has some 'bitrate' and 'decoding buffer size' fields which aren't usually provided by GStreamer, so I'm just filling that up with zeros.
If there is someone out there that knows how to map formats to those fields or any idea on how GStreamer could provide bitrate (perhaps tag events?) I'd really appreciate some help. I've been stuck for almost a week.

Also I've started to test the mpeg4 files in a PS3, too bad it doesn't give meaningful error messages.