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>
|
|
|
|
|
2002-11-26 14:50:05 +00:00
|
|
|
#ifdef HAVE_FFMPEG_UNINSTALLED
|
|
|
|
#include <avcodec.h>
|
|
|
|
#else
|
|
|
|
#include <ffmpeg/avcodec.h>
|
|
|
|
#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"
|
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
typedef struct _GstFFMpegEnc GstFFMpegEnc;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
struct _GstFFMpegEnc
|
|
|
|
{
|
2002-11-06 23:53:46 +00:00
|
|
|
GstElement element;
|
|
|
|
|
|
|
|
/* We need to keep track of our pads, so we do so here. */
|
|
|
|
GstPad *srcpad;
|
|
|
|
GstPad *sinkpad;
|
|
|
|
|
|
|
|
AVCodecContext *context;
|
2003-06-07 20:46:24 +00:00
|
|
|
AVFrame *picture;
|
|
|
|
gboolean opened;
|
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
|
|
|
GstBuffer *cache;
|
2003-06-07 20:46:24 +00:00
|
|
|
|
|
|
|
/* cache */
|
|
|
|
gulong bitrate;
|
|
|
|
gint me_method;
|
|
|
|
gint gop_size;
|
|
|
|
gulong buffer_size;
|
2005-11-28 17:12:13 +00:00
|
|
|
gulong rtp_payload_size;
|
2002-11-06 23:53:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _GstFFMpegEncClass GstFFMpegEncClass;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
struct _GstFFMpegEncClass
|
|
|
|
{
|
2002-11-06 23:53:46 +00:00
|
|
|
GstElementClass parent_class;
|
|
|
|
|
|
|
|
AVCodec *in_plugin;
|
2003-06-07 20:46:24 +00:00
|
|
|
GstPadTemplate *srctempl, *sinktempl;
|
2004-12-17 11:32:45 +00:00
|
|
|
GstCaps *sinkcaps;
|
2002-11-06 23:53:46 +00:00
|
|
|
};
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2003-06-07 20:46:24 +00:00
|
|
|
AVCodec *in_plugin;
|
2003-11-02 13:12:14 +00:00
|
|
|
GstCaps *srccaps, *sinkcaps;
|
2003-06-07 20:46:24 +00:00
|
|
|
} GstFFMpegEncClassParams;
|
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
#define GST_TYPE_FFMPEGENC \
|
|
|
|
(gst_ffmpegenc_get_type())
|
|
|
|
#define GST_FFMPEGENC(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGENC,GstFFMpegEnc))
|
|
|
|
#define GST_FFMPEGENC_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGENC,GstFFMpegEncClass))
|
|
|
|
#define GST_IS_FFMPEGENC(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGENC))
|
|
|
|
#define GST_IS_FFMPEGENC_CLASS(obj) \
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGENC))
|
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,
|
|
|
|
ARG_RTP_PAYLOAD_SIZE
|
|
|
|
/* FILL ME */
|
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[] = {
|
2004-03-29 16:39:18 +00:00
|
|
|
{ME_ZERO, "0", "zero"},
|
|
|
|
{ME_FULL, "1", "full"},
|
|
|
|
{ME_LOG, "2", "logarithmic"},
|
|
|
|
{ME_PHODS, "3", "phods"},
|
|
|
|
{ME_EPZS, "4", "epzs"},
|
|
|
|
{ME_X1, "5", "x1"},
|
|
|
|
{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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GHashTable *enc_global_plugins;
|
|
|
|
|
|
|
|
/* A number of functon 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);
|
|
|
|
static void gst_ffmpegenc_dispose (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);
|
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
|
|
|
static GstFlowReturn gst_ffmpegenc_chain_video (GstPad * pad, GstBuffer *buffer);
|
|
|
|
static GstFlowReturn gst_ffmpegenc_chain_audio (GstPad * pad, GstBuffer *buffer);
|
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
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
GstFFMpegEncClassParams *params;
|
2004-02-11 08:38:26 +00:00
|
|
|
GstElementDetails details;
|
2003-11-02 13:12:14 +00:00
|
|
|
GstPadTemplate *srctempl, *sinktempl;
|
|
|
|
|
|
|
|
params = g_hash_table_lookup (enc_global_plugins,
|
2004-03-29 16:39:18 +00:00
|
|
|
GINT_TO_POINTER (G_OBJECT_CLASS_TYPE (gobject_class)));
|
2003-11-02 19:07:41 +00:00
|
|
|
/* HACK: if we don't have a GType yet, our params are stored at position 0 */
|
|
|
|
if (!params) {
|
2004-03-29 16:39:18 +00:00
|
|
|
params = g_hash_table_lookup (enc_global_plugins, GINT_TO_POINTER (0));
|
2003-11-02 19:07:41 +00:00
|
|
|
}
|
|
|
|
g_assert (params);
|
2003-11-02 13:12:14 +00:00
|
|
|
|
|
|
|
/* construct the element details struct */
|
2004-03-29 16:39:18 +00:00
|
|
|
details.longname = g_strdup_printf ("FFMPEG %s encoder",
|
2004-10-24 22:24:43 +00:00
|
|
|
gst_ffmpeg_get_codecid_longname (params->in_plugin->id));
|
2004-07-08 14:01:28 +00:00
|
|
|
details.klass = g_strdup_printf ("Codec/Encoder/%s",
|
2004-03-29 16:39:18 +00:00
|
|
|
(params->in_plugin->type == CODEC_TYPE_VIDEO) ? "Video" : "Audio");
|
|
|
|
details.description = g_strdup_printf ("FFMPEG %s encoder",
|
|
|
|
params->in_plugin->name);
|
2004-02-11 08:38:26 +00:00
|
|
|
details.author = "Wim Taymans <wim.taymans@chello.be>, "
|
2004-03-29 16:39:18 +00:00
|
|
|
"Ronald Bultje <rbultje@ronald.bitfreak.net>";
|
2004-02-11 08:38:26 +00:00
|
|
|
gst_element_class_set_details (element_class, &details);
|
|
|
|
g_free (details.longname);
|
|
|
|
g_free (details.klass);
|
|
|
|
g_free (details.description);
|
2003-11-02 13:12:14 +00:00
|
|
|
|
|
|
|
/* pad templates */
|
|
|
|
sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
|
2004-03-29 16:39:18 +00:00
|
|
|
GST_PAD_ALWAYS, params->sinkcaps);
|
2003-11-02 13:12:14 +00:00
|
|
|
srctempl = gst_pad_template_new ("src", GST_PAD_SRC,
|
2004-03-29 16:39:18 +00:00
|
|
|
GST_PAD_ALWAYS, params->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);
|
|
|
|
|
|
|
|
klass->in_plugin = params->in_plugin;
|
|
|
|
klass->srctempl = srctempl;
|
|
|
|
klass->sinktempl = sinktempl;
|
2004-12-17 11:32:45 +00:00
|
|
|
klass->sinkcaps = NULL;
|
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
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
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",
|
|
|
|
"Target Video Bitrate", 0, G_MAXULONG, 300000, G_PARAM_READWRITE));
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GOP_SIZE,
|
|
|
|
g_param_spec_int ("gop_size", "GOP Size",
|
|
|
|
"Number of frames within one GOP",
|
|
|
|
0, G_MAXINT, 15, G_PARAM_READWRITE));
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ME_METHOD,
|
|
|
|
g_param_spec_enum ("me_method", "ME Method",
|
|
|
|
"Motion Estimation Method",
|
|
|
|
GST_TYPE_ME_METHOD, ME_LOG, G_PARAM_READWRITE));
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFSIZE,
|
|
|
|
g_param_spec_ulong ("buffer_size", "Buffer Size",
|
|
|
|
"Size of the video buffers", 0, G_MAXULONG, 0, G_PARAM_READWRITE));
|
2005-11-28 17:12:13 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
|
|
ARG_RTP_PAYLOAD_SIZE,
|
2005-12-06 19:57:08 +00:00
|
|
|
g_param_spec_ulong ("rtp_payload_size", "RTP Payload Size",
|
2005-11-28 17:12:13 +00:00
|
|
|
"Target GOB length", 0, G_MAXULONG, 0, G_PARAM_READWRITE));
|
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",
|
|
|
|
"Target Audio Bitrate", 0, G_MAXULONG, 128000, G_PARAM_READWRITE));
|
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
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
gobject_class->dispose = gst_ffmpegenc_dispose;
|
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;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
ffmpegenc->bitrate = 300000;
|
|
|
|
ffmpegenc->buffer_size = 512 * 1024;
|
|
|
|
ffmpegenc->gop_size = 15;
|
2005-11-28 17:12:13 +00:00
|
|
|
ffmpegenc->rtp_payload_size = 0;
|
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);
|
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
ffmpegenc->bitrate = 128000;
|
|
|
|
}
|
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);
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpegenc_dispose (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
|
|
|
|
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
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
2003-06-07 20:46:24 +00:00
|
|
|
}
|
2001-12-23 13:25:04 +00:00
|
|
|
|
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);
|
|
|
|
AVCodecContext *ctx;
|
|
|
|
enum PixelFormat pixfmt;
|
|
|
|
GstCaps *caps = NULL;
|
|
|
|
|
|
|
|
/* audio needs no special care */
|
|
|
|
if (oclass->in_plugin->type == CODEC_TYPE_AUDIO) {
|
|
|
|
return gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cached */
|
|
|
|
if (oclass->sinkcaps) {
|
|
|
|
return gst_caps_copy (oclass->sinkcaps);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create cache etc. */
|
|
|
|
ctx = avcodec_alloc_context ();
|
|
|
|
if (!ctx) {
|
|
|
|
return gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set some default properties */
|
2005-11-28 17:12:13 +00:00
|
|
|
ctx->width = 352;
|
2004-12-17 11:32:45 +00:00
|
|
|
ctx->height = 288;
|
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
|
|
|
ctx->time_base.num = DEFAULT_FRAME_RATE_BASE;
|
|
|
|
ctx->time_base.den = 25 * DEFAULT_FRAME_RATE_BASE;
|
2004-12-17 11:32:45 +00:00
|
|
|
ctx->bit_rate = 350 * 1000;
|
|
|
|
/* makes it silent */
|
|
|
|
ctx->strict_std_compliance = -1;
|
|
|
|
|
2005-09-13 12:16:32 +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
|
2004-12-17 11:32:45 +00:00
|
|
|
for (pixfmt = 0; pixfmt < PIX_FMT_NB; pixfmt++) {
|
|
|
|
ctx->pix_fmt = pixfmt;
|
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 ();
|
|
|
|
gst_caps_append (caps,
|
|
|
|
gst_ffmpeg_codectype_to_caps (oclass->in_plugin->type, ctx));
|
2005-12-16 16:23:05 +00:00
|
|
|
gst_ffmpeg_avcodec_close (ctx);
|
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);
|
2004-12-17 11:32:45 +00:00
|
|
|
}
|
|
|
|
av_free (ctx);
|
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) {
|
|
|
|
return gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
|
|
|
}
|
|
|
|
|
|
|
|
oclass->sinkcaps = gst_caps_copy (caps);
|
|
|
|
|
|
|
|
return 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
|
|
|
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;
|
|
|
|
}
|
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;
|
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_mode = 1;
|
|
|
|
ffmpegenc->context->rtp_payload_size = ffmpegenc->rtp_payload_size;
|
|
|
|
} else {
|
|
|
|
ffmpegenc->context->rtp_mode = 0;
|
|
|
|
ffmpegenc->context->rtp_payload_size = 512;
|
|
|
|
}
|
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
/* general properties */
|
2005-09-22 12:55:30 +00:00
|
|
|
ffmpegenc->context->qmin = 1;
|
|
|
|
ffmpegenc->context->qmax = 31;
|
|
|
|
ffmpegenc->context->max_qdiff = 15;
|
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;
|
|
|
|
}
|
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
|
|
|
|
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);
|
2003-12-22 01:46:58 +00:00
|
|
|
GST_DEBUG ("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
|
|
|
}
|
|
|
|
|
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);
|
2003-12-22 01:46:58 +00:00
|
|
|
GST_DEBUG ("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
|
|
|
}
|
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 */
|
|
|
|
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,
|
2004-10-25 11:56:52 +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
|
|
|
}
|
|
|
|
|
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;
|
2004-03-29 16:39:18 +00:00
|
|
|
GstFFMpegEncClass *oclass =
|
|
|
|
(GstFFMpegEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc));
|
2005-03-12 23:59:15 +00:00
|
|
|
gint ret_size = 0, frame_size;
|
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)));
|
|
|
|
|
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 =
|
2005-07-27 16:03:51 +00:00
|
|
|
gst_ffmpeg_time_gst_to_ff (GST_BUFFER_TIMESTAMP (inbuf),
|
|
|
|
ffmpegenc->context->time_base);
|
2005-01-16 11:29:28 +00:00
|
|
|
|
2005-03-12 23:59:15 +00:00
|
|
|
outbuf = gst_buffer_new_and_alloc (ffmpegenc->buffer_size);
|
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,
|
2005-01-17 13:35:06 +00:00
|
|
|
GST_BUFFER_DATA (outbuf),
|
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_SIZE (outbuf), ffmpegenc->picture);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2003-06-07 21:06:05 +00:00
|
|
|
if (ret_size < 0) {
|
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);
|
2003-06-07 21:06:05 +00:00
|
|
|
gst_buffer_unref (inbuf);
|
2005-01-17 13:35:06 +00:00
|
|
|
gst_buffer_unref (outbuf);
|
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
|
|
|
}
|
|
|
|
|
2005-01-17 13:35:06 +00:00
|
|
|
GST_BUFFER_SIZE (outbuf) = ret_size;
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (inbuf);
|
|
|
|
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (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
|
|
|
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));
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2005-08-19 15:23:39 +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_pad_push (ffmpegenc->srcpad, outbuf);
|
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
|
|
|
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
|
|
|
{
|
|
|
|
GstBuffer *outbuf = NULL, *subbuf;
|
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_OBJECT_PARENT (pad));
|
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
|
|
|
gint size, ret_size = 0, in_size, frame_size;
|
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;
|
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
|
|
|
|
|
|
|
size = GST_BUFFER_SIZE (inbuf);
|
|
|
|
|
|
|
|
/* FIXME: events (discont (flush!) and eos (close down) etc.) */
|
|
|
|
|
|
|
|
frame_size = ffmpegenc->context->frame_size * 2 *
|
2004-03-29 16:39:18 +00:00
|
|
|
ffmpegenc->context->channels;
|
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
|
|
|
in_size = size;
|
|
|
|
if (ffmpegenc->cache)
|
|
|
|
in_size += GST_BUFFER_SIZE (ffmpegenc->cache);
|
|
|
|
|
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 " and size %d (cache: %d)",
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (inbuf)), size, in_size - size);
|
|
|
|
|
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
|
|
|
while (1) {
|
|
|
|
/* do we have enough data for one frame? */
|
|
|
|
if (in_size / (2 * ffmpegenc->context->channels) <
|
2004-03-29 16:39:18 +00:00
|
|
|
ffmpegenc->context->frame_size) {
|
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
|
|
|
if (in_size > size) {
|
|
|
|
/* this is panic! we got a buffer, but still don't have enough
|
|
|
|
* data. Merge them and retry in the next cycle... */
|
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
|
|
|
ffmpegenc->cache = gst_buffer_span (ffmpegenc->cache, 0, inbuf,
|
2005-12-06 19:57:08 +00:00
|
|
|
GST_BUFFER_SIZE (ffmpegenc->cache) + GST_BUFFER_SIZE (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
|
|
|
} else if (in_size == size) {
|
|
|
|
/* exactly the same! how wonderful */
|
|
|
|
ffmpegenc->cache = inbuf;
|
|
|
|
} else if (in_size > 0) {
|
|
|
|
ffmpegenc->cache = gst_buffer_create_sub (inbuf, size - in_size,
|
2004-03-29 16:39:18 +00:00
|
|
|
in_size);
|
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_BUFFER_DURATION (ffmpegenc->cache) =
|
2004-03-29 16:39:18 +00:00
|
|
|
GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (ffmpegenc->cache) /
|
|
|
|
size;
|
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_BUFFER_TIMESTAMP (ffmpegenc->cache) =
|
2004-03-29 16:39:18 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuf) +
|
|
|
|
(GST_BUFFER_DURATION (inbuf) * (size - in_size) / size);
|
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_buffer_unref (inbuf);
|
|
|
|
} else {
|
|
|
|
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;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/* create the frame */
|
|
|
|
if (in_size > size) {
|
|
|
|
/* merge */
|
|
|
|
subbuf = gst_buffer_create_sub (inbuf, 0, frame_size - (in_size - size));
|
|
|
|
GST_BUFFER_DURATION (subbuf) =
|
2004-03-29 16:39:18 +00:00
|
|
|
GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (subbuf) / size;
|
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
|
|
|
subbuf = gst_buffer_span (ffmpegenc->cache, 0, subbuf,
|
2005-12-06 19:57:08 +00:00
|
|
|
GST_BUFFER_SIZE (ffmpegenc->cache) + GST_BUFFER_SIZE (subbuf));
|
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
|
|
|
ffmpegenc->cache = NULL;
|
|
|
|
} else {
|
|
|
|
subbuf = gst_buffer_create_sub (inbuf, size - in_size, frame_size);
|
|
|
|
GST_BUFFER_DURATION (subbuf) =
|
2004-03-29 16:39:18 +00:00
|
|
|
GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (subbuf) / size;
|
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_BUFFER_TIMESTAMP (subbuf) =
|
2004-03-29 16:39:18 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuf) + (GST_BUFFER_DURATION (inbuf) *
|
|
|
|
(size - in_size) / size);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (inbuf));
|
|
|
|
ret_size = avcodec_encode_audio (ffmpegenc->context,
|
2004-03-29 16:39:18 +00:00
|
|
|
GST_BUFFER_DATA (outbuf),
|
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_SIZE (outbuf), (const short int *)
|
2004-03-29 16:39:18 +00:00
|
|
|
GST_BUFFER_DATA (subbuf));
|
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
|
|
|
|
|
|
|
if (ret_size < 0) {
|
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, "Failed to encode buffer");
|
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_buffer_unref (inbuf);
|
configure.ac: Fix configure check for mpeg2enc. We need 1.6.1.93 instead of 1.6.1.92, since the pkg-config file of 1....
Original commit message from CVS:
2004-01-01 Ronald Bultje <rbultje@ronald.bitfreak.net>
* configure.ac:
Fix configure check for mpeg2enc. We need 1.6.1.93 instead of
1.6.1.92, since the pkg-config file of 1.6.1.92 is borked and
it therefore uses the wrong include paths. Too bad... Note
that 1.6.1.93 is not release yet. ;).
Also add a check for mplex, which is now using the lib'ified
mplex from mjpegtools, too.
* ext/ffmpeg/gstffmpegcodecmap.c:
Add codec_tag for 3ivx/xvid. For xvid, this should fix playback
issues. I don't think ffmpeg handles 3ivx correctly, so this
probably won't work. But it won't hurt either.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect),
(gst_ffmpegenc_chain_audio):
Fix memleak in audio encoding. Close codec if open fails, this
calls the cleanup routines so we can re-use the context.
* ext/mpeg2enc/gstmpeg2enc.cc:
Fix pad template names/types, fix memory issue with getcaps().
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encoder.hh:
Fix compile issue with new caps system (const thingy).
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.hh:
We read a first frame right on initing, so that we have a caps
when we init the output. This caps is cached in padprivate and
read as first frame.
* ext/mplex/Makefile.am:
* ext/mplex/gstmplex.cc:
* ext/mplex/gstmplex.h:
* ext/mplex/gstmplex.hh:
* ext/mplex/gstmplexibitstream.cc:
* ext/mplex/gstmplexibitstream.hh:
* ext/mplex/gstmplexjob.cc:
* ext/mplex/gstmplexjob.hh:
* ext/mplex/gstmplexoutputstream.cc:
* ext/mplex/gstmplexoutputstream.hh:
We wrap mjpegtools mplex. So I rewrote the plugin. The old plugin
had issues, didn't do capsnego, supported only a subset of the
mplex features and required a mplex fork in our local CVS. Plus
that it worked agaist a very old mplex version. Rewriting was
faster than updating it.
* gst-libs/ext/Makefile.am:
* gst-libs/ext/mplex/INSTRUCT:
* gst-libs/ext/mplex/Makefile.am:
* gst-libs/ext/mplex/README:
* gst-libs/ext/mplex/TODO:
* gst-libs/ext/mplex/ac3strm_in.cc:
* gst-libs/ext/mplex/audiostrm.hh:
* gst-libs/ext/mplex/audiostrm_out.cc:
* gst-libs/ext/mplex/aunit.hh:
* gst-libs/ext/mplex/bits.cc:
* gst-libs/ext/mplex/bits.hh:
* gst-libs/ext/mplex/buffer.cc:
* gst-libs/ext/mplex/buffer.hh:
* gst-libs/ext/mplex/fastintfns.h:
* gst-libs/ext/mplex/format_codes.h:
* gst-libs/ext/mplex/inputstrm.cc:
* gst-libs/ext/mplex/inputstrm.hh:
* gst-libs/ext/mplex/lpcmstrm_in.cc:
* gst-libs/ext/mplex/mjpeg_logging.cc:
* gst-libs/ext/mplex/mjpeg_logging.h:
* gst-libs/ext/mplex/mjpeg_types.h:
* gst-libs/ext/mplex/mpastrm_in.cc:
* gst-libs/ext/mplex/mpegconsts.cc:
* gst-libs/ext/mplex/mpegconsts.h:
* gst-libs/ext/mplex/mplexconsts.hh:
* gst-libs/ext/mplex/multplex.cc:
* gst-libs/ext/mplex/outputstream.hh:
* gst-libs/ext/mplex/padstrm.cc:
* gst-libs/ext/mplex/padstrm.hh:
* gst-libs/ext/mplex/stillsstream.cc:
* gst-libs/ext/mplex/stillsstream.hh:
* gst-libs/ext/mplex/systems.cc:
* gst-libs/ext/mplex/systems.hh:
* gst-libs/ext/mplex/vector.cc:
* gst-libs/ext/mplex/vector.hh:
* gst-libs/ext/mplex/videostrm.hh:
* gst-libs/ext/mplex/videostrm_in.cc:
* gst-libs/ext/mplex/videostrm_out.cc:
* gst-libs/ext/mplex/yuv4mpeg.cc:
* gst-libs/ext/mplex/yuv4mpeg.h:
* gst-libs/ext/mplex/yuv4mpeg_intern.h:
* gst-libs/ext/mplex/yuv4mpeg_ratio.cc:
We don't fork mjpegtools' mplex in our CVS anymore.
* gst/avi/gstavidemux.c: (gst_avi_demux_src_getcaps),
(gst_avi_demux_add_stream):
* gst/avi/gstavidemux.h:
Add getcaps() function for proper caps nego. This makes some
parts of AVI playback/reading work.
* sys/ximage/ximagesink.c: (gst_ximagesink_sinkconnect):
Resize window on new capsnego. This is probably wrong, but
I'm still committing it because with current capsnego, the
first successfull capsnego is auto-fixated, therefore rounded
down to the lowest values in the caps. this results in a 16x16
XWindow that is not reized when real capsnego finishes.
Dave, I see more cases of this, do you know a proper solution?
* tools/gst-launch-ext.in:
Fix MPEG-4 AAC (Apple iPod/iTunes) file commandline.
2004-01-01 22:45:56 +00:00
|
|
|
gst_buffer_unref (outbuf);
|
2003-11-12 11:27:40 +00:00
|
|
|
gst_buffer_unref (subbuf);
|
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;
|
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_BUFFER_SIZE (outbuf) = ret_size;
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (subbuf);
|
|
|
|
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (subbuf);
|
2006-01-20 13:56:55 +00:00
|
|
|
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (ffmpegenc->srcpad));
|
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_unref (subbuf);
|
|
|
|
|
|
|
|
ret = gst_pad_push (ffmpegenc->srcpad, outbuf);
|
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
|
|
|
|
|
|
|
in_size -= frame_size;
|
|
|
|
}
|
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 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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
/* 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;
|
|
|
|
case ARG_BUFSIZE:
|
2004-03-29 16:39:18 +00:00
|
|
|
ffmpegenc->buffer_size = g_value_get_ulong (value);
|
2001-12-23 13:25:04 +00:00
|
|
|
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:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
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:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
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:
|
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;
|
|
|
|
}
|
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
|
|
|
if (ffmpegenc->cache) {
|
|
|
|
gst_buffer_unref (ffmpegenc->cache);
|
|
|
|
ffmpegenc->cache = 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
|
|
|
in_plugin = first_avcodec;
|
|
|
|
|
|
|
|
enc_global_plugins = g_hash_table_new (NULL, NULL);
|
|
|
|
|
|
|
|
while (in_plugin) {
|
|
|
|
gchar *type_name;
|
2003-06-07 20:46:24 +00:00
|
|
|
GstCaps *srccaps, *sinkcaps;
|
|
|
|
GstFFMpegEncClassParams *params;
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2003-06-17 11:44:38 +00:00
|
|
|
/* no quasi codecs, please */
|
|
|
|
if (in_plugin->id == CODEC_ID_RAWVIDEO ||
|
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 &&
|
2005-10-23 16:07:46 +00:00
|
|
|
in_plugin->id <= CODEC_ID_PCM_S24DAUD)) {
|
2003-06-17 11:44:38 +00:00
|
|
|
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
|
|
|
|
2004-10-24 22:24:43 +00:00
|
|
|
/* name */
|
2005-04-21 19:01:36 +00:00
|
|
|
if (!gst_ffmpeg_get_codecid_longname (in_plugin->id)) {
|
|
|
|
g_warning ("Add encoder %s (%d) please",
|
|
|
|
in_plugin->name, in_plugin->id);
|
2004-10-24 22:24:43 +00:00
|
|
|
goto next;
|
2005-04-21 19:01:36 +00:00
|
|
|
}
|
2004-10-24 22:24:43 +00:00
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
/* first make sure we've got a supported type */
|
2004-03-15 00:01:03 +00:00
|
|
|
srccaps = gst_ffmpeg_codecid_to_caps (in_plugin->id, NULL, TRUE);
|
2005-01-28 12:22:54 +00:00
|
|
|
if (in_plugin->type == CODEC_TYPE_VIDEO) {
|
|
|
|
sinkcaps = gst_caps_from_string ("video/x-raw-rgb; video/x-raw-yuv");
|
|
|
|
} else {
|
|
|
|
sinkcaps = gst_ffmpeg_codectype_to_caps (in_plugin->type, NULL);
|
|
|
|
}
|
2003-06-07 20:46:24 +00:00
|
|
|
if (!sinkcaps || !srccaps)
|
|
|
|
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
|
|
|
|
2002-03-19 04:09:41 +00:00
|
|
|
/* if it's already registered, drop it */
|
2004-03-29 16:39:18 +00:00
|
|
|
if (g_type_from_name (type_name)) {
|
|
|
|
g_free (type_name);
|
2001-12-23 13:25:04 +00:00
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
|
2003-06-07 20:46:24 +00:00
|
|
|
params = g_new0 (GstFFMpegEncClassParams, 1);
|
|
|
|
params->in_plugin = in_plugin;
|
2003-11-02 13:12:14 +00:00
|
|
|
params->srccaps = srccaps;
|
|
|
|
params->sinkcaps = sinkcaps;
|
2003-06-07 20:46:24 +00:00
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
g_hash_table_insert (enc_global_plugins,
|
|
|
|
GINT_TO_POINTER (0), (gpointer) params);
|
2003-11-02 19:07:41 +00:00
|
|
|
|
|
|
|
/* create the glib type now */
|
2004-03-29 16:39:18 +00:00
|
|
|
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
|
2004-02-02 20:27:13 +00:00
|
|
|
if (!gst_element_register (plugin, type_name, GST_RANK_NONE, type)) {
|
|
|
|
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
|
|
|
g_hash_table_insert (enc_global_plugins,
|
|
|
|
GINT_TO_POINTER (type), (gpointer) params);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
next:
|
2001-12-23 13:25:04 +00:00
|
|
|
in_plugin = in_plugin->next;
|
|
|
|
}
|
2003-11-02 19:07:41 +00:00
|
|
|
g_hash_table_remove (enc_global_plugins, GINT_TO_POINTER (0));
|
2001-12-23 13:25:04 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|