Top |
GObject ├── GstEncodingProfile │ ├── GstEncodingVideoProfile │ ├── GstEncodingAudioProfile │ ╰── GstEncodingContainerProfile ╰── GstEncodingTarget
Functions to create and handle encoding profiles.
Encoding profiles describe the media types and settings one wishes to use for an encoding process. The top-level profiles are commonly GstEncodingContainerProfile(s) (which contains a user-readable name and description along with which container format to use). These, in turn, reference one or more GstEncodingProfile(s) which indicate which encoding format should be used on each individual streams.
GstEncodingProfile(s) can be provided to the 'encodebin' element, which will take care of selecting and setting up the required elements to produce an output stream conforming to the specifications of the profile.
Unlike other systems, the encoding profiles do not specify which GstElement to use for the various encoding and muxing steps, but instead relies on specifying the format one wishes to use.
Encoding profiles can be created at runtime by the application or loaded from (and saved to) file using the GstEncodingTarget API.
This is the serialization format of a GstEncodingProfile.
Internally the transcoding application uses GstEncodeBin. gst-validate-transcoding-&GST_API_VERSION; uses its own serialization format to describe the GstEncodeBin.profile property of the encodebin.
The simplest serialized profile looks like:
1 |
muxer_source_caps:videoencoder_source_caps:audioencoder_source_caps |
For example to encode a stream into a WebM container, with an OGG audio stream and a VP8 video stream, the serialized GstEncodingProfile will look like:
1 |
video/webm:video/x-vp8:audio/x-vorbis |
You can also set the preset name of the encoding profile using the caps+preset_name syntax as in:
1 |
video/webm:video/x-vp8+youtube-preset:audio/x-vorbis |
Moreover, you can set the presence property of an
encoding profile using the |presence
syntax as in:
1 |
video/webm:video/x-vp8|1:audio/x-vorbis |
This field allows you to specify how many times maximum a GstEncodingProfile can be used inside an encodebin.
You can also use the restriction_caps->encoded_format_caps
syntax to specify the
restriction caps
to be set on a GstEncodingProfile. It corresponds to the
restriction GstCaps to apply before
the encoder that will be used in the profile. The fields present in restriction
caps are properties of the raw stream (that is, before encoding), such as height
and width for video and depth and sampling rate for audio. This property does not
make sense for muxers.
To force a video stream to be encoded with a Full HD resolution (using WebM as the container format, VP8 as the video codec and Vorbis as the audio codec), you should use:
1 |
video/webm:video/x-raw,width=1920,height=1080->video/x-vp8:audio/x-vorbis |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#include <gst/pbutils/encoding-profile.h> ... GstEncodingProfile * create_ogg_theora_profile(void) { GstEncodingContainerProfile *prof; GstCaps *caps; caps = gst_caps_from_string("application/ogg"); prof = gst_encoding_container_profile_new("Ogg audio/video", "Standard OGG/THEORA/VORBIS", caps, NULL); gst_caps_unref (caps); caps = gst_caps_from_string("video/x-theora"); gst_encoding_container_profile_add_profile(prof, (GstEncodingProfile*) gst_encoding_video_profile_new(caps, NULL, NULL, 0)); gst_caps_unref (caps); caps = gst_caps_from_string("audio/x-vorbis"); gst_encoding_container_profile_add_profile(prof, (GstEncodingProfile*) gst_encoding_audio_profile_new(caps, NULL, NULL, 0)); gst_caps_unref (caps); return (GstEncodingProfile*) prof; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#include <gst/pbutils/encoding-profile.h> ... GstEncodingProfile * create_ogg_theora_profile(void) { GstEncodingVideoProfile *v; GstEncodingAudioProfile *a; GstEncodingContainerProfile *prof; GstCaps *caps; GstPreset *preset; caps = gst_caps_from_string ("application/ogg"); prof = gst_encoding_container_profile_new ("Ogg audio/video", "Standard OGG/THEORA/VORBIS", caps, NULL); gst_caps_unref (caps); preset = GST_PRESET (gst_element_factory_make ("theoraenc", "theorapreset")); g_object_set (preset, "bitrate", 1000, NULL); // The preset will be saved on the filesystem, // so try to use a descriptive name gst_preset_save_preset (preset, "theora_bitrate_preset"); gst_object_unref (preset); caps = gst_caps_from_string ("video/x-theora"); v = gst_encoding_video_profile_new (caps, "theorapreset", NULL, 0); gst_encoding_container_profile_add_profile (prof, (GstEncodingProfile*) v); gst_caps_unref (caps); caps = gst_caps_from_string ("audio/x-vorbis"); a = gst_encoding_audio_profile_new (caps, NULL, NULL, 0); gst_encoding_container_profile_add_profile (prof, (GstEncodingProfile*) a); gst_caps_unref (caps); return (GstEncodingProfile*) prof; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#include <gst/pbutils/encoding-profile.h> ... GstEncodingProfile *prof; GList *categories, *tmpc; GList *targets, *tmpt; ... categories = gst_encoding_list_available_categories (); ... Show available categories to user ... for (tmpc = categories; tmpc; tmpc = tmpc->next) { gchar *category = (gchar *) tmpc->data; ... and we can list all targets within that category ... targets = gst_encoding_list_all_targets (category); ... and show a list to our users ... g_list_foreach (targets, (GFunc) gst_encoding_target_unref, NULL); g_list_free (targets); } g_list_foreach (categories, (GFunc) g_free, NULL); g_list_free (categories); ... |
#define gst_encoding_profile_unref(profile) (g_object_unref ((GObject*) profile))
Decreases the reference count of the profile
, possibly freeing the profile
.
#define gst_encoding_profile_ref(profile) (g_object_ref ((GObject*) profile))
Increases the reference count of the profile
.
GstEncodingProfile * gst_encoding_profile_find (const gchar *targetname
,const gchar *profilename
,const gchar *category
);
Find the GstEncodingProfile with the specified name and category.
GstEncodingProfile *
gst_encoding_profile_from_discoverer (GstDiscovererInfo *info
);
Creates a GstEncodingProfile matching the formats from the given GstDiscovererInfo. Streams other than audio or video (eg, subtitles), are currently ignored.
const gchar *
gst_encoding_profile_get_name (GstEncodingProfile *profile
);
const gchar *
gst_encoding_profile_get_description (GstEncodingProfile *profile
);
GstCaps *
gst_encoding_profile_get_format (GstEncodingProfile *profile
);
the GstCaps corresponding to the media format used in the profile. Unref after usage.
[transfer full]
const gchar *
gst_encoding_profile_get_preset (GstEncodingProfile *profile
);
the name of the GstPreset to be used in the profile. This is the name that has been set when saving the preset.
const gchar *
gst_encoding_profile_get_preset_name (GstEncodingProfile *profile
);
guint
gst_encoding_profile_get_presence (GstEncodingProfile *profile
);
GstCaps *
gst_encoding_profile_get_restriction (GstEncodingProfile *profile
);
The restriction GstCaps to apply before the encoder
that will be used in the profile. The fields present in restriction caps are
properties of the raw stream (that is before encoding), such as height and
width for video and depth and sampling rate for audio. Does not apply to
GstEncodingContainerProfile (since there is no corresponding raw stream).
Can be NULL
. Unref after usage.
[transfer full]
const gchar *
gst_encoding_profile_get_file_extension
(GstEncodingProfile *profile
);
void gst_encoding_profile_set_name (GstEncodingProfile *profile
,const gchar *name
);
Set name
as the given name for the profile
. A copy of name
will be made
internally.
void gst_encoding_profile_set_description (GstEncodingProfile *profile
,const gchar *description
);
Set description
as the given description for the profile
. A copy of
description
will be made internally.
void gst_encoding_profile_set_enabled (GstEncodingProfile *profile
,gboolean enabled
);
Set whether the profile should be used or not.
void gst_encoding_profile_set_format (GstEncodingProfile *profile
,GstCaps *format
);
Sets the media format used in the profile.
void gst_encoding_profile_set_preset (GstEncodingProfile *profile
,const gchar *preset
);
Sets the name of the GstElement that implements the GstPreset interface to use for the profile. This is the name that has been set when saving the preset.
void gst_encoding_profile_set_preset_name (GstEncodingProfile *profile
,const gchar *preset_name
);
Sets the name of the GstPreset's factory to be used in the profile.
void gst_encoding_profile_set_restriction (GstEncodingProfile *profile
,GstCaps *restriction
);
Set the restriction GstCaps to apply before the encoder
that will be used in the profile. See gst_encoding_profile_get_restriction()
for more about restrictions. Does not apply to GstEncodingContainerProfile.
void gst_encoding_profile_set_presence (GstEncodingProfile *profile
,guint presence
);
Set the number of time the profile is used in its parent container profile. If 0, it is not a mandatory stream
gboolean gst_encoding_profile_is_equal (GstEncodingProfile *a
,GstEncodingProfile *b
);
Checks whether the two GstEncodingProfile are equal
gboolean
gst_encoding_profile_is_enabled (GstEncodingProfile *profile
);
GstCaps *
gst_encoding_profile_get_input_caps (GstEncodingProfile *profile
);
Computes the full output caps that this profile
will be able to consume.
The full caps the given profile
can consume. Call
gst_caps_unref()
when you are done with the caps.
[transfer full]
const gchar *
gst_encoding_profile_get_type_nick (GstEncodingProfile *profile
);
GstEncodingContainerProfile * gst_encoding_container_profile_new (const gchar *name
,const gchar *description
,GstCaps *format
,const gchar *preset
);
Creates a new GstEncodingContainerProfile.
gboolean gst_encoding_container_profile_add_profile (GstEncodingContainerProfile *container
,GstEncodingProfile *profile
);
Add a GstEncodingProfile to the list of profiles handled by container
.
No copy of profile
will be made, if you wish to use it elsewhere after this
method you should increment its reference count.
container |
the GstEncodingContainerProfile to use |
|
profile |
the GstEncodingProfile to add. |
[transfer full] |
gboolean gst_encoding_container_profile_contains_profile (GstEncodingContainerProfile *container
,GstEncodingProfile *profile
);
Checks if container
contains a GstEncodingProfile identical to
profile
.
const GList *
gst_encoding_container_profile_get_profiles
(GstEncodingContainerProfile *profile
);
the list of contained GstEncodingProfile.
[element-type GstPbutils.EncodingProfile][transfer none]
GstEncodingAudioProfile * gst_encoding_audio_profile_new (GstCaps *format
,const gchar *preset
,GstCaps *restriction
,guint presence
);
Creates a new GstEncodingAudioProfile
All provided allocatable arguments will be internally copied, so can be safely freed/unreferenced after calling this method.
format |
the GstCaps |
|
preset |
the preset(s) to use on the encoder, can be NULL. |
[allow-none] |
restriction |
the GstCaps used to restrict the input to the encoder, can be
NULL. See |
[allow-none] |
presence |
the number of time this stream must be used. 0 means any number of times (including never) |
GstEncodingVideoProfile * gst_encoding_video_profile_new (GstCaps *format
,const gchar *preset
,GstCaps *restriction
,guint presence
);
Creates a new GstEncodingVideoProfile
All provided allocatable arguments will be internally copied, so can be safely freed/unreferenced after calling this method.
If you wish to control the pass number (in case of multi-pass scenarios),
please refer to the gst_encoding_video_profile_set_pass()
documentation.
If you wish to use/force a constant framerate please refer to the
gst_encoding_video_profile_set_variableframerate()
documentation.
format |
the GstCaps |
|
preset |
the preset(s) to use on the encoder, can be NULL. |
[allow-none] |
restriction |
the GstCaps used to restrict the input to the encoder, can be
NULL. See |
[allow-none] |
presence |
the number of time this stream must be used. 0 means any number of times (including never) |
guint
gst_encoding_video_profile_get_pass (GstEncodingVideoProfile *prof
);
Get the pass number if this is part of a multi-pass profile.
gboolean
gst_encoding_video_profile_get_variableframerate
(GstEncodingVideoProfile *prof
);
void gst_encoding_video_profile_set_pass (GstEncodingVideoProfile *prof
,guint pass
);
Sets the pass number of this video profile. The first pass profile should have this value set to 1. If this video profile isn't part of a multi-pass profile, you may set it to 0 (the default value).
void gst_encoding_video_profile_set_variableframerate (GstEncodingVideoProfile *prof
,gboolean variableframerate
);
If set to TRUE
, then the incoming stream will be allowed to have non-constant
framerate. If set to FALSE
(default value), then the incoming stream will
be normalized by dropping/duplicating frames in order to produce a
constance framerate.
#define gst_encoding_target_unref(target)
Decreases the reference count of the target
, possibly freeing it.
#define gst_encoding_target_ref(target)
Increases the reference count of the target
.
GstEncodingTarget * gst_encoding_target_new (const gchar *name
,const gchar *category
,const gchar *description
,const GList *profiles
);
Creates a new GstEncodingTarget.
The name and category can only consist of lowercase ASCII letters for the first character, followed by either lowercase ASCII letters, digits or hyphens ('-').
The category
should be one of the existing
well-defined categories, like GST_ENCODING_CATEGORY_DEVICE, but it
can be a application or user specific category if
needed.
name |
The name of the target. |
|
category |
The name of the category to which this |
[transfer none] |
description |
A description of GstEncodingTarget in the current locale. |
[transfer none] |
profiles |
A GList of GstEncodingProfile. |
[transfer none][element-type GstPbutils.EncodingProfile] |
const gchar *
gst_encoding_target_get_name (GstEncodingTarget *target
);
const gchar *
gst_encoding_target_get_category (GstEncodingTarget *target
);
const gchar *
gst_encoding_target_get_description (GstEncodingTarget *target
);
const GList *
gst_encoding_target_get_profiles (GstEncodingTarget *target
);
A list of
GstEncodingProfile(s) this target
handles.
[transfer none][element-type GstPbutils.EncodingProfile]
GstEncodingProfile * gst_encoding_target_get_profile (GstEncodingTarget *target
,const gchar *name
);
gboolean gst_encoding_target_add_profile (GstEncodingTarget *target
,GstEncodingProfile *profile
);
Adds the given profile
to the target
. Each added profile must have
a unique name within the profile.
The target
will steal a reference to the profile
. If you wish to use
the profile after calling this method, you should increase its reference
count.
target |
the GstEncodingTarget to add a profile to |
|
profile |
the GstEncodingProfile to add. |
[transfer full] |
gboolean gst_encoding_target_save (GstEncodingTarget *target
,GError **error
);
Saves the target
to a default user-local directory.
gboolean gst_encoding_target_save_to_file (GstEncodingTarget *target
,const gchar *filepath
,GError **error
);
Saves the target
to the provided file location.
GstEncodingTarget * gst_encoding_target_load (const gchar *name
,const gchar *category
,GError **error
);
Searches for the GstEncodingTarget with the given name, loads it and returns it.
If the category name is specified only targets from that category will be searched for.
name |
the name of the GstEncodingTarget to load. |
|
category |
the name of the target category, like
GST_ENCODING_CATEGORY_DEVICE. Can be |
[allow-none] |
error |
If an error occured, this field will be filled in. |
GstEncodingTarget * gst_encoding_target_load_from_file (const gchar *filepath
,GError **error
);
Opens the provided file and returns the contained GstEncodingTarget.
filepath |
The file location to load the GstEncodingTarget from |
|
error |
If an error occured, this field will be filled in. |
GList *
gst_encoding_list_all_targets (const gchar *categoryname
);
List all available GstEncodingTarget for the specified category, or all categories
if categoryname
is NULL
.
categoryname |
The category, for ex: GST_ENCODING_CATEGORY_DEVICE.
Can be |
[allow-none] |
GList *
gst_encoding_list_available_categories
(void
);
Lists all GstEncodingTarget categories present on disk.
typedef struct _GstEncodingProfile GstEncodingProfile;
The opaque base class object for all encoding profiles. This contains generic information like name, description, format and preset.
typedef struct _GstEncodingContainerProfile GstEncodingContainerProfile;
Encoding profiles for containers. Keeps track of a list of GstEncodingProfile
typedef struct _GstEncodingAudioProfile GstEncodingAudioProfile;
Variant of GstEncodingProfile for audio streams.
typedef struct _GstEncodingVideoProfile GstEncodingVideoProfile;
Variant of GstEncodingProfile for video streams, allows specifying the pass
.
#define GST_ENCODING_CATEGORY_DEVICE "device"
GstEncodingTarget category for device-specific targets. The name of the target will usually be the constructor and model of the device, and that target will contain GstEncodingProfiles suitable for that device.
#define GST_ENCODING_CATEGORY_ONLINE_SERVICE "online-service"
GstEncodingTarget category for online-services. The name of the target will usually be the name of the online service and that target will contain GstEncodingProfiles suitable for that online service.
#define GST_ENCODING_CATEGORY_STORAGE_EDITING "storage-editing"
GstEncodingTarget category for storage, archiving and editing targets. Those targets can be lossless and/or provide very fast random access content. The name of the target will usually be the container type or editing target, and that target will contain GstEncodingProfiles suitable for editing or storage.
#define GST_ENCODING_CATEGORY_CAPTURE "capture"
GstEncodingTarget category for recording and capture. Targets within this category are optimized for low latency encoding.
typedef struct _GstEncodingTarget GstEncodingTarget;
Collection of GstEncodingProfile for a specific target or use-case.
When being stored/loaded, targets come from a specific category, like GST_ENCODING_CATEGORY_DEVICE.
“restriction-caps”
property“restriction-caps” GstCaps *
The restriction caps to use.
Flags: Read / Write