int
main (int argc, char *argv[])
{
- GstElement *filesrc, *decoder, *audiosink;
+ GstElement *filesrc, *demuxer, *decoder, *audiosink;
GstElement *thread;
if (argc < 2) {
g_signal_connect (G_OBJECT (filesrc), "eos",
G_CALLBACK (eos), thread);
- /* create an ogg decoder */
- decoder = gst_element_factory_make ("vorbisfile", "decoder");
+ /* create an ogg demuxer */
+ demuxer = gst_element_factory_make ("oggdemux", "demuxer");
+ g_assert (demuxer != NULL);
+
+ /* create a vorbis decoder */
+ decoder = gst_element_factory_make ("vorbisdec", "decoder");
g_assert (decoder != NULL);
/* and an audio sink */
g_assert (audiosink != NULL);
/* add objects to the thread */
- gst_bin_add_many (GST_BIN (thread), filesrc, decoder, audiosink, NULL);
+ gst_bin_add_many (GST_BIN (thread), filesrc, demuxer, decoder, audiosink, NULL);
/* link them in the logical order */
- gst_element_link_many (filesrc, decoder, audiosink, NULL);
+ gst_element_link_many (filesrc, demuxer, decoder, audiosink, NULL);
/* start playing */
gst_element_set_state (thread, GST_STATE_PLAYING);
</para>
<para>
We can also choose to use another type of sink instead of the audiosink.
- We could use a disksink to write the raw samples to a file, for example.
+ We could use a filesink to write the raw samples to a file, for example.
It should also be clear that inserting filters, like a stereo effect,
into the pipeline is not that hard to do. The most important thing is
that you can reuse already existing elements.
</para>
<para>
We can also choose to use another type of sink instead of the audiosink.
- We could use a disksink to write the raw samples to a file, for example.
+ We could use a filesink to write the raw samples to a file, for example.
It should also be clear that inserting filters, like a stereo effect,
into the pipeline is not that hard to do. The most important thing is
that you can reuse already existing elements.
int
main (int argc, char *argv[])
{
- GstElement *filesrc, *decoder, *audiosink;
+ GstElement *filesrc, *demuxer, *decoder, *audiosink;
GstElement *thread;
if (argc < 2) {
g_signal_connect (G_OBJECT (filesrc), "eos",
G_CALLBACK (eos), thread);
- /* create an ogg decoder */
- decoder = gst_element_factory_make ("vorbisfile", "decoder");
+ /* create an ogg demuxer */
+ demuxer = gst_element_factory_make ("oggdemux", "demuxer");
+ g_assert (demuxer != NULL);
+
+ /* create a vorbis decoder */
+ decoder = gst_element_factory_make ("vorbisdec", "decoder");
g_assert (decoder != NULL);
/* and an audio sink */
g_assert (audiosink != NULL);
/* add objects to the thread */
- gst_bin_add_many (GST_BIN (thread), filesrc, decoder, audiosink, NULL);
+ gst_bin_add_many (GST_BIN (thread), filesrc, demuxer, decoder, audiosink, NULL);
/* link them in the logical order */
- gst_element_link_many (filesrc, decoder, audiosink, NULL);
+ gst_element_link_many (filesrc, demuxer, decoder, audiosink, NULL);
/* start playing */
gst_element_set_state (thread, GST_STATE_PLAYING);
4 - Ogg/Vorbis
MIME type: audio/x-vorbis
Encoder: vorbisenc
- Decoder: vorbisfile
+ Decoder: vorbisdec
5 - Windows Media Audio 1 and 2 (WMA)
MIME type: audio/x-wma
travel downstream (left to right)?
eg. Seek travels upstream, but it makes sense to also make it travel
- downstream (the case of a disksink, where we overwrite the header)
+ downstream (the case of a filesink, where we overwrite the header)
Setting an event function
Here we convert a Mp3 file into an Ogg Vorbis file:
- gst-launch filesrc location=music.mp3 ! mad ! vorbisenc ! disksink location=music.ogg
+ gst-launch filesrc location=music.mp3 ! mad ! vorbisenc ! filesink location=music.ogg
And then we can play that file with:
- gst-launch filesrc location=music.ogg ! vorbisdec ! osssink
+ gst-launch filesrc location=music.ogg ! oggdemux ! vorbisdec ! osssink
Some other useful pipelines are..
Plays wav files (currently there are no wav encoders):
- gst-launch filesrc location=music.wav ! parsewav ! osssink
+ gst-launch filesrc location=music.wav ! wavparse ! osssink
Converts wav files into mp3 and ogg files:
- gst-launch filesrc location=music.wav ! parsewav ! vorbisenc ! disksink location=music.ogg
- gst-launch filesrc location=music.wav ! parsewav ! mpegaudio ! disksink location=music.mp3
+ gst-launch filesrc location=music.wav ! wavparse ! vorbisenc ! filesink location=music.ogg
+ gst-launch filesrc location=music.wav ! wavparse ! mpegaudio ! filesink location=music.mp3
You can also use lame for mp3 encoding if you have it installed, it does a
much better job than mpegaudio.
Rips all songs from cd and saves them into a mp3 file:
- gst-launch cdparanoia ! mpegaudio ! disksink location=cd.mp3
+ gst-launch cdparanoia ! mpegaudio ! filesink location=cd.mp3
You can toy around with gst-inspect to discover the settings for
cdparanoia to rip individual tracks
Record sound from your sound input and encode it into an ogg file:
- gst-launch osssrc ! vorbisenc ! disksink location=input.ogg
+ gst-launch osssrc ! vorbisenc ! filesink location=input.ogg
gst-launch not only handles audio but video as well:
For mpeg1 files (video and audio streams respectively):
output to an OSS device
.B
- gst\-launch filesrc location=music.ogg ! vorbisfile ! osssink
+ gst\-launch filesrc location=music.ogg ! oggdemux ! vorbisdec ! osssink
.br
Play an Ogg Vorbis format file