diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2016-07-05 20:16:09 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2016-07-05 20:16:09 +0300 |
commit | 832b42301d7be88cf80b2a0ba5ab54cf02393000 (patch) | |
tree | e8d9915026fbcbccf3481bfcfd86fde53352120a /ext/libav/gstavaudenc.c | |
parent | a5ac55c4a04e668afb0a5cf9945a92dc4d5e1b31 (diff) | |
download | gst-libav-832b42301d7be88cf80b2a0ba5ab54cf02393000.tar.gz |
avaudenc: Create caps from the codec context after it is opened
We won't get codec_data and various other information otherwise.
Diffstat (limited to 'ext/libav/gstavaudenc.c')
-rw-r--r-- | ext/libav/gstavaudenc.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/ext/libav/gstavaudenc.c b/ext/libav/gstavaudenc.c index b895a9d..1edbc90 100644 --- a/ext/libav/gstavaudenc.c +++ b/ext/libav/gstavaudenc.c @@ -303,8 +303,23 @@ gst_ffmpegaudenc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info) ffmpegaudenc->context->channels) != 0); } + /* some codecs support more than one format, first auto-choose one */ + GST_DEBUG_OBJECT (ffmpegaudenc, "picking an output format ..."); + allowed_caps = gst_pad_get_allowed_caps (GST_AUDIO_ENCODER_SRC_PAD (encoder)); + if (!allowed_caps) { + GST_DEBUG_OBJECT (ffmpegaudenc, "... but no peer, using template caps"); + /* we need to copy because get_allowed_caps returns a ref, and + * get_pad_template_caps doesn't */ + allowed_caps = + gst_pad_get_pad_template_caps (GST_AUDIO_ENCODER_SRC_PAD (encoder)); + } + GST_DEBUG_OBJECT (ffmpegaudenc, "chose caps %" GST_PTR_FORMAT, allowed_caps); + gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id, + oclass->in_plugin->type, allowed_caps, ffmpegaudenc->context); + /* open codec */ if (gst_ffmpeg_avcodec_open (ffmpegaudenc->context, oclass->in_plugin) < 0) { + gst_caps_unref (allowed_caps); gst_ffmpeg_avcodec_close (ffmpegaudenc->context); GST_DEBUG_OBJECT (ffmpegaudenc, "avenc_%s: Failed to open FFMPEG codec", oclass->in_plugin->name); @@ -324,20 +339,6 @@ gst_ffmpegaudenc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info) return FALSE; } - /* some codecs support more than one format, first auto-choose one */ - GST_DEBUG_OBJECT (ffmpegaudenc, "picking an output format ..."); - allowed_caps = gst_pad_get_allowed_caps (GST_AUDIO_ENCODER_SRC_PAD (encoder)); - if (!allowed_caps) { - GST_DEBUG_OBJECT (ffmpegaudenc, "... but no peer, using template caps"); - /* we need to copy because get_allowed_caps returns a ref, and - * get_pad_template_caps doesn't */ - allowed_caps = - gst_pad_get_pad_template_caps (GST_AUDIO_ENCODER_SRC_PAD (encoder)); - } - GST_DEBUG_OBJECT (ffmpegaudenc, "chose caps %" GST_PTR_FORMAT, allowed_caps); - gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id, - oclass->in_plugin->type, allowed_caps, ffmpegaudenc->context); - /* try to set this caps on the other side */ other_caps = gst_ffmpeg_codecid_to_caps (oclass->in_plugin->id, ffmpegaudenc->context, TRUE); |