This is intended to be a hands-on introduction to GStreamer.
GStreamer is a multi-platform multimedia framework but heavily focused on the Linux desktop and specifically GNOME.
You'll need to get familiarized with some jargon:
- A GStreamer element is an object that can send and/or receive data
- An element that generates a data stream
- An element that transforms the data stream
- An element that receives a stream and doesn't redirect it
- A collection of linked elements
A typical pipeline would be: source -> parser -> decoder -> filter -> sink
The easiest way to get started with GStreamer is to use the basic tools (gst-inspect and gst-launch).
If you are really impatient you can try the following:
gst-launch-0.10 playbin uri="file://$PWD/Radiohead - Down is the New Up.flac"
The 'playbin' element is probably the magick element most people would end up using. You only need to pass the URL of the media stream you want to play and that's it.
If you want to go into further details with gst-inspect you can inspect all the available GStreamer elements like this:
coreelements: filesrc: File Source coreelements: filesink: File Sink decodebin2: decodebin2: Decoder Bin flac: flacdec: FLAC audio decoder lame: lame: L.A.M.E. mp3 encoder Total count: 4 plugins, 5 features
Then you can query a specific element:
You'll be able to see a lot of information, but the most important are the properties. The 'lame' element has a 'quality' property which will be useful to our purposes.
In this example we will try to create a GStreamer pipeline with gst-launch to re-encode a FLAC clip into an MP3 one.
First we need to specify the input stream:
filesrc location="Radiohead - Down is the New Up.flac"
First the element we are using, 'filesrc', will let us read from a local file. The 'location' property specifies the path of the file we want to use. Simple.
Then we need to decode this thing. Obviously you'll need the 'flacdec' element for this task, but sometimes this is not so obvious, so the best thing to do is to use 'decodebin2', which will find out the right steps needed to decode our stream.
Now we have raw PCM data ready to be encoded by our favorite format, which in this case is MP3:
lame quality=3 vbr=4
The 'vbr' option is not so intuitive, you'll need to use 'gst-inspect' to find out what each value really means, in this case it's: (4): new - Lame's new VBR algorithm
Finally we want to save this to a file, so:
filesink location="Radiohead - Down is the New Up.mp3"
That's it, now we join all the elements with ! and we have:
gst-launch-0.10 filesrc location="Radiohead - Down is the New Up.flac" ! decodebin2 ! lame quality=3 vbr=4 ! filesink location="Radiohead - Down is the New Up.mp3"
Remember that gst-launch is a debugging tool, so don't expect it to be easy to use. For more information you can type 'man gst-launch-0.10'.
And obviously you can find more information about GStreamer on the site.