Commit 40deef89 authored by Ronald S. Bultje's avatar Ronald S. Bultje

Loop through input capses instead of just picking the first, and handle encoding errors

Original commit message from CVS:
Loop through input capses instead of just picking the first, and handle encoding errors
parent 49b22bce
......@@ -284,11 +284,6 @@ gst_ffmpegenc_connect (GstPad *pad,
ffmpegenc->context->qmax = 15;
ffmpegenc->context->max_qdiff = 3;
/* fill in the context (width/height/pixfmt or
* rate/channels/samplefmt) */
gst_ffmpeg_caps_to_codectype (oclass->in_plugin->type,
caps, ffmpegenc->context);
/* no edges */
ffmpegenc->context->flags |= CODEC_FLAG_EMU_EDGE;
......@@ -298,11 +293,23 @@ gst_ffmpegenc_connect (GstPad *pad,
ffmpegenc->context->frame_rate = 25 * DEFAULT_FRAME_RATE_BASE;
ffmpegenc->context->frame_rate_base = DEFAULT_FRAME_RATE_BASE;
/* open codec */
if (avcodec_open (ffmpegenc->context, oclass->in_plugin) < 0) {
GST_DEBUG (GST_CAT_PLUGIN_INFO,
"ffenc_%s: Failed to open FFMPEG codec",
oclass->in_plugin->name);
for (ret_caps = caps; ret_caps != NULL; ret_caps = ret_caps->next) {
/* fetch pix_fmt and so on */
gst_ffmpeg_caps_to_codectype (oclass->in_plugin->type,
caps, ffmpegenc->context);
/* open codec */
if (avcodec_open (ffmpegenc->context, oclass->in_plugin) < 0) {
GST_DEBUG (GST_CAT_PLUGIN_INFO,
"ffenc_%s: Failed to open FFMPEG codec",
oclass->in_plugin->name);
continue;
}
break;
}
if (ret_caps == NULL) {
return GST_PAD_LINK_REFUSED;
}
......@@ -375,6 +382,13 @@ gst_ffmpegenc_chain (GstPad *pad,
break;
}
if (ret_size < 0) {
g_warning("ffenc_%s: failed to encode buffer",
oclass->in_plugin->name);
gst_buffer_unref (inbuf);
return;
}
/* bla */
GST_BUFFER_SIZE (outbuf) = ret_size;
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (inbuf);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment