# HG changeset patch # User renatofilho # Date 1183556841 -3600 # Node ID 4127375c2a030baeca53ca4f9e6d5db7c2cf7d6e # Parent 9add73d88bceb8123a184d249eafd33fc21198e3 [svn r783] implemented deinterlaced to gmemcoder diff -r 9add73d88bce -r 4127375c2a03 gmyth-stream/gmemcoder/src/gmencoder.c --- a/gmyth-stream/gmemcoder/src/gmencoder.c Wed Jul 04 13:38:51 2007 +0100 +++ b/gmyth-stream/gmemcoder/src/gmencoder.c Wed Jul 04 14:47:21 2007 +0100 @@ -75,7 +75,8 @@ static GstElement *_create_video_bin(const gchar * encode, gchar ** encode_prop, gdouble fps, - gint rate, guint width, guint height); + gint rate, guint width, guint height, + gboolean use_deinterlace); static gboolean _pipeline_bus_cb(GstBus * bus, GstMessage * msg, gpointer user_data); @@ -103,7 +104,8 @@ guint video_height, const gchar * audio_encode, gchar ** audio_encode_prop, - guint audio_rate); + guint audio_rate, + gboolean deinterlace); #ifdef USE_MANUAL_SINK static void _flush_queue (GMencoder *self); static void _buffer_arrive_cb (GstElement* object, @@ -240,7 +242,8 @@ g_value_set_float(&p, (float) atof (prop_val)); break; default: - g_warning ("Property %s of type %s. Not supported", + g_value_set_enum(&p, atoi(prop_val)); + g_warning ("Property %s of type %s. Not supported using default enum", prop_name, g_type_name (s->value_type)); return; } @@ -357,7 +360,8 @@ static GstElement * _create_video_bin(const gchar * encode, gchar ** encode_prop, - gdouble fps, gint rate, guint width, guint height) + gdouble fps, gint rate, guint width, guint height, + gboolean use_deinterlace) { GstElement *vbin = NULL; GstElement *vqueue = NULL; @@ -365,6 +369,8 @@ GstElement *vcolorspace = NULL; GstElement *vencode = NULL; GstElement *vrate = NULL; + GstElement *deinterlace = NULL; + GstElement *walk = NULL; GstPad *vpad = NULL; vbin = gst_bin_new("vbin"); @@ -372,6 +378,14 @@ vcolorspace = gst_element_factory_make("ffmpegcolorspace", "colorspace"); + if (use_deinterlace) { + deinterlace = gst_element_factory_make ("ffdeinterlace", "deinterlace"); + if (deinterlace == NULL) { + g_warning ("Fail to create deinterlace element: Continue without deinterlace."); + } + } + + vencode = _create_element_with_prop((encode != NULL ? encode : "ffenc_mpeg1video"), "vencode", @@ -387,19 +401,29 @@ gst_bin_add_many(GST_BIN(vbin), vqueue, vcolorspace, vencode, vqueue_src, NULL); + if (deinterlace != NULL) { + gst_bin_add(GST_BIN(vbin), deinterlace); + gst_element_link (vqueue, deinterlace); + walk = deinterlace; + } else { + walk = vqueue; + } + if ((width > 0) && (height > 0)) { // Scalling video GstCaps *vcaps; GstElement *vscale = gst_element_factory_make("videoscale", "vscale"); + g_object_set (G_OBJECT (vscale), "method", 1, NULL); + gst_bin_add(GST_BIN(vbin), vscale); vcaps = gst_caps_new_simple("video/x-raw-yuv", "width", G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL); - gst_element_link(vqueue, vscale); + gst_element_link(walk, vscale); if (gst_element_link_filtered(vscale, vcolorspace, vcaps) == FALSE) { g_warning("Fail to resize video"); @@ -409,7 +433,7 @@ } gst_caps_unref(vcaps); } else { - gst_element_link(vqueue, vcolorspace); + gst_element_link(walk, vcolorspace); } if (fps > 0) { @@ -480,6 +504,7 @@ gboolean g_mencoder_setup_stream(GMencoder * self, gboolean chunked, + gboolean deinterlace, const gchar * mux_name, const gchar * video_encode, gchar ** video_encode_prop, @@ -513,7 +538,8 @@ video_width, video_height, audio_encode, audio_encode_prop, - audio_rate); + audio_rate, + deinterlace); return (priv->pipe != NULL); } @@ -674,7 +700,8 @@ guint video_width, guint video_height, const gchar * audio_encode, - gchar ** audio_encode_prop, guint audio_rate) + gchar ** audio_encode_prop, guint audio_rate, + gboolean deinterlace) { GstBus *bus = NULL; GstElement *pipe = NULL; @@ -729,7 +756,7 @@ vbin = _create_video_bin(video_encode, video_encode_prop, video_fps, - video_rate, video_width, video_height); + video_rate, video_width, video_height, deinterlace); if (vbin == NULL) goto error; diff -r 9add73d88bce -r 4127375c2a03 gmyth-stream/gmemcoder/src/gmencoder.h --- a/gmyth-stream/gmemcoder/src/gmencoder.h Wed Jul 04 13:38:51 2007 +0100 +++ b/gmyth-stream/gmemcoder/src/gmencoder.h Wed Jul 04 14:47:21 2007 +0100 @@ -36,6 +36,7 @@ gboolean g_mencoder_setup_stream(GMencoder * self, gboolean chunked, + gboolean deinterlace, const gchar * mux_name, const gchar * video_encode, gchar ** video_encode_prop, diff -r 9add73d88bce -r 4127375c2a03 gmyth-stream/gmemcoder/src/main.c --- a/gmyth-stream/gmemcoder/src/main.c Wed Jul 04 13:38:51 2007 +0100 +++ b/gmyth-stream/gmemcoder/src/main.c Wed Jul 04 14:47:21 2007 +0100 @@ -27,6 +27,7 @@ static gchar *mux_name = NULL; static gchar *output_uri = NULL; static gboolean chunked = FALSE; +static gboolean deinterlace = FALSE; @@ -125,6 +126,10 @@ {"chunked", 'c', 0, G_OPTION_ARG_NONE, &chunked, "Send package chunked", NULL}, + {"deinterlace", 'd', 0, G_OPTION_ARG_NONE, &deinterlace, + "Use to deinterlace videos", NULL}, + + {NULL} }; @@ -166,7 +171,7 @@ vopts = NULL; - ret = g_mencoder_setup_stream(coder, chunked, mux_name, + ret = g_mencoder_setup_stream(coder, chunked, deinterlace, mux_name, video_encode, vopts, video_fps, video_rate, video_width, video_height, audio_encode, aopts, audio_rate, output_uri); diff -r 9add73d88bce -r 4127375c2a03 gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py --- a/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py Wed Jul 04 13:38:51 2007 +0100 +++ b/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py Wed Jul 04 14:47:21 2007 +0100 @@ -50,6 +50,7 @@ # _parse_params def start(self, outfd): + self.opts.append ("-d") self.opts.append (self.gmencoder_path) self._parser_params ()