2010-05-21 11:47:03 +00:00
|
|
|
/* GStreamer WebM muxer
|
|
|
|
* Copyright (c) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
|
|
|
*
|
|
|
|
* 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
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2010-05-21 11:47:03 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:element-webmmux
|
|
|
|
*
|
|
|
|
* webmmux muxes VP8 video and Vorbis audio streams into a WebM file.
|
|
|
|
*
|
|
|
|
* <refsect2>
|
|
|
|
* <title>Example launch line</title>
|
|
|
|
* |[
|
2010-05-23 10:17:27 +00:00
|
|
|
* gst-launch-0.10 webmmux name=mux ! filesink location=newfile.webm \
|
|
|
|
* uridecodebin uri=file:///path/to/somefile.ogv name=demux \
|
2012-08-26 21:39:55 +00:00
|
|
|
* demux. ! videoconvert ! vp8enc ! queue ! mux.video_0 \
|
2010-05-23 10:17:27 +00:00
|
|
|
* demux. ! progressreport ! audioconvert ! audiorate ! vorbisenc ! queue ! mux.audio_0
|
|
|
|
* ]| This pipeline re-encodes a video file of any format into a WebM file.
|
2010-05-21 11:47:03 +00:00
|
|
|
* |[
|
2010-05-23 10:17:27 +00:00
|
|
|
* gst-launch-0.10 webmmux name=mux ! filesink location=test.webm \
|
2012-08-26 21:39:55 +00:00
|
|
|
* videotestsrc num-buffers=250 ! video/x-raw,framerate=25/1 ! videoconvert ! vp8enc ! queue ! mux.video_0 \
|
2011-11-26 09:01:07 +00:00
|
|
|
* audiotestsrc samplesperbuffer=44100 num-buffers=10 ! audio/x-raw,rate=44100 ! vorbisenc ! queue ! mux.audio_0
|
2010-05-23 10:17:27 +00:00
|
|
|
* ]| This pipeline muxes a test video and a sine wave into a WebM file.
|
2010-05-21 11:47:03 +00:00
|
|
|
* </refsect2>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "webm-mux.h"
|
|
|
|
|
|
|
|
#define COMMON_VIDEO_CAPS \
|
|
|
|
"width = (int) [ 16, 4096 ], " \
|
|
|
|
"height = (int) [ 16, 4096 ], " \
|
|
|
|
"framerate = (fraction) [ 0, MAX ]"
|
|
|
|
|
|
|
|
#define COMMON_AUDIO_CAPS \
|
|
|
|
"channels = (int) [ 1, MAX ], " \
|
|
|
|
"rate = (int) [ 1, MAX ]"
|
|
|
|
|
2011-11-26 09:01:07 +00:00
|
|
|
G_DEFINE_TYPE (GstWebMMux, gst_webm_mux, GST_TYPE_MATROSKA_MUX);
|
2010-05-21 11:47:03 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate webm_src_templ = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2012-04-28 18:57:51 +00:00
|
|
|
GST_STATIC_CAPS ("video/webm; audio/webm")
|
2010-05-21 11:47:03 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate webm_videosink_templ =
|
2013-06-21 11:11:32 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("video_%u",
|
2010-05-21 11:47:03 +00:00
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_REQUEST,
|
2013-06-21 11:11:32 +00:00
|
|
|
GST_STATIC_CAPS ("video/x-vp8, " COMMON_VIDEO_CAPS ";"
|
|
|
|
"video/x-vp9, " COMMON_VIDEO_CAPS)
|
2010-05-21 11:47:03 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate webm_audiosink_templ =
|
2011-11-04 10:58:22 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("audio_%u",
|
2010-05-21 11:47:03 +00:00
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_REQUEST,
|
|
|
|
GST_STATIC_CAPS ("audio/x-vorbis, " COMMON_AUDIO_CAPS)
|
|
|
|
);
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_webm_mux_class_init (GstWebMMuxClass * klass)
|
|
|
|
{
|
|
|
|
GstElementClass *gstelement_class = (GstElementClass *) klass;
|
|
|
|
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&webm_videosink_templ));
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&webm_audiosink_templ));
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&webm_src_templ));
|
2012-04-09 23:51:41 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class, "WebM muxer",
|
2010-05-21 11:47:03 +00:00
|
|
|
"Codec/Muxer",
|
2010-05-21 12:01:30 +00:00
|
|
|
"Muxes video and audio streams into a WebM stream",
|
2010-05-21 11:47:03 +00:00
|
|
|
"GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-11-26 09:01:07 +00:00
|
|
|
gst_webm_mux_init (GstWebMMux * mux)
|
2010-05-21 11:47:03 +00:00
|
|
|
{
|
|
|
|
GST_MATROSKA_MUX (mux)->doctype = GST_MATROSKA_DOCTYPE_WEBM;
|
2013-10-06 16:17:00 +00:00
|
|
|
GST_MATROSKA_MUX (mux)->is_webm = TRUE;
|
2010-05-21 11:47:03 +00:00
|
|
|
}
|