gst-omx encoder change caps
BK
brijeshku84 at gmail.com
Fri Jan 16 07:24:11 PST 2015
Thanks for your input. Finally I got it working last night. As per doc I
should not be setting the resolution information in input caps instead
those info should be set in the returned GstVideoCodeState.
"The specified *caps* should not contain any resolution,
pixel-aspect-ratio, framerate, codec-data, .... Those should be specified
instead in the returned GstVideoCodecState
<http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-gstvideoutils.html#GstVideoCodecState>."
But I did tried setting the resolution in input caps which didn't help.
Then I looked at gst_video_encoder_negotiate_default() implementation
which gave me hint that the width and height information is retrieved from
the state->info{width/height} fields and not from the caps. After setting
the info->width and info->height in the state I see the correct negotiated
caps.
now my code looks like this:
state = gst_video_encoder_set_output_state (GST_VIDEO_ENCODER (self), caps,
self->input_state);
state->info.width = scaling_width;
state->info.height = scaling_height;
if (!gst_video_encoder_negotiate (GST_VIDEO_ENCODER (self))) {
if (buf)
gst_omx_port_release_buffer (self->enc_out_port, buf);
GST_VIDEO_ENCODER_STREAM_UNLOCK (self);
goto caps_failed;
}
GST_DEBUG_OBJECT (self, "final caps : %" GST_PTR_FORMAT, state->caps);
final cap print the correct caps and gst-launch -v also shows the right
caps.
Thanks
BK
On Fri, Jan 16, 2015 at 5:22 AM, Sebastian Dröge <sebastian at centricular.com>
wrote:
> On Mi, 2015-01-14 at 13:19 -0500, BK wrote:
> > Hi,
> >
> > I am using gst-omx encoder element to support hw accelerated code on my
> > platform. In addition to encode the module also support scaling plus
> > encode. I have added a new property in element to pass the resize
> parameter
> > and its working as expected. But caps still have the old resolution as
> > passed from upstream element. As per the gst plugin doc I am using
> > gst_video_encoder_set_output_state() to change the caps resolution
> > information. Can anyone comment on what I am missing here
> >
> > static void
> > gst_omx_video_enc_loop (GstOMXVideoEnc * self)
> > {
> >
> >
> > ....
> > ...
> > .....
> > caps = klass->get_caps (self, self->enc_out_port, self->input_state);
> > if (!caps) {
> > if (buf)
> > gst_omx_port_release_buffer (self->enc_out_port, buf);
> > GST_VIDEO_ENCODER_STREAM_UNLOCK (self);
> > goto caps_failed;
> > }
> >
> > GST_DEBUG_OBJECT (self, "Setting output state: %" GST_PTR_FORMAT,
> caps);
> >
> > state =
> > gst_video_encoder_set_output_state (GST_VIDEO_ENCODER (self),
> caps,
> > self->input_state);
> > gst_caps_set_simple (state->caps, "width", G_TYPE_INT, 640, NULL);
> > gst_caps_set_simple (state->caps, "height", G_TYPE_INT, 480, NULL);
> > GST_DEBUG_OBJECT (self, "requesting caps : %" GST_PTR_FORMAT,
> > state->caps);
>
> You have to change the fields of the caps *before* calling
> gst_video_encoder_set_output_state(), and then pass the caps to that
> function.
>
> By default it will take over any generic fields from the input state
> though, so usually it's not necessary to set width or height manually.
>
>
> Also by giving the caps to gst_video_encoder_set_output_state() you give
> them away and don't own a reference to them anymore, so you're not
> allowed to use them (or change them). If you want to keep a reference
> for yourself you need to call gst_caps_ref() before, but then you still
> can't change them without copying first as they become immutable once
> there are more than 1 references to the caps.
>
> --
> Sebastian Dröge, Centricular Ltd · http://www.centricular.com
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20150116/78e0fb21/attachment.html>
More information about the gstreamer-devel
mailing list