How to create a pipeline from ready-made media profiles?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to create a pipeline from ready-made media profiles?

Alexander Botero
Hello,
The GNOME-desktop has a list of supported/installed media profiles and audio formats.
I can see these in THE gconf-editor,  system -> gstreamer -> 0.10 -> audio -> profiles:

Sample profiles:
FLAC: "audio/x-raw-int,rate=44100,channels=2 ! flacenc name=enc"
OGG:  "audio/x-raw-float,rate=44100,channels=2 ! vorbisenc name=enc quality=0.5 ! oggmux"
MP3:  "audio/x-raw-int,rate=44100,channels=2 ! lamemp3enc name=enc target=0 quality=6 ! xingmux ! id3v2mux"

I want to create a complete pipeline of these formats, and I want to build it from separate elements (not from gst_parse_launch(...)).

Q: Is this right way to parse the profile string?

0) Split the string to two (2) parts. The parts are separated by first "!".

F.ex let's study the OGG-profile.

1) Create GstCaps from the capabilities string (the 1.st part).
   Create GstCapsfilter element and set "caps" on it.

  GstElement *filter = gst_element_factory_make("capsfilter", NULL);
  GstCaps *caps = gst_caps_from_string("audio/x-raw-float,rate=44100,channels=2");
  g_object_set(G_OBJECT(filter), "caps", caps, NULL);
  gst_caps_unref(caps);

2) Create a GstBin from the profile's encoder/mux part.
  gchar *str = "vorbisenc name=enc quality=0.5 ! oggmux";

  GError *err = NULL;
  GstBin *bin = gst_parse_bin_from_description(str, TRUE, &err);
  
3) Create rest of the pipeline as usual. 
  gst_bin_add_many(GST_BIN(pipe), ...);
  gst_element_link_many(source,...,audioconvert, audioresample, filter, bin, filesink, NULL);

This approach seems to work pretty well. Have you a better approach?
----------------------------

The gst_parse_launch(...) function seems to do this magick automatically.

For example this works fine:
const gchar *str = "pulsesrc"
             " ! queue"
             " ! audioconvert"
             " ! audio/x-raw-int,rate=44100,channels=2 ! flacenc name=enc"
             " ! filesink location=xxx");

GError *err = NULL;
GstElement *pipe = gst_parse_launch(str, &err);
...

Kindly
 Alexander

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to create a pipeline from ready-made media profiles?

Alexander Botero
Re-hi,
Of course, this should also work. 
"capsfilter caps=" + the profile string.

gchar *profile_str = "capsfilter caps=audio/x-raw-int,rate=22050,channels=1 ! wavenc name=enc";

GError *err = NULL;
GstBin *bin = gst_parse_bin_from_description(profile_str, TRUE, &err);
if (err) {
   ...
}

Alex.


On Sun, Sep 23, 2012 at 7:27 PM, Alexander Botero <[hidden email]> wrote:
Hello,
The GNOME-desktop has a list of supported/installed media profiles and audio formats.
I can see these in THE gconf-editor,  system -> gstreamer -> 0.10 -> audio -> profiles:

Sample profiles:
FLAC: "audio/x-raw-int,rate=44100,channels=2 ! flacenc name=enc"
OGG:  "audio/x-raw-float,rate=44100,channels=2 ! vorbisenc name=enc quality=0.5 ! oggmux"
MP3:  "audio/x-raw-int,rate=44100,channels=2 ! lamemp3enc name=enc target=0 quality=6 ! xingmux ! id3v2mux"

I want to create a complete pipeline of these formats, and I want to build it from separate elements (not from gst_parse_launch(...)).

Q: Is this right way to parse the profile string?

0) Split the string to two (2) parts. The parts are separated by first "!".

F.ex let's study the OGG-profile.

1) Create GstCaps from the capabilities string (the 1.st part).
   Create GstCapsfilter element and set "caps" on it.

  GstElement *filter = gst_element_factory_make("capsfilter", NULL);
  GstCaps *caps = gst_caps_from_string("audio/x-raw-float,rate=44100,channels=2");
  g_object_set(G_OBJECT(filter), "caps", caps, NULL);
  gst_caps_unref(caps);

2) Create a GstBin from the profile's encoder/mux part.
  gchar *str = "vorbisenc name=enc quality=0.5 ! oggmux";

  GError *err = NULL;
  GstBin *bin = gst_parse_bin_from_description(str, TRUE, &err);
  
3) Create rest of the pipeline as usual. 
  gst_bin_add_many(GST_BIN(pipe), ...);
  gst_element_link_many(source,...,audioconvert, audioresample, filter, bin, filesink, NULL);

This approach seems to work pretty well. Have you a better approach?
----------------------------

The gst_parse_launch(...) function seems to do this magick automatically.

For example this works fine:
const gchar *str = "pulsesrc"
             " ! queue"
             " ! audioconvert"
             " ! audio/x-raw-int,rate=44100,channels=2 ! flacenc name=enc"
             " ! filesink location=xxx");

GError *err = NULL;
GstElement *pipe = gst_parse_launch(str, &err);


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel