mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 20:59:44 +00:00
avvidenc: Create caps from the codec context after it is opened
We won't get codec_data and various other information otherwise.
This commit is contained in:
parent
ee5e2bcd6b
commit
a5ac55c4a0
1 changed files with 23 additions and 17 deletions
|
@ -430,6 +430,29 @@ gst_ffmpegvidenc_set_format (GstVideoEncoder * encoder,
|
||||||
gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
|
gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
|
||||||
oclass->in_plugin->type, allowed_caps, ffmpegenc->context);
|
oclass->in_plugin->type, allowed_caps, ffmpegenc->context);
|
||||||
|
|
||||||
|
/* open codec */
|
||||||
|
if (gst_ffmpeg_avcodec_open (ffmpegenc->context, oclass->in_plugin) < 0) {
|
||||||
|
gst_caps_unref (allowed_caps);
|
||||||
|
goto open_codec_fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* is the colourspace correct? */
|
||||||
|
if (pix_fmt != ffmpegenc->context->pix_fmt) {
|
||||||
|
gst_caps_unref (allowed_caps);
|
||||||
|
goto pix_fmt_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* we may have failed mapping caps to a pixfmt,
|
||||||
|
* and quite some codecs do not make up their own mind about that
|
||||||
|
* in any case, _NONE can never work out later on */
|
||||||
|
if (pix_fmt == AV_PIX_FMT_NONE) {
|
||||||
|
gst_caps_unref (allowed_caps);
|
||||||
|
goto bad_input_fmt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* second pass stats buffer no longer needed */
|
||||||
|
g_free (ffmpegenc->context->stats_in);
|
||||||
|
|
||||||
/* try to set this caps on the other side */
|
/* try to set this caps on the other side */
|
||||||
other_caps = gst_ffmpeg_codecid_to_caps (oclass->in_plugin->id,
|
other_caps = gst_ffmpeg_codecid_to_caps (oclass->in_plugin->id,
|
||||||
ffmpegenc->context, TRUE);
|
ffmpegenc->context, TRUE);
|
||||||
|
@ -450,23 +473,6 @@ gst_ffmpegvidenc_set_format (GstVideoEncoder * encoder,
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (ffmpegenc, "codec flags 0x%08x", ffmpegenc->context->flags);
|
GST_DEBUG_OBJECT (ffmpegenc, "codec flags 0x%08x", ffmpegenc->context->flags);
|
||||||
|
|
||||||
/* open codec */
|
|
||||||
if (gst_ffmpeg_avcodec_open (ffmpegenc->context, oclass->in_plugin) < 0)
|
|
||||||
goto open_codec_fail;
|
|
||||||
|
|
||||||
/* is the colourspace correct? */
|
|
||||||
if (pix_fmt != ffmpegenc->context->pix_fmt)
|
|
||||||
goto pix_fmt_err;
|
|
||||||
|
|
||||||
/* we may have failed mapping caps to a pixfmt,
|
|
||||||
* and quite some codecs do not make up their own mind about that
|
|
||||||
* in any case, _NONE can never work out later on */
|
|
||||||
if (pix_fmt == AV_PIX_FMT_NONE)
|
|
||||||
goto bad_input_fmt;
|
|
||||||
|
|
||||||
/* second pass stats buffer no longer needed */
|
|
||||||
g_free (ffmpegenc->context->stats_in);
|
|
||||||
|
|
||||||
/* Store input state and set output state */
|
/* Store input state and set output state */
|
||||||
if (ffmpegenc->input_state)
|
if (ffmpegenc->input_state)
|
||||||
gst_video_codec_state_unref (ffmpegenc->input_state);
|
gst_video_codec_state_unref (ffmpegenc->input_state);
|
||||||
|
|
Loading…
Reference in a new issue