2002-03-20 21:44:42 +00:00
|
|
|
/* GStreamer
|
2001-12-23 13:25:04 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2004-01-12 04:15:46 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2002-11-26 14:50:05 +00:00
|
|
|
#include "config.h"
|
2004-01-12 04:15:46 +00:00
|
|
|
#endif
|
2003-06-07 00:41:32 +00:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
/* for stats file handling */
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <glib/gstdio.h>
|
|
|
|
#include <errno.h>
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2002-11-26 14:50:05 +00:00
|
|
|
#ifdef HAVE_FFMPEG_UNINSTALLED
|
|
|
|
#include <avcodec.h>
|
|
|
|
#else
|
2008-10-30 12:05:45 +00:00
|
|
|
#include <libavcodec/avcodec.h>
|
2002-11-26 14:50:05 +00:00
|
|
|
#endif
|
2002-11-06 23:53:46 +00:00
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2004-12-18 20:53:55 +00:00
|
|
|
#include "gstffmpeg.h"
|
2003-06-07 00:41:32 +00:00
|
|
|
#include "gstffmpegcodecmap.h"
|
2009-04-15 20:33:16 +00:00
|
|
|
#include "gstffmpegutils.h"
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
#include "gstffmpegenc.h"
|
|
|
|
#include "gstffmpegcfg.h"
|
2003-06-07 00:41:32 +00:00
|
|
|
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
#define DEFAULT_VIDEO_BITRATE 300000 /* in bps */
|
2006-02-11 12:04:31 +00:00
|
|
|
#define DEFAULT_VIDEO_GOP_SIZE 15
|
|
|
|
#define DEFAULT_AUDIO_BITRATE 128000
|
|
|
|
|
2006-02-12 19:54:16 +00:00
|
|
|
#define DEFAULT_WIDTH 352
|
|
|
|
#define DEFAULT_HEIGHT 288
|
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2002-06-03 22:48:11 +00:00
|
|
|
#define VIDEO_BUFFER_SIZE (1024*1024)
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-23 13:25:04 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-23 13:25:04 +00:00
|
|
|
ARG_0,
|
|
|
|
ARG_BIT_RATE,
|
|
|
|
ARG_GOP_SIZE,
|
|
|
|
ARG_ME_METHOD,
|
2005-11-28 17:12:13 +00:00
|
|
|
ARG_BUFSIZE,
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
ARG_RTP_PAYLOAD_SIZE,
|
|
|
|
ARG_CFG_BASE
|
2001-12-23 13:25:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define GST_TYPE_ME_METHOD (gst_ffmpegenc_me_method_get_type())
|
|
|
|
static GType
|
|
|
|
gst_ffmpegenc_me_method_get_type (void)
|
|
|
|
{
|
|
|
|
static GType ffmpegenc_me_method_type = 0;
|
|
|
|
static GEnumValue ffmpegenc_me_methods[] = {
|
2007-01-08 16:39:00 +00:00
|
|
|
{ME_ZERO, "None (Very low quality)", "zero"},
|
|
|
|
{ME_FULL, "Full (Slow, unmaintained)", "full"},
|
|
|
|
{ME_LOG, "Logarithmic (Low quality, unmaintained)", "logarithmic"},
|
|
|
|
{ME_PHODS, "phods (Low quality, unmaintained)", "phods"},
|
|
|
|
{ME_EPZS, "EPZS (Best quality, Fast)", "epzs"},
|
|
|
|
{ME_X1, "X1 (Experimental)", "x1"},
|
2004-03-29 16:39:18 +00:00
|
|
|
{0, NULL, NULL},
|
2001-12-23 13:25:04 +00:00
|
|
|
};
|
|
|
|
if (!ffmpegenc_me_method_type) {
|
2004-03-29 16:39:18 +00:00
|
|
|
ffmpegenc_me_method_type =
|
|
|
|
g_enum_register_static ("GstFFMpegEncMeMethod", ffmpegenc_me_methods);
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
|
|
|
return ffmpegenc_me_method_type;
|
|
|
|
}
|
|
|
|
|
2007-02-16 11:48:15 +00:00
|
|
|
/* A number of function prototypes are given so we can refer to them later. */
|
2004-03-29 16:39:18 +00:00
|
|
|
static void gst_ffmpegenc_class_init (GstFFMpegEncClass * klass);
|
|
|
|
static void gst_ffmpegenc_base_init (GstFFMpegEncClass * klass);
|
|
|
|
static void gst_ffmpegenc_init (GstFFMpegEnc * ffmpegenc);
|
2007-01-03 17:00:08 +00:00
|
|
|
static void gst_ffmpegenc_finalize (GObject * object);
|
2003-06-07 20:46:24 +00:00
|
|
|
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
static gboolean gst_ffmpegenc_setcaps (GstPad * pad, GstCaps * caps);
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
static GstCaps *gst_ffmpegenc_getcaps (GstPad * pad);
|
|
|
|
static GstFlowReturn gst_ffmpegenc_chain_video (GstPad * pad,
|
|
|
|
GstBuffer * buffer);
|
|
|
|
static GstFlowReturn gst_ffmpegenc_chain_audio (GstPad * pad,
|
|
|
|
GstBuffer * buffer);
|
|
|
|
static gboolean gst_ffmpegenc_event_video (GstPad * pad, GstEvent * event);
|
2009-03-25 11:51:55 +00:00
|
|
|
static gboolean gst_ffmpegenc_event_src (GstPad * pad, GstEvent * event);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
static void gst_ffmpegenc_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_ffmpegenc_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
|
|
|
|
2005-09-05 14:06:29 +00:00
|
|
|
static GstStateChangeReturn gst_ffmpegenc_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2007-02-16 11:48:15 +00:00
|
|
|
#define GST_FFENC_PARAMS_QDATA g_quark_from_static_string("ffenc-params")
|
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
2002-03-19 04:09:41 +00:00
|
|
|
/*static guint gst_ffmpegenc_signals[LAST_SIGNAL] = { 0 }; */
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2003-11-02 13:12:14 +00:00
|
|
|
static void
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpegenc_base_init (GstFFMpegEncClass * klass)
|
2003-11-02 13:12:14 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
2009-11-02 07:43:17 +00:00
|
|
|
AVCodec *in_plugin;
|
|
|
|
GstPadTemplate *srctempl = NULL, *sinktempl = NULL;
|
|
|
|
GstCaps *srccaps = NULL, *sinkcaps = NULL;
|
2010-03-24 10:51:26 +00:00
|
|
|
gchar *longname, *classification, *description;
|
2003-11-02 13:12:14 +00:00
|
|
|
|
2009-11-02 07:43:17 +00:00
|
|
|
in_plugin =
|
|
|
|
(AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
|
2007-02-16 11:48:15 +00:00
|
|
|
GST_FFENC_PARAMS_QDATA);
|
2009-11-02 07:43:17 +00:00
|
|
|
g_assert (in_plugin != NULL);
|
2003-11-02 13:12:14 +00:00
|
|
|
|
|
|
|
/* construct the element details struct */
|
2010-03-24 10:51:26 +00:00
|
|
|
longname = g_strdup_printf ("FFmpeg %s encoder", in_plugin->long_name);
|
|
|
|
classification = g_strdup_printf ("Codec/Encoder/%s",
|
2009-11-02 07:43:17 +00:00
|
|
|
(in_plugin->type == CODEC_TYPE_VIDEO) ? "Video" : "Audio");
|
2010-03-24 10:51:26 +00:00
|
|
|
description = g_strdup_printf ("FFmpeg %s encoder", in_plugin->name);
|
|
|
|
gst_element_class_set_details_simple (element_class, longname, classification,
|
|
|
|
description,
|
|
|
|
"Wim Taymans <wim.taymans@gmail.com>, "
|
|
|
|
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
|
|
|
|
g_free (longname);
|
|
|
|
g_free (classification);
|
|
|
|
g_free (description);
|
2003-11-02 13:12:14 +00:00
|
|
|
|
2009-11-02 07:43:17 +00:00
|
|
|
if (!(srccaps = gst_ffmpeg_codecid_to_caps (in_plugin->id, NULL, TRUE))) {
|
|
|
|
GST_DEBUG ("Couldn't get source caps for encoder '%s'", in_plugin->name);
|
|
|
|
srccaps = gst_caps_new_simple ("unknown/unknown", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (in_plugin->type == CODEC_TYPE_VIDEO) {
|
|
|
|
sinkcaps = gst_caps_from_string
|
|
|
|
("video/x-raw-rgb; video/x-raw-yuv; video/x-raw-gray");
|
|
|
|
} else {
|
|
|
|
sinkcaps = gst_ffmpeg_codectype_to_audio_caps (NULL,
|
|
|
|
in_plugin->id, TRUE, in_plugin);
|
|
|
|
}
|
|
|
|
if (!sinkcaps) {
|
|
|
|
GST_DEBUG ("Couldn't get sink caps for encoder '%s'", in_plugin->name);
|
|
|
|
sinkcaps = gst_caps_new_simple ("unknown/unknown", NULL);
|
|
|
|
}
|
|
|
|
|
2003-11-02 13:12:14 +00:00
|
|
|
/* pad templates */
|
|
|
|
sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
|
2009-11-02 07:43:17 +00:00
|
|
|
GST_PAD_ALWAYS, sinkcaps);
|
|
|
|
srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
|
2003-11-02 13:12:14 +00:00
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class, srctempl);
|
|
|
|
gst_element_class_add_pad_template (element_class, sinktempl);
|
|
|
|
|
2009-11-02 07:43:17 +00:00
|
|
|
klass->in_plugin = in_plugin;
|
2003-11-02 13:12:14 +00:00
|
|
|
klass->srctempl = srctempl;
|
|
|
|
klass->sinktempl = sinktempl;
|
2004-12-17 11:32:45 +00:00
|
|
|
klass->sinkcaps = NULL;
|
2009-11-02 07:43:17 +00:00
|
|
|
|
|
|
|
return;
|
2003-11-02 13:12:14 +00:00
|
|
|
}
|
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
static void
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpegenc_class_init (GstFFMpegEncClass * klass)
|
2001-12-23 13:25:04 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2006-04-08 21:55:22 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
gobject_class->set_property = gst_ffmpegenc_set_property;
|
|
|
|
gobject_class->get_property = gst_ffmpegenc_get_property;
|
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
if (klass->in_plugin->type == CODEC_TYPE_VIDEO) {
|
2004-03-29 16:39:18 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BIT_RATE,
|
|
|
|
g_param_spec_ulong ("bitrate", "Bit Rate",
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
"Target Video Bitrate", 0, G_MAXULONG, DEFAULT_VIDEO_BITRATE,
|
2010-10-19 14:26:08 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2004-03-29 16:39:18 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GOP_SIZE,
|
2009-10-01 14:20:13 +00:00
|
|
|
g_param_spec_int ("gop-size", "GOP Size",
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
"Number of frames within one GOP", 0, G_MAXINT,
|
2010-10-19 14:26:08 +00:00
|
|
|
DEFAULT_VIDEO_GOP_SIZE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2004-03-29 16:39:18 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ME_METHOD,
|
2009-10-01 14:20:13 +00:00
|
|
|
g_param_spec_enum ("me-method", "ME Method", "Motion Estimation Method",
|
2010-10-19 14:26:08 +00:00
|
|
|
GST_TYPE_ME_METHOD, ME_EPZS,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2009-10-08 11:54:45 +00:00
|
|
|
|
|
|
|
/* FIXME 0.11: Make this property read-only */
|
2004-03-29 16:39:18 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFSIZE,
|
2009-10-01 14:20:13 +00:00
|
|
|
g_param_spec_ulong ("buffer-size", "Buffer Size",
|
2009-10-08 11:54:45 +00:00
|
|
|
"Size of the video buffers. "
|
|
|
|
"Note: Setting this property has no effect "
|
2010-10-19 14:26:08 +00:00
|
|
|
"and is deprecated!", 0, G_MAXULONG, 0,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2005-11-28 17:12:13 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
2009-10-01 14:20:13 +00:00
|
|
|
ARG_RTP_PAYLOAD_SIZE, g_param_spec_ulong ("rtp-payload-size",
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
"RTP Payload Size", "Target GOB length", 0, G_MAXULONG, 0,
|
2010-10-19 14:26:08 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
|
|
|
|
/* register additional properties, possibly dependent on the exact CODEC */
|
|
|
|
gst_ffmpeg_cfg_install_property (klass, ARG_CFG_BASE);
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (klass->in_plugin->type == CODEC_TYPE_AUDIO) {
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BIT_RATE,
|
|
|
|
g_param_spec_ulong ("bitrate", "Bit Rate",
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
"Target Audio Bitrate", 0, G_MAXULONG, DEFAULT_AUDIO_BITRATE,
|
2010-10-19 14:26:08 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
gstelement_class->change_state = gst_ffmpegenc_change_state;
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2007-01-03 17:00:08 +00:00
|
|
|
gobject_class->finalize = gst_ffmpegenc_finalize;
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpegenc_init (GstFFMpegEnc * ffmpegenc)
|
2001-12-23 13:25:04 +00:00
|
|
|
{
|
2004-03-29 16:39:18 +00:00
|
|
|
GstFFMpegEncClass *oclass =
|
|
|
|
(GstFFMpegEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc));
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
/* setup pads */
|
|
|
|
ffmpegenc->sinkpad = gst_pad_new_from_template (oclass->sinktempl, "sink");
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
gst_pad_set_setcaps_function (ffmpegenc->sinkpad, gst_ffmpegenc_setcaps);
|
2004-12-17 11:32:45 +00:00
|
|
|
gst_pad_set_getcaps_function (ffmpegenc->sinkpad, gst_ffmpegenc_getcaps);
|
2003-06-07 20:46:24 +00:00
|
|
|
ffmpegenc->srcpad = gst_pad_new_from_template (oclass->srctempl, "src");
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
gst_pad_use_fixed_caps (ffmpegenc->srcpad);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
/* ffmpeg objects */
|
2004-03-29 16:39:18 +00:00
|
|
|
ffmpegenc->context = avcodec_alloc_context ();
|
|
|
|
ffmpegenc->picture = avcodec_alloc_frame ();
|
2003-06-07 20:46:24 +00:00
|
|
|
ffmpegenc->opened = FALSE;
|
|
|
|
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
ffmpegenc->file = NULL;
|
|
|
|
ffmpegenc->delay = g_queue_new ();
|
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
if (oclass->in_plugin->type == CODEC_TYPE_VIDEO) {
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
gst_pad_set_chain_function (ffmpegenc->sinkpad, gst_ffmpegenc_chain_video);
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
/* so we know when to flush the buffers on EOS */
|
|
|
|
gst_pad_set_event_function (ffmpegenc->sinkpad, gst_ffmpegenc_event_video);
|
2009-03-25 11:51:55 +00:00
|
|
|
gst_pad_set_event_function (ffmpegenc->srcpad, gst_ffmpegenc_event_src);
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
|
2006-02-11 12:04:31 +00:00
|
|
|
ffmpegenc->bitrate = DEFAULT_VIDEO_BITRATE;
|
2006-10-24 09:27:16 +00:00
|
|
|
ffmpegenc->me_method = ME_EPZS;
|
2003-06-07 20:46:24 +00:00
|
|
|
ffmpegenc->buffer_size = 512 * 1024;
|
2006-02-11 12:04:31 +00:00
|
|
|
ffmpegenc->gop_size = DEFAULT_VIDEO_GOP_SIZE;
|
2005-11-28 17:12:13 +00:00
|
|
|
ffmpegenc->rtp_payload_size = 0;
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
|
2006-10-06 14:46:48 +00:00
|
|
|
ffmpegenc->lmin = 2;
|
|
|
|
ffmpegenc->lmax = 31;
|
|
|
|
ffmpegenc->max_key_interval = 0;
|
|
|
|
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
gst_ffmpeg_cfg_set_defaults (ffmpegenc);
|
2003-06-07 20:46:24 +00:00
|
|
|
} else if (oclass->in_plugin->type == CODEC_TYPE_AUDIO) {
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
gst_pad_set_chain_function (ffmpegenc->sinkpad, gst_ffmpegenc_chain_audio);
|
|
|
|
|
2006-02-11 12:04:31 +00:00
|
|
|
ffmpegenc->bitrate = DEFAULT_AUDIO_BITRATE;
|
2003-06-07 20:46:24 +00:00
|
|
|
}
|
2004-10-11 08:21:16 +00:00
|
|
|
|
|
|
|
gst_element_add_pad (GST_ELEMENT (ffmpegenc), ffmpegenc->sinkpad);
|
|
|
|
gst_element_add_pad (GST_ELEMENT (ffmpegenc), ffmpegenc->srcpad);
|
2009-05-12 23:04:30 +00:00
|
|
|
|
|
|
|
ffmpegenc->adapter = gst_adapter_new ();
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-01-03 17:00:08 +00:00
|
|
|
gst_ffmpegenc_finalize (GObject * object)
|
2001-12-23 13:25:04 +00:00
|
|
|
{
|
2003-06-07 20:46:24 +00:00
|
|
|
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) object;
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2007-08-01 17:43:39 +00:00
|
|
|
gst_ffmpeg_cfg_finalize (ffmpegenc);
|
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
/* close old session */
|
|
|
|
if (ffmpegenc->opened) {
|
2005-12-16 16:23:05 +00:00
|
|
|
gst_ffmpeg_avcodec_close (ffmpegenc->context);
|
2003-06-07 20:46:24 +00:00
|
|
|
ffmpegenc->opened = FALSE;
|
|
|
|
}
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
/* clean up remaining allocated data */
|
|
|
|
av_free (ffmpegenc->context);
|
|
|
|
av_free (ffmpegenc->picture);
|
2005-01-09 21:47:26 +00:00
|
|
|
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
g_queue_free (ffmpegenc->delay);
|
|
|
|
g_free (ffmpegenc->filename);
|
|
|
|
|
2009-05-12 23:04:30 +00:00
|
|
|
g_object_unref (ffmpegenc->adapter);
|
|
|
|
|
2007-01-03 17:00:08 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2003-06-07 20:46:24 +00:00
|
|
|
}
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2009-03-06 18:47:05 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_ffmpegenc_get_possible_sizes (GstFFMpegEnc * ffmpegenc, GstPad * pad,
|
|
|
|
const GstCaps * caps)
|
|
|
|
{
|
|
|
|
GstCaps *othercaps = NULL;
|
|
|
|
GstCaps *tmpcaps = NULL;
|
|
|
|
GstCaps *intersect = NULL;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
othercaps = gst_pad_peer_get_caps (ffmpegenc->srcpad);
|
|
|
|
|
|
|
|
if (!othercaps)
|
|
|
|
return gst_caps_copy (caps);
|
|
|
|
|
|
|
|
intersect = gst_caps_intersect (othercaps,
|
|
|
|
gst_pad_get_pad_template_caps (ffmpegenc->srcpad));
|
|
|
|
gst_caps_unref (othercaps);
|
|
|
|
|
|
|
|
if (gst_caps_is_empty (intersect))
|
|
|
|
return intersect;
|
|
|
|
|
|
|
|
if (gst_caps_is_any (intersect))
|
|
|
|
return gst_caps_copy (caps);
|
|
|
|
|
|
|
|
tmpcaps = gst_caps_new_empty ();
|
|
|
|
|
|
|
|
for (i = 0; i < gst_caps_get_size (intersect); i++) {
|
|
|
|
GstStructure *s = gst_caps_get_structure (intersect, i);
|
|
|
|
const GValue *height = NULL;
|
|
|
|
const GValue *width = NULL;
|
|
|
|
const GValue *framerate = NULL;
|
|
|
|
GstStructure *tmps;
|
|
|
|
|
|
|
|
height = gst_structure_get_value (s, "height");
|
|
|
|
width = gst_structure_get_value (s, "width");
|
|
|
|
framerate = gst_structure_get_value (s, "framerate");
|
|
|
|
|
|
|
|
tmps = gst_structure_new ("video/x-raw-rgb", NULL);
|
|
|
|
if (width)
|
|
|
|
gst_structure_set_value (tmps, "width", width);
|
|
|
|
if (height)
|
|
|
|
gst_structure_set_value (tmps, "height", height);
|
|
|
|
if (framerate)
|
|
|
|
gst_structure_set_value (tmps, "framerate", framerate);
|
|
|
|
gst_caps_merge_structure (tmpcaps, gst_structure_copy (tmps));
|
|
|
|
|
|
|
|
gst_structure_set_name (tmps, "video/x-raw-yuv");
|
|
|
|
gst_caps_merge_structure (tmpcaps, gst_structure_copy (tmps));
|
|
|
|
|
|
|
|
gst_structure_set_name (tmps, "video/x-raw-gray");
|
|
|
|
gst_caps_merge_structure (tmpcaps, tmps);
|
|
|
|
}
|
|
|
|
gst_caps_unref (intersect);
|
|
|
|
|
|
|
|
intersect = gst_caps_intersect (caps, tmpcaps);
|
|
|
|
gst_caps_unref (tmpcaps);
|
|
|
|
|
|
|
|
return intersect;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-17 11:32:45 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_ffmpegenc_getcaps (GstPad * pad)
|
|
|
|
{
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) GST_PAD_PARENT (pad);
|
2004-12-17 11:32:45 +00:00
|
|
|
GstFFMpegEncClass *oclass =
|
|
|
|
(GstFFMpegEncClass *) G_OBJECT_GET_CLASS (ffmpegenc);
|
2008-08-01 18:37:02 +00:00
|
|
|
AVCodecContext *ctx = NULL;
|
2004-12-17 11:32:45 +00:00
|
|
|
enum PixelFormat pixfmt;
|
|
|
|
GstCaps *caps = NULL;
|
2009-03-06 18:47:05 +00:00
|
|
|
GstCaps *finalcaps = NULL;
|
2008-10-08 14:20:37 +00:00
|
|
|
gint i;
|
2004-12-17 11:32:45 +00:00
|
|
|
|
2008-05-26 09:19:53 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "getting caps");
|
|
|
|
|
2004-12-17 11:32:45 +00:00
|
|
|
/* audio needs no special care */
|
|
|
|
if (oclass->in_plugin->type == CODEC_TYPE_AUDIO) {
|
2008-05-26 09:19:53 +00:00
|
|
|
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
|
|
|
|
2008-10-30 12:05:45 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "audio caps, return template %" GST_PTR_FORMAT,
|
|
|
|
caps);
|
2008-05-26 09:19:53 +00:00
|
|
|
|
|
|
|
return caps;
|
2004-12-17 11:32:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* cached */
|
|
|
|
if (oclass->sinkcaps) {
|
2009-03-06 18:47:05 +00:00
|
|
|
caps = gst_ffmpegenc_get_possible_sizes (ffmpegenc, pad, oclass->sinkcaps);
|
2008-10-30 12:05:45 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "return cached caps %" GST_PTR_FORMAT, caps);
|
2008-05-26 09:19:53 +00:00
|
|
|
return caps;
|
2004-12-17 11:32:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* create cache etc. */
|
|
|
|
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
/* shut up the logging while we autoprobe; we don't want warnings and
|
|
|
|
* errors about unsupported formats */
|
|
|
|
/* FIXME: if someone cares about this disabling the logging for other
|
|
|
|
* instances/threads/..., one could investigate if there is a way to
|
|
|
|
* set this as a struct member on the av context, and check it from the
|
|
|
|
* log handler */
|
2006-02-03 18:39:38 +00:00
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
2005-09-13 12:16:32 +00:00
|
|
|
_shut_up_I_am_probing = TRUE;
|
2006-02-03 18:39:38 +00:00
|
|
|
#endif
|
2008-05-26 09:19:53 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "probing caps");
|
2008-10-08 14:20:37 +00:00
|
|
|
i = pixfmt = 0;
|
|
|
|
/* check pixfmt until deemed finished */
|
|
|
|
for (pixfmt = 0;; pixfmt++) {
|
2006-10-26 11:41:45 +00:00
|
|
|
GstCaps *tmpcaps;
|
2006-10-13 13:13:08 +00:00
|
|
|
|
2008-10-08 14:20:37 +00:00
|
|
|
/* override looping all pixfmt if codec declares pixfmts;
|
|
|
|
* these may not properly check and report supported pixfmt during _init */
|
|
|
|
if (oclass->in_plugin->pix_fmts) {
|
2009-07-31 11:27:28 +00:00
|
|
|
if ((pixfmt = oclass->in_plugin->pix_fmts[i++]) == PIX_FMT_NONE) {
|
|
|
|
GST_DEBUG_OBJECT (ffmpegenc,
|
|
|
|
"At the end of official pixfmt for this codec, breaking out");
|
2008-10-08 14:20:37 +00:00
|
|
|
break;
|
2009-07-31 11:27:28 +00:00
|
|
|
}
|
|
|
|
GST_DEBUG_OBJECT (ffmpegenc,
|
|
|
|
"Got an official pixfmt [%d], attempting to get caps", pixfmt);
|
2009-08-08 20:43:06 +00:00
|
|
|
tmpcaps = gst_ffmpeg_pixfmt_to_caps (pixfmt, NULL, oclass->in_plugin->id);
|
2009-07-31 11:27:28 +00:00
|
|
|
if (tmpcaps) {
|
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "Got caps, breaking out");
|
|
|
|
if (!caps)
|
|
|
|
caps = gst_caps_new_empty ();
|
|
|
|
gst_caps_append (caps, tmpcaps);
|
2009-08-09 07:47:26 +00:00
|
|
|
continue;
|
2009-07-31 11:27:28 +00:00
|
|
|
}
|
|
|
|
GST_DEBUG_OBJECT (ffmpegenc,
|
|
|
|
"Couldn't figure out caps without context, trying again with a context");
|
2008-10-08 14:20:37 +00:00
|
|
|
}
|
2009-07-31 11:27:28 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "pixfmt :%d", pixfmt);
|
|
|
|
if (pixfmt >= PIX_FMT_NB) {
|
|
|
|
GST_WARNING ("Invalid pixfmt, breaking out");
|
2008-10-08 14:20:37 +00:00
|
|
|
break;
|
2009-07-31 11:27:28 +00:00
|
|
|
}
|
2008-10-08 14:20:37 +00:00
|
|
|
|
2008-08-01 18:37:02 +00:00
|
|
|
/* need to start with a fresh codec_context each time around, since
|
|
|
|
* codec_close may have released stuff causing the next pass to segfault */
|
|
|
|
ctx = avcodec_alloc_context ();
|
|
|
|
if (!ctx) {
|
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "no context");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set some default properties */
|
|
|
|
ctx->width = DEFAULT_WIDTH;
|
|
|
|
ctx->height = DEFAULT_HEIGHT;
|
2008-10-30 12:05:45 +00:00
|
|
|
ctx->time_base.num = 1;
|
|
|
|
ctx->time_base.den = 25;
|
2009-03-17 22:44:43 +00:00
|
|
|
ctx->ticks_per_frame = 1;
|
2008-08-01 18:37:02 +00:00
|
|
|
ctx->bit_rate = DEFAULT_VIDEO_BITRATE;
|
|
|
|
/* makes it silent */
|
|
|
|
ctx->strict_std_compliance = -1;
|
|
|
|
|
2004-12-17 11:32:45 +00:00
|
|
|
ctx->pix_fmt = pixfmt;
|
2009-07-31 11:27:28 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Attempting to open codec");
|
2005-12-16 16:23:05 +00:00
|
|
|
if (gst_ffmpeg_avcodec_open (ctx, oclass->in_plugin) >= 0 &&
|
2004-12-17 11:32:45 +00:00
|
|
|
ctx->pix_fmt == pixfmt) {
|
|
|
|
ctx->width = -1;
|
|
|
|
if (!caps)
|
|
|
|
caps = gst_caps_new_empty ();
|
ext/ffmpeg/: Use codecid as extra parameter when getting caps.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_get_palette),
(gst_ffmpeg_set_palette), (gst_ff_vid_caps_new),
(gst_ff_aud_caps_new), (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_smpfmt_to_caps),
(gst_ffmpeg_codectype_to_caps), (gst_ffmpeg_caps_to_pixfmt),
(gst_ffmpeg_caps_with_codecid), (gst_ffmpeg_formatid_to_caps),
(gst_ffmpeg_formatid_get_codecids), (gst_ffmpeg_caps_to_codecid),
(gst_ffmpeg_init_pix_fmt_info), (gst_ffmpeg_avpicture_fill),
(gst_ffmpeg_img_convert):
* ext/ffmpeg/gstffmpegcodecmap.h:
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_register):
Use codecid as extra parameter when getting caps.
Restrict H263 caps to allowed sizes for better negotiation.
MP4/3gp can contain AMR-WB as well.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_register):
Indent.
2007-01-09 14:59:34 +00:00
|
|
|
tmpcaps = gst_ffmpeg_codectype_to_caps (oclass->in_plugin->type, ctx,
|
2008-10-08 14:20:37 +00:00
|
|
|
oclass->in_plugin->id, TRUE);
|
2006-10-13 13:13:08 +00:00
|
|
|
if (tmpcaps)
|
2006-10-26 11:41:45 +00:00
|
|
|
gst_caps_append (caps, tmpcaps);
|
2006-10-13 13:13:08 +00:00
|
|
|
else
|
2006-10-26 11:41:45 +00:00
|
|
|
GST_LOG_OBJECT (ffmpegenc,
|
|
|
|
"Couldn't get caps for oclass->in_plugin->name:%s",
|
|
|
|
oclass->in_plugin->name);
|
2005-12-16 16:23:05 +00:00
|
|
|
gst_ffmpeg_avcodec_close (ctx);
|
2009-07-31 11:27:28 +00:00
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "Opening codec failed with pixfmt : %d",
|
|
|
|
pixfmt);
|
2004-12-17 11:32:45 +00:00
|
|
|
}
|
2005-06-03 11:34:13 +00:00
|
|
|
if (ctx->priv_data)
|
2005-12-16 16:23:05 +00:00
|
|
|
gst_ffmpeg_avcodec_close (ctx);
|
2008-08-01 18:37:02 +00:00
|
|
|
av_free (ctx);
|
2004-12-17 11:32:45 +00:00
|
|
|
}
|
2006-02-03 18:39:38 +00:00
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
2005-09-13 12:16:32 +00:00
|
|
|
_shut_up_I_am_probing = FALSE;
|
2006-02-03 18:39:38 +00:00
|
|
|
#endif
|
2004-12-17 11:32:45 +00:00
|
|
|
|
|
|
|
/* make sure we have something */
|
|
|
|
if (!caps) {
|
2009-03-06 18:47:05 +00:00
|
|
|
caps = gst_ffmpegenc_get_possible_sizes (ffmpegenc, pad,
|
|
|
|
gst_pad_get_pad_template_caps (pad));
|
2008-08-01 18:37:02 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "probing gave nothing, "
|
|
|
|
"return template %" GST_PTR_FORMAT, caps);
|
2008-05-26 09:19:53 +00:00
|
|
|
return caps;
|
2004-12-17 11:32:45 +00:00
|
|
|
}
|
|
|
|
|
2008-10-30 12:05:45 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "probed caps gave %" GST_PTR_FORMAT, caps);
|
2004-12-17 11:32:45 +00:00
|
|
|
oclass->sinkcaps = gst_caps_copy (caps);
|
|
|
|
|
2009-03-06 18:47:05 +00:00
|
|
|
finalcaps = gst_ffmpegenc_get_possible_sizes (ffmpegenc, pad, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
return finalcaps;
|
2004-12-17 11:32:45 +00:00
|
|
|
}
|
|
|
|
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
static gboolean
|
|
|
|
gst_ffmpegenc_setcaps (GstPad * pad, GstCaps * caps)
|
2003-06-07 20:46:24 +00:00
|
|
|
{
|
2003-12-22 01:46:58 +00:00
|
|
|
GstCaps *other_caps;
|
2004-01-09 01:53:31 +00:00
|
|
|
GstCaps *allowed_caps;
|
|
|
|
GstCaps *icaps;
|
2003-12-22 01:46:58 +00:00
|
|
|
enum PixelFormat pix_fmt;
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) GST_PAD_PARENT (pad);
|
2004-03-29 16:39:18 +00:00
|
|
|
GstFFMpegEncClass *oclass =
|
|
|
|
(GstFFMpegEncClass *) G_OBJECT_GET_CLASS (ffmpegenc);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
/* close old session */
|
|
|
|
if (ffmpegenc->opened) {
|
2005-12-16 16:23:05 +00:00
|
|
|
gst_ffmpeg_avcodec_close (ffmpegenc->context);
|
2003-06-07 20:46:24 +00:00
|
|
|
ffmpegenc->opened = FALSE;
|
2010-10-25 10:14:42 +00:00
|
|
|
/* fixed src caps;
|
|
|
|
* so clear src caps for proper (re-)negotiation */
|
|
|
|
gst_pad_set_caps (ffmpegenc->srcpad, NULL);
|
2003-06-07 20:46:24 +00:00
|
|
|
}
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
/* set defaults */
|
|
|
|
avcodec_get_context_defaults (ffmpegenc->context);
|
|
|
|
|
2005-01-16 11:29:28 +00:00
|
|
|
/* if we set it in _getcaps we should set it also in _link */
|
|
|
|
ffmpegenc->context->strict_std_compliance = -1;
|
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
/* user defined properties */
|
|
|
|
ffmpegenc->context->bit_rate = ffmpegenc->bitrate;
|
|
|
|
ffmpegenc->context->bit_rate_tolerance = ffmpegenc->bitrate;
|
|
|
|
ffmpegenc->context->gop_size = ffmpegenc->gop_size;
|
|
|
|
ffmpegenc->context->me_method = ffmpegenc->me_method;
|
2006-10-05 18:44:09 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "Setting avcontext to bitrate %lu, gop_size %d",
|
2006-02-11 12:04:31 +00:00
|
|
|
ffmpegenc->bitrate, ffmpegenc->gop_size);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2005-11-28 17:12:13 +00:00
|
|
|
/* RTP payload used for GOB production (for Asterisk) */
|
|
|
|
if (ffmpegenc->rtp_payload_size) {
|
|
|
|
ffmpegenc->context->rtp_payload_size = ffmpegenc->rtp_payload_size;
|
|
|
|
}
|
|
|
|
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
/* additional avcodec settings */
|
|
|
|
/* first fill in the majority by copying over */
|
|
|
|
gst_ffmpeg_cfg_fill_context (ffmpegenc, ffmpegenc->context);
|
|
|
|
|
|
|
|
/* then handle some special cases */
|
|
|
|
ffmpegenc->context->lmin = (ffmpegenc->lmin * FF_QP2LAMBDA + 0.5);
|
|
|
|
ffmpegenc->context->lmax = (ffmpegenc->lmax * FF_QP2LAMBDA + 0.5);
|
|
|
|
|
|
|
|
if (ffmpegenc->interlaced) {
|
|
|
|
ffmpegenc->context->flags |=
|
|
|
|
CODEC_FLAG_INTERLACED_DCT | CODEC_FLAG_INTERLACED_ME;
|
|
|
|
ffmpegenc->picture->interlaced_frame = TRUE;
|
|
|
|
/* if this is not the case, a filter element should be used to swap fields */
|
|
|
|
ffmpegenc->picture->top_field_first = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* some other defaults */
|
|
|
|
ffmpegenc->context->rc_strategy = 2;
|
|
|
|
ffmpegenc->context->b_frame_strategy = 0;
|
|
|
|
ffmpegenc->context->coder_type = 0;
|
|
|
|
ffmpegenc->context->context_model = 0;
|
|
|
|
ffmpegenc->context->scenechange_threshold = 0;
|
|
|
|
ffmpegenc->context->inter_threshold = 0;
|
|
|
|
|
|
|
|
/* and last but not least the pass; CBR, 2-pass, etc */
|
|
|
|
ffmpegenc->context->flags |= ffmpegenc->pass;
|
|
|
|
switch (ffmpegenc->pass) {
|
|
|
|
/* some additional action depends on type of pass */
|
|
|
|
case CODEC_FLAG_QSCALE:
|
|
|
|
ffmpegenc->context->global_quality
|
|
|
|
= ffmpegenc->picture->quality = FF_QP2LAMBDA * ffmpegenc->quantizer;
|
|
|
|
break;
|
|
|
|
case CODEC_FLAG_PASS1: /* need to prepare a stats file */
|
|
|
|
/* we don't close when changing caps, fingers crossed */
|
|
|
|
if (!ffmpegenc->file)
|
|
|
|
ffmpegenc->file = g_fopen (ffmpegenc->filename, "w");
|
|
|
|
if (!ffmpegenc->file) {
|
|
|
|
GST_ELEMENT_ERROR (ffmpegenc, RESOURCE, OPEN_WRITE,
|
|
|
|
(("Could not open file \"%s\" for writing."), ffmpegenc->filename),
|
|
|
|
GST_ERROR_SYSTEM);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CODEC_FLAG_PASS2:
|
|
|
|
{ /* need to read the whole stats file ! */
|
|
|
|
gsize size;
|
|
|
|
|
|
|
|
if (!g_file_get_contents (ffmpegenc->filename,
|
|
|
|
&ffmpegenc->context->stats_in, &size, NULL)) {
|
|
|
|
GST_ELEMENT_ERROR (ffmpegenc, RESOURCE, READ,
|
|
|
|
(("Could not get contents of file \"%s\"."), ffmpegenc->filename),
|
|
|
|
GST_ERROR_SYSTEM);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
/* fetch pix_fmt and so on */
|
ext/ffmpeg/gstffmpegcodecmap.*: Change some function names to reflect that they don't really _return_ something, but ...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_get_palette),
(gst_ffmpeg_set_palette), (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_smpfmt),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_caps_with_codectype),
(gst_ffmpeg_caps_with_codecid), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Change some function names to reflect that they don't really
_return_ something, but rather _use_ something to fill a
AVCodecContext. s/to/with/. Restructure the extradata handling,
it's now not picking up the type from the caps but rather
using the type as provided in the function. This is a lot
cleaner. Implement MS RLE palette pickup.
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_pad_link):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect):
Sync with the above function name changes.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_close),
(gst_ffmpegdec_open), (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state):
Add some hacks to convert palette-based raw image formats to
RGBA32. Ugly, but I don't know how else to handle palette-based
RGB, since img_convert() (and thus ffcolorspace) doesn't accept
a palette as argument.
2004-04-16 01:28:36 +00:00
|
|
|
gst_ffmpeg_caps_with_codectype (oclass->in_plugin->type,
|
2004-03-29 16:39:18 +00:00
|
|
|
caps, ffmpegenc->context);
|
2005-07-27 16:03:51 +00:00
|
|
|
if (!ffmpegenc->context->time_base.den) {
|
|
|
|
ffmpegenc->context->time_base.den = 25;
|
|
|
|
ffmpegenc->context->time_base.num = 1;
|
2009-03-17 22:44:43 +00:00
|
|
|
ffmpegenc->context->ticks_per_frame = 1;
|
2006-10-26 11:41:45 +00:00
|
|
|
} else if ((oclass->in_plugin->id == CODEC_ID_MPEG4)
|
|
|
|
&& (ffmpegenc->context->time_base.den > 65535)) {
|
|
|
|
/* MPEG4 Standards do not support time_base denominator greater than
|
|
|
|
* (1<<16) - 1 . We therefore scale them down.
|
|
|
|
* Agreed, it will not be the exact framerate... but the difference
|
|
|
|
* shouldn't be that noticeable */
|
|
|
|
ffmpegenc->context->time_base.num =
|
|
|
|
(gint) gst_util_uint64_scale_int (ffmpegenc->context->time_base.num,
|
|
|
|
65535, ffmpegenc->context->time_base.den);
|
|
|
|
ffmpegenc->context->time_base.den = 65535;
|
|
|
|
GST_LOG_OBJECT (ffmpegenc, "MPEG4 : scaled down framerate to %d / %d",
|
|
|
|
ffmpegenc->context->time_base.den, ffmpegenc->context->time_base.num);
|
2005-07-27 16:03:51 +00:00
|
|
|
}
|
ext/: Update to ffmpeg snapshot of Jul 20 2005 4:00 PM GMT. Mostly some added codecs, some API changes, etc. Also add...
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.h:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_formatid_get_codecids),
(gst_ffmpeg_caps_to_codecid), (gst_ffmpeg_get_codecid_longname),
(gst_ffmpeg_img_convert):
* ext/ffmpeg/gstffmpegcodecmap.h:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_chain),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegdeinterlace.c:
(gst_ffmpegdeinterlace_getcaps), (gst_ffmpegdeinterlace_pad_link):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_link), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_write):
* ext/ffmpeg/gstffmpegscale.c: (gst_ffmpegscale_pad_link):
* ext/libpostproc/gstpostproc.c: (gst_postproc_chain):
Update to ffmpeg snapshot of Jul 20 2005 4:00 PM GMT. Mostly
some added codecs, some API changes, etc. Also adds a VOB muxer
for MPEG-2 video and adds h264 to .mp4 muxing.
2005-07-20 15:40:57 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
pix_fmt = ffmpegenc->context->pix_fmt;
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
/* max-key-interval may need the framerate set above */
|
|
|
|
if (ffmpegenc->max_key_interval) {
|
|
|
|
AVCodecContext *ctx;
|
|
|
|
|
|
|
|
/* override gop-size */
|
|
|
|
ctx = ffmpegenc->context;
|
|
|
|
ctx->gop_size = (ffmpegenc->max_key_interval < 0) ?
|
|
|
|
(-ffmpegenc->max_key_interval
|
2009-03-17 22:44:43 +00:00
|
|
|
* (ctx->time_base.den * ctx->ticks_per_frame / ctx->time_base.num))
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
: ffmpegenc->max_key_interval;
|
|
|
|
}
|
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
/* open codec */
|
2005-12-16 16:23:05 +00:00
|
|
|
if (gst_ffmpeg_avcodec_open (ffmpegenc->context, oclass->in_plugin) < 0) {
|
2005-02-05 18:35:18 +00:00
|
|
|
if (ffmpegenc->context->priv_data)
|
2005-12-16 16:23:05 +00:00
|
|
|
gst_ffmpeg_avcodec_close (ffmpegenc->context);
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
if (ffmpegenc->context->stats_in)
|
|
|
|
g_free (ffmpegenc->context->stats_in);
|
2006-02-11 12:04:31 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "ffenc_%s: Failed to open FFMPEG codec",
|
2004-03-29 16:39:18 +00:00
|
|
|
oclass->in_plugin->name);
|
2005-08-19 15:23:39 +00:00
|
|
|
return FALSE;
|
2003-06-07 21:06:05 +00:00
|
|
|
}
|
|
|
|
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
/* second pass stats buffer no longer needed */
|
|
|
|
if (ffmpegenc->context->stats_in)
|
|
|
|
g_free (ffmpegenc->context->stats_in);
|
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
/* is the colourspace correct? */
|
|
|
|
if (pix_fmt != ffmpegenc->context->pix_fmt) {
|
2005-12-16 16:23:05 +00:00
|
|
|
gst_ffmpeg_avcodec_close (ffmpegenc->context);
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegenc,
|
|
|
|
"ffenc_%s: AV wants different colourspace (%d given, %d wanted)",
|
2004-03-29 16:39:18 +00:00
|
|
|
oclass->in_plugin->name, pix_fmt, ffmpegenc->context->pix_fmt);
|
2005-08-19 15:23:39 +00:00
|
|
|
return FALSE;
|
2003-06-07 20:46:24 +00:00
|
|
|
}
|
2008-07-28 11:50:56 +00:00
|
|
|
/* 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 (oclass->in_plugin->type == CODEC_TYPE_VIDEO && pix_fmt == PIX_FMT_NONE) {
|
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "ffenc_%s: Failed to determine input format",
|
|
|
|
oclass->in_plugin->name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2004-10-25 11:56:52 +00:00
|
|
|
/* some codecs support more than one format, first auto-choose one */
|
2005-09-30 09:29:22 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "picking an output format ...");
|
2004-10-25 11:56:52 +00:00
|
|
|
allowed_caps = gst_pad_get_allowed_caps (ffmpegenc->srcpad);
|
2005-09-30 09:29:22 +00:00
|
|
|
if (!allowed_caps) {
|
2005-10-05 17:53:00 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "... but no peer, using template caps");
|
|
|
|
/* we need to copy because get_allowed_caps returns a ref, and
|
|
|
|
* get_pad_template_caps doesn't */
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
allowed_caps =
|
|
|
|
gst_caps_copy (gst_pad_get_pad_template_caps (ffmpegenc->srcpad));
|
2005-09-30 09:29:22 +00:00
|
|
|
}
|
2005-10-05 17:53:00 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "chose caps %" GST_PTR_FORMAT, allowed_caps);
|
2004-10-25 11:56:52 +00:00
|
|
|
gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
|
|
|
|
oclass->in_plugin->type, allowed_caps, ffmpegenc->context);
|
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
/* try to set this caps on the other side */
|
2003-12-22 01:46:58 +00:00
|
|
|
other_caps = gst_ffmpeg_codecid_to_caps (oclass->in_plugin->id,
|
2004-03-29 16:39:18 +00:00
|
|
|
ffmpegenc->context, TRUE);
|
2004-10-25 11:56:52 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
if (!other_caps) {
|
2005-12-16 16:23:05 +00:00
|
|
|
gst_ffmpeg_avcodec_close (ffmpegenc->context);
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
GST_DEBUG ("Unsupported codec - no caps found");
|
2005-08-19 15:23:39 +00:00
|
|
|
return FALSE;
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
2003-06-07 20:46:24 +00:00
|
|
|
|
2004-01-09 01:53:31 +00:00
|
|
|
icaps = gst_caps_intersect (allowed_caps, other_caps);
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
gst_caps_unref (allowed_caps);
|
|
|
|
gst_caps_unref (other_caps);
|
2004-01-09 01:53:31 +00:00
|
|
|
if (gst_caps_is_empty (icaps)) {
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
gst_caps_unref (icaps);
|
2005-08-19 15:23:39 +00:00
|
|
|
return FALSE;
|
2004-01-09 01:53:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gst_caps_get_size (icaps) > 1) {
|
|
|
|
GstCaps *newcaps;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
newcaps =
|
|
|
|
gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (icaps,
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
0)), NULL);
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
gst_caps_unref (icaps);
|
2004-01-09 01:53:31 +00:00
|
|
|
icaps = newcaps;
|
|
|
|
}
|
|
|
|
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
if (!gst_pad_set_caps (ffmpegenc->srcpad, icaps)) {
|
2005-12-16 16:23:05 +00:00
|
|
|
gst_ffmpeg_avcodec_close (ffmpegenc->context);
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
gst_caps_unref (icaps);
|
2005-08-19 15:23:39 +00:00
|
|
|
return FALSE;
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
gst_caps_unref (icaps);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
/* success! */
|
|
|
|
ffmpegenc->opened = TRUE;
|
|
|
|
|
2005-08-19 15:23:39 +00:00
|
|
|
return TRUE;
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
|
|
|
|
2007-06-22 12:13:18 +00:00
|
|
|
static void
|
ext/ffmpeg/: gst-indent cleanup.
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (gst_ffmpeg_avcodec_open),
(gst_ffmpeg_avcodec_close), (gst_ffmpeg_av_find_stream_info),
(gst_ffmpeg_log_callback), (plugin_init):
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context), (gst_ffmpeg_cfg_finalize):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_save_incoming_values),
(gst_ffmpegdec_get_best_values), (gst_ffmpegdec_video_frame):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_src_query):
* ext/ffmpeg/gstffmpegenc.c: (ffmpegenc_setup_working_buf),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_flush_buffers):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
gst-indent cleanup.
2007-11-03 16:14:53 +00:00
|
|
|
ffmpegenc_setup_working_buf (GstFFMpegEnc * ffmpegenc)
|
2007-06-22 12:13:18 +00:00
|
|
|
{
|
2009-10-01 14:44:22 +00:00
|
|
|
guint wanted_size =
|
|
|
|
ffmpegenc->context->width * ffmpegenc->context->height * 6 +
|
|
|
|
FF_MIN_BUFFER_SIZE;
|
|
|
|
|
|
|
|
/* Above is the buffer size used by ffmpeg/ffmpeg.c */
|
|
|
|
|
ext/ffmpeg/: gst-indent cleanup.
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (gst_ffmpeg_avcodec_open),
(gst_ffmpeg_avcodec_close), (gst_ffmpeg_av_find_stream_info),
(gst_ffmpeg_log_callback), (plugin_init):
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context), (gst_ffmpeg_cfg_finalize):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_save_incoming_values),
(gst_ffmpegdec_get_best_values), (gst_ffmpegdec_video_frame):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_src_query):
* ext/ffmpeg/gstffmpegenc.c: (ffmpegenc_setup_working_buf),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_flush_buffers):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
gst-indent cleanup.
2007-11-03 16:14:53 +00:00
|
|
|
if (ffmpegenc->working_buf == NULL ||
|
2009-10-01 14:44:22 +00:00
|
|
|
ffmpegenc->working_buf_size != wanted_size) {
|
2007-06-22 12:13:18 +00:00
|
|
|
if (ffmpegenc->working_buf)
|
|
|
|
g_free (ffmpegenc->working_buf);
|
2009-10-01 14:44:22 +00:00
|
|
|
ffmpegenc->working_buf_size = wanted_size;
|
2007-06-22 12:13:18 +00:00
|
|
|
ffmpegenc->working_buf = g_malloc (ffmpegenc->working_buf_size);
|
|
|
|
}
|
2009-10-01 14:44:22 +00:00
|
|
|
ffmpegenc->buffer_size = wanted_size;
|
2007-06-22 12:13:18 +00:00
|
|
|
}
|
|
|
|
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_ffmpegenc_chain_video (GstPad * pad, GstBuffer * inbuf)
|
2001-12-23 13:25:04 +00:00
|
|
|
{
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) (GST_PAD_PARENT (pad));
|
|
|
|
GstBuffer *outbuf;
|
2005-03-12 23:59:15 +00:00
|
|
|
gint ret_size = 0, frame_size;
|
2009-11-21 02:46:33 +00:00
|
|
|
gboolean force_keyframe;
|
2001-12-23 13:25:04 +00:00
|
|
|
|
ext/: Update to ffmpeg snapshot of Jul 20 2005 4:00 PM GMT. Mostly some added codecs, some API changes, etc. Also add...
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.h:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_formatid_get_codecids),
(gst_ffmpeg_caps_to_codecid), (gst_ffmpeg_get_codecid_longname),
(gst_ffmpeg_img_convert):
* ext/ffmpeg/gstffmpegcodecmap.h:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_chain),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegdeinterlace.c:
(gst_ffmpegdeinterlace_getcaps), (gst_ffmpegdeinterlace_pad_link):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_link), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_write):
* ext/ffmpeg/gstffmpegscale.c: (gst_ffmpegscale_pad_link):
* ext/libpostproc/gstpostproc.c: (gst_postproc_chain):
Update to ffmpeg snapshot of Jul 20 2005 4:00 PM GMT. Mostly
some added codecs, some API changes, etc. Also adds a VOB muxer
for MPEG-2 video and adds h264 to .mp4 muxing.
2005-07-20 15:40:57 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegenc,
|
|
|
|
"Received buffer of time %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (inbuf)));
|
|
|
|
|
2009-11-21 02:46:33 +00:00
|
|
|
GST_OBJECT_LOCK (ffmpegenc);
|
|
|
|
force_keyframe = ffmpegenc->force_keyframe;
|
|
|
|
ffmpegenc->force_keyframe = FALSE;
|
|
|
|
GST_OBJECT_UNLOCK (ffmpegenc);
|
|
|
|
|
|
|
|
if (force_keyframe)
|
|
|
|
ffmpegenc->picture->pict_type = FF_I_TYPE;
|
|
|
|
|
2005-03-12 23:59:15 +00:00
|
|
|
frame_size = gst_ffmpeg_avpicture_fill ((AVPicture *) ffmpegenc->picture,
|
2004-03-29 16:39:18 +00:00
|
|
|
GST_BUFFER_DATA (inbuf),
|
|
|
|
ffmpegenc->context->pix_fmt,
|
|
|
|
ffmpegenc->context->width, ffmpegenc->context->height);
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
g_return_val_if_fail (frame_size == GST_BUFFER_SIZE (inbuf), GST_FLOW_ERROR);
|
2005-01-16 11:29:28 +00:00
|
|
|
|
ext/: Update to ffmpeg snapshot of Jul 20 2005 4:00 PM GMT. Mostly some added codecs, some API changes, etc. Also add...
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.h:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_formatid_get_codecids),
(gst_ffmpeg_caps_to_codecid), (gst_ffmpeg_get_codecid_longname),
(gst_ffmpeg_img_convert):
* ext/ffmpeg/gstffmpegcodecmap.h:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_chain),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegdeinterlace.c:
(gst_ffmpegdeinterlace_getcaps), (gst_ffmpegdeinterlace_pad_link):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_link), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_write):
* ext/ffmpeg/gstffmpegscale.c: (gst_ffmpegscale_pad_link):
* ext/libpostproc/gstpostproc.c: (gst_postproc_chain):
Update to ffmpeg snapshot of Jul 20 2005 4:00 PM GMT. Mostly
some added codecs, some API changes, etc. Also adds a VOB muxer
for MPEG-2 video and adds h264 to .mp4 muxing.
2005-07-20 15:40:57 +00:00
|
|
|
ffmpegenc->picture->pts =
|
2009-03-17 22:44:43 +00:00
|
|
|
gst_ffmpeg_time_gst_to_ff (GST_BUFFER_TIMESTAMP (inbuf) /
|
|
|
|
ffmpegenc->context->ticks_per_frame, ffmpegenc->context->time_base);
|
2005-01-16 11:29:28 +00:00
|
|
|
|
2007-06-22 12:13:18 +00:00
|
|
|
ffmpegenc_setup_working_buf (ffmpegenc);
|
|
|
|
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
ret_size = avcodec_encode_video (ffmpegenc->context,
|
ext/ffmpeg/: gst-indent cleanup.
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (gst_ffmpeg_avcodec_open),
(gst_ffmpeg_avcodec_close), (gst_ffmpeg_av_find_stream_info),
(gst_ffmpeg_log_callback), (plugin_init):
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context), (gst_ffmpeg_cfg_finalize):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_save_incoming_values),
(gst_ffmpegdec_get_best_values), (gst_ffmpegdec_video_frame):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_src_query):
* ext/ffmpeg/gstffmpegenc.c: (ffmpegenc_setup_working_buf),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_flush_buffers):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
gst-indent cleanup.
2007-11-03 16:14:53 +00:00
|
|
|
ffmpegenc->working_buf, ffmpegenc->working_buf_size, ffmpegenc->picture);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2003-06-07 21:06:05 +00:00
|
|
|
if (ret_size < 0) {
|
2006-04-24 18:51:15 +00:00
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
|
|
|
GstFFMpegEncClass *oclass =
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
(GstFFMpegEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc));
|
ext/: Update to ffmpeg snapshot of Jul 20 2005 4:00 PM GMT. Mostly some added codecs, some API changes, etc. Also add...
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.h:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_formatid_get_codecids),
(gst_ffmpeg_caps_to_codecid), (gst_ffmpeg_get_codecid_longname),
(gst_ffmpeg_img_convert):
* ext/ffmpeg/gstffmpegcodecmap.h:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_chain),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegdeinterlace.c:
(gst_ffmpegdeinterlace_getcaps), (gst_ffmpegdeinterlace_pad_link):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_link), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_write):
* ext/ffmpeg/gstffmpegscale.c: (gst_ffmpegscale_pad_link):
* ext/libpostproc/gstpostproc.c: (gst_postproc_chain):
Update to ffmpeg snapshot of Jul 20 2005 4:00 PM GMT. Mostly
some added codecs, some API changes, etc. Also adds a VOB muxer
for MPEG-2 video and adds h264 to .mp4 muxing.
2005-07-20 15:40:57 +00:00
|
|
|
GST_ERROR_OBJECT (ffmpegenc,
|
|
|
|
"ffenc_%s: failed to encode buffer", oclass->in_plugin->name);
|
2006-04-24 18:51:15 +00:00
|
|
|
#endif /* GST_DISABLE_GST_DEBUG */
|
2003-06-07 21:06:05 +00:00
|
|
|
gst_buffer_unref (inbuf);
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
return GST_FLOW_OK;
|
2003-06-07 21:06:05 +00:00
|
|
|
}
|
|
|
|
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
/* handle b-frame delay when no output, so we don't output empty frames;
|
|
|
|
* timestamps and so can permute a bit between coding and display order
|
|
|
|
* but keyframes should still end up with the proper metadata */
|
|
|
|
g_queue_push_tail (ffmpegenc->delay, inbuf);
|
|
|
|
if (ret_size)
|
|
|
|
inbuf = g_queue_pop_head (ffmpegenc->delay);
|
|
|
|
else
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
|
|
|
|
/* save stats info if there is some as well as a stats file */
|
|
|
|
if (ffmpegenc->file && ffmpegenc->context->stats_out)
|
|
|
|
if (fprintf (ffmpegenc->file, "%s", ffmpegenc->context->stats_out) < 0)
|
|
|
|
GST_ELEMENT_ERROR (ffmpegenc, RESOURCE, WRITE,
|
|
|
|
(("Could not write to file \"%s\"."), ffmpegenc->filename),
|
|
|
|
GST_ERROR_SYSTEM);
|
|
|
|
|
2007-06-22 12:13:18 +00:00
|
|
|
outbuf = gst_buffer_new_and_alloc (ret_size);
|
2007-07-05 11:19:21 +00:00
|
|
|
memcpy (GST_BUFFER_DATA (outbuf), ffmpegenc->working_buf, ret_size);
|
2005-01-17 13:35:06 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (inbuf);
|
|
|
|
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (inbuf);
|
2008-07-28 11:50:56 +00:00
|
|
|
/* buggy codec may not set coded_frame */
|
|
|
|
if (ffmpegenc->context->coded_frame) {
|
|
|
|
if (!ffmpegenc->context->coded_frame->key_frame)
|
|
|
|
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
|
|
|
|
} else
|
|
|
|
GST_WARNING_OBJECT (ffmpegenc, "codec did not provide keyframe info");
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (ffmpegenc->srcpad));
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2005-08-19 15:23:39 +00:00
|
|
|
gst_buffer_unref (inbuf);
|
|
|
|
|
2009-03-25 11:51:55 +00:00
|
|
|
/* Reset frame type */
|
|
|
|
if (ffmpegenc->picture->pict_type)
|
|
|
|
ffmpegenc->picture->pict_type = 0;
|
|
|
|
|
2009-11-21 02:46:33 +00:00
|
|
|
if (force_keyframe) {
|
|
|
|
gst_pad_push_event (ffmpegenc->srcpad,
|
|
|
|
gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM,
|
|
|
|
gst_structure_new ("GstForceKeyUnit",
|
|
|
|
"timestamp", G_TYPE_UINT64, GST_BUFFER_TIMESTAMP (outbuf),
|
|
|
|
NULL)));
|
|
|
|
}
|
|
|
|
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
return gst_pad_push (ffmpegenc->srcpad, outbuf);
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
|
|
|
|
2009-05-12 23:04:30 +00:00
|
|
|
static GstFlowReturn
|
2009-05-13 21:18:50 +00:00
|
|
|
gst_ffmpegenc_encode_audio (GstFFMpegEnc * ffmpegenc, guint8 * audio_in,
|
2010-10-05 17:22:28 +00:00
|
|
|
guint in_size, guint max_size, GstClockTime timestamp,
|
|
|
|
GstClockTime duration, gboolean discont)
|
2009-05-12 23:04:30 +00:00
|
|
|
{
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
AVCodecContext *ctx;
|
2009-05-13 21:18:50 +00:00
|
|
|
guint8 *audio_out;
|
2009-05-12 23:04:30 +00:00
|
|
|
gint res;
|
|
|
|
GstFlowReturn ret;
|
|
|
|
|
|
|
|
ctx = ffmpegenc->context;
|
|
|
|
|
2010-10-05 17:22:28 +00:00
|
|
|
/* We need to provide at least ffmpegs minimal buffer size */
|
|
|
|
outbuf = gst_buffer_new_and_alloc (max_size + FF_MIN_BUFFER_SIZE);
|
2009-05-12 23:04:30 +00:00
|
|
|
audio_out = GST_BUFFER_DATA (outbuf);
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (ffmpegenc, "encoding buffer of max size %d", max_size);
|
2009-10-01 14:44:22 +00:00
|
|
|
if (ffmpegenc->buffer_size != max_size)
|
|
|
|
ffmpegenc->buffer_size = max_size;
|
2009-05-12 23:04:30 +00:00
|
|
|
|
2010-10-05 17:22:28 +00:00
|
|
|
res = avcodec_encode_audio (ctx, audio_out, in_size, (short *) audio_in);
|
2009-05-12 23:04:30 +00:00
|
|
|
|
|
|
|
if (res < 0) {
|
|
|
|
GST_ERROR_OBJECT (ffmpegenc, "Failed to encode buffer: %d", res);
|
|
|
|
gst_buffer_unref (outbuf);
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
GST_LOG_OBJECT (ffmpegenc, "got output size %d", res);
|
|
|
|
|
|
|
|
GST_BUFFER_SIZE (outbuf) = res;
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
|
|
|
|
GST_BUFFER_DURATION (outbuf) = duration;
|
|
|
|
if (discont)
|
|
|
|
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
|
|
|
|
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (ffmpegenc->srcpad));
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (ffmpegenc, "pushing size %d, timestamp %" GST_TIME_FORMAT,
|
|
|
|
res, GST_TIME_ARGS (timestamp));
|
|
|
|
|
|
|
|
ret = gst_pad_push (ffmpegenc->srcpad, outbuf);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_ffmpegenc_chain_audio (GstPad * pad, GstBuffer * inbuf)
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
{
|
2009-05-12 23:04:30 +00:00
|
|
|
GstFFMpegEnc *ffmpegenc;
|
|
|
|
GstFFMpegEncClass *oclass;
|
|
|
|
AVCodecContext *ctx;
|
|
|
|
GstClockTime timestamp, duration;
|
|
|
|
guint size, frame_size;
|
|
|
|
gint osize;
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
GstFlowReturn ret;
|
2009-05-12 23:04:30 +00:00
|
|
|
gint out_size;
|
|
|
|
gboolean discont;
|
2009-05-13 21:18:50 +00:00
|
|
|
guint8 *in_data;
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
|
2009-05-12 23:04:30 +00:00
|
|
|
ffmpegenc = (GstFFMpegEnc *) (GST_OBJECT_PARENT (pad));
|
|
|
|
oclass = (GstFFMpegEncClass *) G_OBJECT_GET_CLASS (ffmpegenc);
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
|
2009-05-12 23:04:30 +00:00
|
|
|
ctx = ffmpegenc->context;
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
|
2009-05-12 23:04:30 +00:00
|
|
|
size = GST_BUFFER_SIZE (inbuf);
|
|
|
|
timestamp = GST_BUFFER_TIMESTAMP (inbuf);
|
|
|
|
duration = GST_BUFFER_DURATION (inbuf);
|
|
|
|
discont = GST_BUFFER_IS_DISCONT (inbuf);
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
|
ext/: Update to ffmpeg snapshot of Jul 20 2005 4:00 PM GMT. Mostly some added codecs, some API changes, etc. Also add...
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.h:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_formatid_get_codecids),
(gst_ffmpeg_caps_to_codecid), (gst_ffmpeg_get_codecid_longname),
(gst_ffmpeg_img_convert):
* ext/ffmpeg/gstffmpegcodecmap.h:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_chain),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegdeinterlace.c:
(gst_ffmpegdeinterlace_getcaps), (gst_ffmpegdeinterlace_pad_link):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_link), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_write):
* ext/ffmpeg/gstffmpegscale.c: (gst_ffmpegscale_pad_link):
* ext/libpostproc/gstpostproc.c: (gst_postproc_chain):
Update to ffmpeg snapshot of Jul 20 2005 4:00 PM GMT. Mostly
some added codecs, some API changes, etc. Also adds a VOB muxer
for MPEG-2 video and adds h264 to .mp4 muxing.
2005-07-20 15:40:57 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegenc,
|
2009-05-12 23:04:30 +00:00
|
|
|
"Received time %" GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT
|
|
|
|
", size %d", GST_TIME_ARGS (timestamp), GST_TIME_ARGS (duration), size);
|
|
|
|
|
|
|
|
frame_size = ctx->frame_size;
|
|
|
|
osize = av_get_bits_per_sample_format (ctx->sample_fmt) / 8;
|
|
|
|
|
|
|
|
if (frame_size > 1) {
|
|
|
|
/* we have a frame_size, feed the encoder multiples of this frame size */
|
|
|
|
guint avail, frame_bytes;
|
|
|
|
|
|
|
|
if (discont) {
|
|
|
|
GST_LOG_OBJECT (ffmpegenc, "DISCONT, clear adapter");
|
|
|
|
gst_adapter_clear (ffmpegenc->adapter);
|
|
|
|
ffmpegenc->discont = TRUE;
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
}
|
|
|
|
|
2009-05-12 23:04:30 +00:00
|
|
|
if (gst_adapter_available (ffmpegenc->adapter) == 0) {
|
|
|
|
/* lock on to new timestamp */
|
|
|
|
GST_LOG_OBJECT (ffmpegenc, "taking buffer timestamp %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (timestamp));
|
|
|
|
ffmpegenc->adapter_ts = timestamp;
|
|
|
|
ffmpegenc->adapter_consumed = 0;
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
} else {
|
2009-12-14 20:20:53 +00:00
|
|
|
GstClockTime upstream_time;
|
2010-07-02 21:38:06 +00:00
|
|
|
GstClockTime consumed_time;
|
2009-12-14 20:20:53 +00:00
|
|
|
guint64 bytes;
|
|
|
|
|
2009-05-12 23:04:30 +00:00
|
|
|
/* use timestamp at head of the adapter */
|
2010-07-02 21:38:06 +00:00
|
|
|
consumed_time =
|
2009-05-12 23:04:30 +00:00
|
|
|
gst_util_uint64_scale (ffmpegenc->adapter_consumed, GST_SECOND,
|
|
|
|
ctx->sample_rate);
|
2010-07-02 21:38:06 +00:00
|
|
|
timestamp = ffmpegenc->adapter_ts + consumed_time;
|
|
|
|
GST_LOG_OBJECT (ffmpegenc, "taking adapter timestamp %" GST_TIME_FORMAT
|
|
|
|
" and adding consumed time %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (ffmpegenc->adapter_ts), GST_TIME_ARGS (consumed_time));
|
|
|
|
|
2009-12-14 20:20:53 +00:00
|
|
|
/* check with upstream timestamps, if too much deviation,
|
|
|
|
* forego some timestamp perfection in favour of upstream syncing
|
|
|
|
* (particularly in case these do not happen to come in multiple
|
|
|
|
* of frame size) */
|
|
|
|
upstream_time = gst_adapter_prev_timestamp (ffmpegenc->adapter, &bytes);
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (upstream_time)) {
|
|
|
|
GstClockTimeDiff diff;
|
|
|
|
|
|
|
|
upstream_time +=
|
2010-07-02 21:38:06 +00:00
|
|
|
gst_util_uint64_scale (bytes, GST_SECOND,
|
|
|
|
ctx->sample_rate * osize * ctx->channels);
|
2009-12-14 20:20:53 +00:00
|
|
|
diff = upstream_time - timestamp;
|
|
|
|
/* relaxed difference, rather than half a sample or so ... */
|
|
|
|
if (diff > GST_SECOND / 10 || diff < -GST_SECOND / 10) {
|
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "adapter timestamp drifting, "
|
|
|
|
"taking upstream timestamp %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (upstream_time));
|
|
|
|
timestamp = upstream_time;
|
2010-07-05 08:32:42 +00:00
|
|
|
/* samples corresponding to bytes */
|
|
|
|
ffmpegenc->adapter_consumed = bytes / (osize * ctx->channels);
|
2009-12-14 20:20:53 +00:00
|
|
|
ffmpegenc->adapter_ts = upstream_time -
|
2010-07-05 08:32:42 +00:00
|
|
|
gst_util_uint64_scale (ffmpegenc->adapter_consumed, GST_SECOND,
|
|
|
|
ctx->sample_rate);
|
2009-12-14 20:20:53 +00:00
|
|
|
ffmpegenc->discont = TRUE;
|
|
|
|
}
|
|
|
|
}
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
}
|
|
|
|
|
2009-05-12 23:04:30 +00:00
|
|
|
GST_LOG_OBJECT (ffmpegenc, "pushing buffer in adapter");
|
|
|
|
gst_adapter_push (ffmpegenc->adapter, inbuf);
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
|
2009-05-12 23:04:30 +00:00
|
|
|
/* first see how many bytes we need to feed to the decoder. */
|
|
|
|
frame_bytes = frame_size * osize * ctx->channels;
|
|
|
|
avail = gst_adapter_available (ffmpegenc->adapter);
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
|
2009-05-12 23:04:30 +00:00
|
|
|
GST_LOG_OBJECT (ffmpegenc, "frame_bytes %u, avail %u", frame_bytes, avail);
|
|
|
|
|
|
|
|
/* while there is more than a frame size in the adapter, consume it */
|
|
|
|
while (avail >= frame_bytes) {
|
|
|
|
GST_LOG_OBJECT (ffmpegenc, "taking %u bytes from the adapter",
|
|
|
|
frame_bytes);
|
|
|
|
|
2010-07-02 21:38:06 +00:00
|
|
|
/* Note that we take frame_bytes and add frame_size.
|
|
|
|
* Makes sense when resyncing because you don't have to count channels
|
|
|
|
* or samplesize to divide by the samplerate */
|
|
|
|
|
2009-05-12 23:04:30 +00:00
|
|
|
/* take an audio buffer out of the adapter */
|
2009-05-13 21:18:50 +00:00
|
|
|
in_data = (guint8 *) gst_adapter_peek (ffmpegenc->adapter, frame_bytes);
|
2009-05-12 23:04:30 +00:00
|
|
|
ffmpegenc->adapter_consumed += frame_size;
|
|
|
|
|
|
|
|
/* calculate timestamp and duration relative to start of adapter and to
|
|
|
|
* the amount of samples we consumed */
|
|
|
|
duration =
|
|
|
|
gst_util_uint64_scale (ffmpegenc->adapter_consumed, GST_SECOND,
|
|
|
|
ctx->sample_rate);
|
|
|
|
duration -= (timestamp - ffmpegenc->adapter_ts);
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
|
2010-10-05 17:22:28 +00:00
|
|
|
/* 4 times the input size should be big enough... */
|
|
|
|
out_size = frame_bytes * 4;
|
2009-05-12 23:04:30 +00:00
|
|
|
|
2010-10-05 17:22:28 +00:00
|
|
|
ret =
|
|
|
|
gst_ffmpegenc_encode_audio (ffmpegenc, in_data, frame_bytes, out_size,
|
2009-05-13 21:18:50 +00:00
|
|
|
timestamp, duration, ffmpegenc->discont);
|
|
|
|
|
|
|
|
gst_adapter_flush (ffmpegenc->adapter, frame_bytes);
|
|
|
|
|
2009-05-12 23:04:30 +00:00
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto push_failed;
|
|
|
|
|
2009-05-13 21:18:50 +00:00
|
|
|
/* advance the adapter timestamp with the duration */
|
|
|
|
timestamp += duration;
|
|
|
|
|
2009-05-12 23:04:30 +00:00
|
|
|
ffmpegenc->discont = FALSE;
|
|
|
|
avail = gst_adapter_available (ffmpegenc->adapter);
|
2009-04-23 17:35:10 +00:00
|
|
|
}
|
2009-05-12 23:04:30 +00:00
|
|
|
GST_LOG_OBJECT (ffmpegenc, "%u bytes left in the adapter", avail);
|
|
|
|
} else {
|
|
|
|
/* we have no frame_size, feed the encoder all the data and expect a fixed
|
|
|
|
* output size */
|
2010-10-05 17:22:28 +00:00
|
|
|
int coded_bps = av_get_bits_per_sample (oclass->in_plugin->id);
|
2009-05-12 23:04:30 +00:00
|
|
|
|
|
|
|
GST_LOG_OBJECT (ffmpegenc, "coded bps %d, osize %d", coded_bps, osize);
|
|
|
|
|
|
|
|
out_size = size / osize;
|
|
|
|
if (coded_bps)
|
2010-10-05 17:22:28 +00:00
|
|
|
out_size = (out_size * coded_bps) / 8;
|
2009-10-01 14:44:22 +00:00
|
|
|
|
2009-05-13 21:18:50 +00:00
|
|
|
in_data = (guint8 *) GST_BUFFER_DATA (inbuf);
|
2010-10-05 17:22:28 +00:00
|
|
|
ret = gst_ffmpegenc_encode_audio (ffmpegenc, in_data, size, out_size,
|
2009-05-13 21:18:50 +00:00
|
|
|
timestamp, duration, discont);
|
|
|
|
gst_buffer_unref (inbuf);
|
|
|
|
|
2009-05-12 23:04:30 +00:00
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto push_failed;
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
}
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
|
2009-05-12 23:04:30 +00:00
|
|
|
return GST_FLOW_OK;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
push_failed:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "Failed to push buffer %d (%s)", ret,
|
|
|
|
gst_flow_get_name (ret));
|
|
|
|
return ret;
|
|
|
|
}
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
}
|
|
|
|
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
static void
|
|
|
|
gst_ffmpegenc_flush_buffers (GstFFMpegEnc * ffmpegenc, gboolean send)
|
|
|
|
{
|
|
|
|
GstBuffer *outbuf, *inbuf;
|
|
|
|
gint ret_size;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (ffmpegenc, "flushing buffers with sending %d", send);
|
|
|
|
|
|
|
|
/* no need to empty codec if there is none */
|
|
|
|
if (!ffmpegenc->opened)
|
|
|
|
goto flush;
|
|
|
|
|
|
|
|
while (!g_queue_is_empty (ffmpegenc->delay)) {
|
|
|
|
|
2007-06-22 12:13:18 +00:00
|
|
|
ffmpegenc_setup_working_buf (ffmpegenc);
|
2007-08-01 17:43:39 +00:00
|
|
|
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
ret_size = avcodec_encode_video (ffmpegenc->context,
|
ext/ffmpeg/: gst-indent cleanup.
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (gst_ffmpeg_avcodec_open),
(gst_ffmpeg_avcodec_close), (gst_ffmpeg_av_find_stream_info),
(gst_ffmpeg_log_callback), (plugin_init):
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context), (gst_ffmpeg_cfg_finalize):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_save_incoming_values),
(gst_ffmpegdec_get_best_values), (gst_ffmpegdec_video_frame):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_src_query):
* ext/ffmpeg/gstffmpegenc.c: (ffmpegenc_setup_working_buf),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_flush_buffers):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
gst-indent cleanup.
2007-11-03 16:14:53 +00:00
|
|
|
ffmpegenc->working_buf, ffmpegenc->working_buf_size, NULL);
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
|
|
|
|
if (ret_size < 0) { /* there should be something, notify and give up */
|
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
|
|
|
GstFFMpegEncClass *oclass =
|
|
|
|
(GstFFMpegEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc));
|
|
|
|
GST_WARNING_OBJECT (ffmpegenc,
|
|
|
|
"ffenc_%s: failed to flush buffer", oclass->in_plugin->name);
|
|
|
|
#endif /* GST_DISABLE_GST_DEBUG */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* save stats info if there is some as well as a stats file */
|
|
|
|
if (ffmpegenc->file && ffmpegenc->context->stats_out)
|
|
|
|
if (fprintf (ffmpegenc->file, "%s", ffmpegenc->context->stats_out) < 0)
|
|
|
|
GST_ELEMENT_ERROR (ffmpegenc, RESOURCE, WRITE,
|
|
|
|
(("Could not write to file \"%s\"."), ffmpegenc->filename),
|
|
|
|
GST_ERROR_SYSTEM);
|
|
|
|
|
|
|
|
/* handle b-frame delay when no output, so we don't output empty frames */
|
|
|
|
inbuf = g_queue_pop_head (ffmpegenc->delay);
|
|
|
|
|
2007-06-22 12:13:18 +00:00
|
|
|
outbuf = gst_buffer_new_and_alloc (ret_size);
|
2007-07-05 11:19:21 +00:00
|
|
|
memcpy (GST_BUFFER_DATA (outbuf), ffmpegenc->working_buf, ret_size);
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (inbuf);
|
|
|
|
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (inbuf);
|
2007-06-22 12:13:18 +00:00
|
|
|
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
if (!ffmpegenc->context->coded_frame->key_frame)
|
|
|
|
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
|
|
|
|
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (ffmpegenc->srcpad));
|
|
|
|
|
|
|
|
gst_buffer_unref (inbuf);
|
|
|
|
|
|
|
|
if (send)
|
|
|
|
gst_pad_push (ffmpegenc->srcpad, outbuf);
|
|
|
|
else
|
|
|
|
gst_buffer_unref (outbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
flush:
|
|
|
|
{
|
|
|
|
/* make sure that we empty the queue, is still needed if we had to break */
|
|
|
|
while (!g_queue_is_empty (ffmpegenc->delay))
|
|
|
|
gst_buffer_unref (g_queue_pop_head (ffmpegenc->delay));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_ffmpegenc_event_video (GstPad * pad, GstEvent * event)
|
|
|
|
{
|
|
|
|
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) (GST_PAD_PARENT (pad));
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_EOS:
|
|
|
|
gst_ffmpegenc_flush_buffers (ffmpegenc, TRUE);
|
|
|
|
break;
|
|
|
|
/* no flushing if flush received,
|
|
|
|
* buffers in encoder are considered (in the) past */
|
2009-03-25 11:51:55 +00:00
|
|
|
|
|
|
|
case GST_EVENT_CUSTOM_DOWNSTREAM:{
|
|
|
|
const GstStructure *s;
|
|
|
|
s = gst_event_get_structure (event);
|
|
|
|
if (gst_structure_has_name (s, "GstForceKeyUnit")) {
|
|
|
|
ffmpegenc->picture->pict_type = FF_I_TYPE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return gst_pad_push_event (ffmpegenc->srcpad, event);
|
|
|
|
}
|
|
|
|
|
2009-03-25 11:51:55 +00:00
|
|
|
static gboolean
|
|
|
|
gst_ffmpegenc_event_src (GstPad * pad, GstEvent * event)
|
|
|
|
{
|
|
|
|
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) (GST_PAD_PARENT (pad));
|
2009-11-21 02:46:33 +00:00
|
|
|
gboolean forward = TRUE;
|
2009-03-25 11:51:55 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_CUSTOM_UPSTREAM:{
|
|
|
|
const GstStructure *s;
|
|
|
|
s = gst_event_get_structure (event);
|
|
|
|
if (gst_structure_has_name (s, "GstForceKeyUnit")) {
|
2009-11-21 02:46:33 +00:00
|
|
|
GST_OBJECT_LOCK (ffmpegenc);
|
|
|
|
ffmpegenc->force_keyframe = TRUE;
|
|
|
|
GST_OBJECT_UNLOCK (ffmpegenc);
|
|
|
|
forward = FALSE;
|
|
|
|
gst_event_unref (event);
|
2009-03-25 11:51:55 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-11-21 02:46:33 +00:00
|
|
|
if (forward)
|
|
|
|
return gst_pad_push_event (ffmpegenc->sinkpad, event);
|
|
|
|
else
|
|
|
|
return TRUE;
|
2009-03-25 11:51:55 +00:00
|
|
|
}
|
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
static void
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpegenc_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec)
|
2001-12-23 13:25:04 +00:00
|
|
|
{
|
|
|
|
GstFFMpegEnc *ffmpegenc;
|
|
|
|
|
|
|
|
/* Get a pointer of the right type. */
|
2004-03-29 16:39:18 +00:00
|
|
|
ffmpegenc = (GstFFMpegEnc *) (object);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2009-04-21 16:38:03 +00:00
|
|
|
if (ffmpegenc->opened) {
|
|
|
|
GST_WARNING_OBJECT (ffmpegenc,
|
|
|
|
"Can't change properties once decoder is setup !");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
/* Check the argument id to see which argument we're setting. */
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_BIT_RATE:
|
2003-06-07 20:46:24 +00:00
|
|
|
ffmpegenc->bitrate = g_value_get_ulong (value);
|
2001-12-23 13:25:04 +00:00
|
|
|
break;
|
|
|
|
case ARG_GOP_SIZE:
|
2003-06-07 20:46:24 +00:00
|
|
|
ffmpegenc->gop_size = g_value_get_int (value);
|
2001-12-23 13:25:04 +00:00
|
|
|
break;
|
|
|
|
case ARG_ME_METHOD:
|
2003-06-07 20:46:24 +00:00
|
|
|
ffmpegenc->me_method = g_value_get_enum (value);
|
|
|
|
break;
|
2009-10-08 11:52:22 +00:00
|
|
|
case ARG_BUFSIZE:
|
|
|
|
break;
|
2005-11-28 17:12:13 +00:00
|
|
|
case ARG_RTP_PAYLOAD_SIZE:
|
|
|
|
ffmpegenc->rtp_payload_size = g_value_get_ulong (value);
|
|
|
|
break;
|
2001-12-23 13:25:04 +00:00
|
|
|
default:
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
if (!gst_ffmpeg_cfg_set_property (object, value, pspec))
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2001-12-23 13:25:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The set function is simply the inverse of the get fuction. */
|
|
|
|
static void
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpegenc_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec)
|
2001-12-23 13:25:04 +00:00
|
|
|
{
|
|
|
|
GstFFMpegEnc *ffmpegenc;
|
|
|
|
|
|
|
|
/* It's not null if we got it, but it might not be ours */
|
2004-03-29 16:39:18 +00:00
|
|
|
ffmpegenc = (GstFFMpegEnc *) (object);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_BIT_RATE:
|
2003-06-07 20:46:24 +00:00
|
|
|
g_value_set_ulong (value, ffmpegenc->bitrate);
|
2001-12-23 13:25:04 +00:00
|
|
|
break;
|
|
|
|
case ARG_GOP_SIZE:
|
2003-06-07 20:46:24 +00:00
|
|
|
g_value_set_int (value, ffmpegenc->gop_size);
|
2001-12-23 13:25:04 +00:00
|
|
|
break;
|
|
|
|
case ARG_ME_METHOD:
|
2003-06-07 20:46:24 +00:00
|
|
|
g_value_set_enum (value, ffmpegenc->me_method);
|
|
|
|
break;
|
|
|
|
case ARG_BUFSIZE:
|
|
|
|
g_value_set_ulong (value, ffmpegenc->buffer_size);
|
2001-12-23 13:25:04 +00:00
|
|
|
break;
|
2005-11-28 17:12:13 +00:00
|
|
|
case ARG_RTP_PAYLOAD_SIZE:
|
|
|
|
g_value_set_ulong (value, ffmpegenc->rtp_payload_size);
|
|
|
|
break;
|
2001-12-23 13:25:04 +00:00
|
|
|
default:
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
if (!gst_ffmpeg_cfg_get_property (object, value, pspec))
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2001-12-23 13:25:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-05 14:06:29 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_ffmpegenc_change_state (GstElement * element, GstStateChange transition)
|
2003-06-07 20:46:24 +00:00
|
|
|
{
|
|
|
|
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) element;
|
2005-09-05 14:06:29 +00:00
|
|
|
GstStateChangeReturn result;
|
2005-08-19 15:23:39 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-09-05 14:06:29 +00:00
|
|
|
result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
2003-06-07 20:46:24 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
2005-09-05 14:06:29 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
gst_ffmpegenc_flush_buffers (ffmpegenc, FALSE);
|
2003-06-07 20:46:24 +00:00
|
|
|
if (ffmpegenc->opened) {
|
2005-12-16 16:23:05 +00:00
|
|
|
gst_ffmpeg_avcodec_close (ffmpegenc->context);
|
2003-06-07 20:46:24 +00:00
|
|
|
ffmpegenc->opened = FALSE;
|
|
|
|
}
|
2009-05-12 23:04:30 +00:00
|
|
|
gst_adapter_clear (ffmpegenc->adapter);
|
|
|
|
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
if (ffmpegenc->file) {
|
|
|
|
fclose (ffmpegenc->file);
|
|
|
|
ffmpegenc->file = NULL;
|
|
|
|
}
|
2007-06-22 12:13:18 +00:00
|
|
|
if (ffmpegenc->working_buf) {
|
|
|
|
g_free (ffmpegenc->working_buf);
|
|
|
|
ffmpegenc->working_buf = NULL;
|
|
|
|
}
|
2003-06-07 20:46:24 +00:00
|
|
|
break;
|
2005-08-19 15:23:39 +00:00
|
|
|
default:
|
|
|
|
break;
|
2003-06-07 20:46:24 +00:00
|
|
|
}
|
2005-08-19 15:23:39 +00:00
|
|
|
return result;
|
2003-06-07 20:46:24 +00:00
|
|
|
}
|
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
gboolean
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpegenc_register (GstPlugin * plugin)
|
2001-12-23 13:25:04 +00:00
|
|
|
{
|
|
|
|
GTypeInfo typeinfo = {
|
2004-03-29 16:39:18 +00:00
|
|
|
sizeof (GstFFMpegEncClass),
|
|
|
|
(GBaseInitFunc) gst_ffmpegenc_base_init,
|
2001-12-23 13:25:04 +00:00
|
|
|
NULL,
|
2004-03-29 16:39:18 +00:00
|
|
|
(GClassInitFunc) gst_ffmpegenc_class_init,
|
2001-12-23 13:25:04 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-29 16:39:18 +00:00
|
|
|
sizeof (GstFFMpegEnc),
|
2001-12-23 13:25:04 +00:00
|
|
|
0,
|
2004-03-29 16:39:18 +00:00
|
|
|
(GInstanceInitFunc) gst_ffmpegenc_init,
|
2001-12-23 13:25:04 +00:00
|
|
|
};
|
|
|
|
GType type;
|
|
|
|
AVCodec *in_plugin;
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2007-12-17 12:43:06 +00:00
|
|
|
GST_LOG ("Registering encoders");
|
|
|
|
|
ext/ffmpeg/: Added helper object to handle extra properties.
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_pass_get_type),
(gst_ffmpeg_lim_pass_get_type), (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_mb_cmp_get_type), (gst_ffmpeg_dct_algo_get_type),
(gst_ffmpeg_idct_algo_get_type), (gst_ffmpeg_quant_type_get_type),
(gst_ffmpeg_pre_me_get_type), (gst_ffmpeg_pred_method_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context):
* ext/ffmpeg/gstffmpegcfg.h:
Added helper object to handle extra properties.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_dispose),
(gst_ffmpegenc_getcaps), (gst_ffmpegenc_setcaps),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_chain_audio),
(gst_ffmpegenc_flush_buffers), (gst_ffmpegenc_event_video),
(gst_ffmpegenc_set_property), (gst_ffmpegenc_get_property),
(gst_ffmpegenc_change_state), (gst_ffmpegenc_register):
* ext/ffmpeg/gstffmpegenc.h:
Exposes (quite some of) the AVCodecContext configurable
settings, as well as some additional (though simple) logic for b-frame
delay handling.
Most of the properties are only enabled for mpeg4-like codecs.
Fixes #344583.
2006-09-06 14:51:13 +00:00
|
|
|
/* build global ffmpeg param/property info */
|
|
|
|
gst_ffmpeg_cfg_init ();
|
|
|
|
|
2008-10-30 12:05:45 +00:00
|
|
|
in_plugin = av_codec_next (NULL);
|
2001-12-23 13:25:04 +00:00
|
|
|
while (in_plugin) {
|
|
|
|
gchar *type_name;
|
|
|
|
|
2003-06-17 11:44:38 +00:00
|
|
|
/* no quasi codecs, please */
|
|
|
|
if (in_plugin->id == CODEC_ID_RAWVIDEO ||
|
2010-05-31 16:44:02 +00:00
|
|
|
in_plugin->id == CODEC_ID_V210 ||
|
|
|
|
in_plugin->id == CODEC_ID_V210X ||
|
|
|
|
in_plugin->id == CODEC_ID_R210 ||
|
2004-10-25 11:56:52 +00:00
|
|
|
in_plugin->id == CODEC_ID_ZLIB ||
|
2004-03-29 16:39:18 +00:00
|
|
|
(in_plugin->id >= CODEC_ID_PCM_S16LE &&
|
2010-05-31 16:44:02 +00:00
|
|
|
in_plugin->id <= CODEC_ID_PCM_BLURAY)) {
|
2003-06-17 11:44:38 +00:00
|
|
|
goto next;
|
2009-03-10 20:11:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* No encoders depending on external libraries (we don't build them, but
|
|
|
|
* people who build against an external ffmpeg might have them.
|
|
|
|
* We have native gstreamer plugins for all of those libraries anyway. */
|
|
|
|
if (!strncmp (in_plugin->name, "lib", 3)) {
|
|
|
|
GST_DEBUG
|
|
|
|
("Not using external library encoder %s. Use the gstreamer-native ones instead.",
|
|
|
|
in_plugin->name);
|
|
|
|
goto next;
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
2003-06-17 11:44:38 +00:00
|
|
|
|
|
|
|
/* only encoders */
|
|
|
|
if (!in_plugin->encode) {
|
2001-12-23 13:25:04 +00:00
|
|
|
goto next;
|
|
|
|
}
|
2003-06-07 20:46:24 +00:00
|
|
|
|
2009-11-02 07:43:17 +00:00
|
|
|
/* FIXME : We should have a method to know cheaply whether we have a mapping
|
|
|
|
* for the given plugin or not */
|
|
|
|
|
2008-10-30 12:05:45 +00:00
|
|
|
GST_DEBUG ("Trying plugin %s [%s]", in_plugin->name, in_plugin->long_name);
|
2008-06-13 17:06:55 +00:00
|
|
|
|
2007-12-17 12:43:06 +00:00
|
|
|
/* no codecs for which we're GUARANTEED to have better alternatives */
|
|
|
|
if (!strcmp (in_plugin->name, "vorbis") ||
|
|
|
|
!strcmp (in_plugin->name, "gif") || !strcmp (in_plugin->name, "flac")) {
|
|
|
|
GST_LOG ("Ignoring encoder %s", in_plugin->name);
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
|
2002-03-19 04:09:41 +00:00
|
|
|
/* construct the type */
|
2004-03-29 16:39:18 +00:00
|
|
|
type_name = g_strdup_printf ("ffenc_%s", in_plugin->name);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2009-06-05 11:19:03 +00:00
|
|
|
type = g_type_from_name (type_name);
|
|
|
|
|
|
|
|
if (!type) {
|
|
|
|
|
|
|
|
/* create the glib type now */
|
|
|
|
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
|
2009-11-02 07:43:17 +00:00
|
|
|
g_type_set_qdata (type, GST_FFENC_PARAMS_QDATA, (gpointer) in_plugin);
|
2009-06-05 11:19:03 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
static const GInterfaceInfo preset_info = {
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
g_type_add_interface_static (type, GST_TYPE_PRESET, &preset_info);
|
|
|
|
}
|
2009-05-04 11:00:49 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 16:36:48 +00:00
|
|
|
if (!gst_element_register (plugin, type_name, GST_RANK_SECONDARY, type)) {
|
2004-02-02 20:27:13 +00:00
|
|
|
g_free (type_name);
|
2003-11-02 19:07:41 +00:00
|
|
|
return FALSE;
|
2004-02-02 20:27:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (type_name);
|
2003-11-02 19:07:41 +00:00
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
next:
|
2008-10-30 12:05:45 +00:00
|
|
|
in_plugin = av_codec_next (in_plugin);
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
|
|
|
|
2007-12-17 12:43:06 +00:00
|
|
|
GST_LOG ("Finished registering encoders");
|
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|