|
Packit |
1f69a5 |
/* GStreamer WebM muxer
|
|
Packit |
1f69a5 |
* Copyright (c) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
|
Packit |
1f69a5 |
*
|
|
Packit |
1f69a5 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
1f69a5 |
* modify it under the terms of the GNU Library General Public
|
|
Packit |
1f69a5 |
* License as published by the Free Software Foundation; either
|
|
Packit |
1f69a5 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
1f69a5 |
*
|
|
Packit |
1f69a5 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
1f69a5 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
1f69a5 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
1f69a5 |
* Library General Public License for more details.
|
|
Packit |
1f69a5 |
*
|
|
Packit |
1f69a5 |
* You should have received a copy of the GNU Library General Public
|
|
Packit |
1f69a5 |
* License along with this library; if not, write to the
|
|
Packit |
1f69a5 |
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
Packit |
1f69a5 |
* Boston, MA 02110-1301, USA.
|
|
Packit |
1f69a5 |
*/
|
|
Packit |
1f69a5 |
|
|
Packit |
1f69a5 |
/**
|
|
Packit |
1f69a5 |
* SECTION:element-webmmux
|
|
Packit |
1f69a5 |
*
|
|
Packit |
1f69a5 |
* webmmux muxes VP8 video and Vorbis audio streams into a WebM file.
|
|
Packit |
1f69a5 |
*
|
|
Packit |
1f69a5 |
* <refsect2>
|
|
Packit |
1f69a5 |
* <title>Example launch line</title>
|
|
Packit |
1f69a5 |
* |[
|
|
Packit |
1f69a5 |
* gst-launch-1.0 webmmux name=mux ! filesink location=newfile.webm \
|
|
Packit |
1f69a5 |
* uridecodebin uri=file:///path/to/somefile.ogv name=demux \
|
|
Packit |
1f69a5 |
* demux. ! videoconvert ! vp8enc ! queue ! mux.video_0 \
|
|
Packit |
1f69a5 |
* demux. ! progressreport ! audioconvert ! audiorate ! vorbisenc ! queue ! mux.audio_0
|
|
Packit |
1f69a5 |
* ]| This pipeline re-encodes a video file of any format into a WebM file.
|
|
Packit |
1f69a5 |
* |[
|
|
Packit |
1f69a5 |
* gst-launch-1.0 webmmux name=mux ! filesink location=test.webm \
|
|
Packit |
1f69a5 |
* videotestsrc num-buffers=250 ! video/x-raw,framerate=25/1 ! videoconvert ! vp8enc ! queue ! mux.video_0 \
|
|
Packit |
1f69a5 |
* audiotestsrc samplesperbuffer=44100 num-buffers=10 ! audio/x-raw,rate=44100 ! vorbisenc ! queue ! mux.audio_0
|
|
Packit |
1f69a5 |
* ]| This pipeline muxes a test video and a sine wave into a WebM file.
|
|
Packit |
1f69a5 |
* </refsect2>
|
|
Packit |
1f69a5 |
*/
|
|
Packit |
1f69a5 |
|
|
Packit |
1f69a5 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
1f69a5 |
#include "config.h"
|
|
Packit |
1f69a5 |
#endif
|
|
Packit |
1f69a5 |
|
|
Packit |
1f69a5 |
#include "webm-mux.h"
|
|
Packit |
1f69a5 |
|
|
Packit |
1f69a5 |
#define COMMON_VIDEO_CAPS \
|
|
Packit |
1f69a5 |
"width = (int) [ 16, 4096 ], " \
|
|
Packit |
1f69a5 |
"height = (int) [ 16, 4096 ], " \
|
|
Packit |
1f69a5 |
"framerate = (fraction) [ 0, MAX ]"
|
|
Packit |
1f69a5 |
|
|
Packit |
1f69a5 |
#define COMMON_AUDIO_CAPS \
|
|
Packit |
1f69a5 |
"channels = (int) [ 1, MAX ], " \
|
|
Packit |
1f69a5 |
"rate = (int) [ 1, MAX ]"
|
|
Packit |
1f69a5 |
|
|
Packit |
1f69a5 |
G_DEFINE_TYPE (GstWebMMux, gst_webm_mux, GST_TYPE_MATROSKA_MUX);
|
|
Packit |
1f69a5 |
|
|
Packit |
1f69a5 |
static GstStaticPadTemplate webm_src_templ = GST_STATIC_PAD_TEMPLATE ("src",
|
|
Packit |
1f69a5 |
GST_PAD_SRC,
|
|
Packit |
1f69a5 |
GST_PAD_ALWAYS,
|
|
Packit |
1f69a5 |
GST_STATIC_CAPS ("video/webm; audio/webm")
|
|
Packit |
1f69a5 |
);
|
|
Packit |
1f69a5 |
|
|
Packit |
1f69a5 |
static GstStaticPadTemplate webm_videosink_templ =
|
|
Packit |
1f69a5 |
GST_STATIC_PAD_TEMPLATE ("video_%u",
|
|
Packit |
1f69a5 |
GST_PAD_SINK,
|
|
Packit |
1f69a5 |
GST_PAD_REQUEST,
|
|
Packit |
1f69a5 |
GST_STATIC_CAPS ("video/x-vp8, " COMMON_VIDEO_CAPS ";"
|
|
Packit |
1f69a5 |
"video/x-vp9, " COMMON_VIDEO_CAPS ";" "video/x-av1, " COMMON_VIDEO_CAPS)
|
|
Packit |
1f69a5 |
);
|
|
Packit |
1f69a5 |
|
|
Packit |
1f69a5 |
static GstStaticPadTemplate webm_audiosink_templ =
|
|
Packit |
1f69a5 |
GST_STATIC_PAD_TEMPLATE ("audio_%u",
|
|
Packit |
1f69a5 |
GST_PAD_SINK,
|
|
Packit |
1f69a5 |
GST_PAD_REQUEST,
|
|
Packit |
1f69a5 |
GST_STATIC_CAPS ("audio/x-vorbis, " COMMON_AUDIO_CAPS ";"
|
|
Packit |
1f69a5 |
"audio/x-opus, " COMMON_AUDIO_CAPS)
|
|
Packit |
1f69a5 |
);
|
|
Packit |
1f69a5 |
|
|
Packit |
1f69a5 |
static void
|
|
Packit |
1f69a5 |
gst_webm_mux_class_init (GstWebMMuxClass * klass)
|
|
Packit |
1f69a5 |
{
|
|
Packit |
1f69a5 |
GstElementClass *gstelement_class = (GstElementClass *) klass;
|
|
Packit |
1f69a5 |
|
|
Packit |
1f69a5 |
gst_element_class_add_static_pad_template (gstelement_class,
|
|
Packit |
1f69a5 |
&webm_videosink_templ);
|
|
Packit |
1f69a5 |
gst_element_class_add_static_pad_template (gstelement_class,
|
|
Packit |
1f69a5 |
&webm_audiosink_templ);
|
|
Packit |
1f69a5 |
gst_element_class_add_static_pad_template (gstelement_class, &webm_src_templ);
|
|
Packit |
1f69a5 |
gst_element_class_set_static_metadata (gstelement_class, "WebM muxer",
|
|
Packit |
1f69a5 |
"Codec/Muxer",
|
|
Packit |
1f69a5 |
"Muxes video and audio streams into a WebM stream",
|
|
Packit |
1f69a5 |
"GStreamer maintainers <gstreamer-devel@lists.freedesktop.org>");
|
|
Packit |
1f69a5 |
}
|
|
Packit |
1f69a5 |
|
|
Packit |
1f69a5 |
static void
|
|
Packit |
1f69a5 |
gst_webm_mux_init (GstWebMMux * mux)
|
|
Packit |
1f69a5 |
{
|
|
Packit |
1f69a5 |
GST_MATROSKA_MUX (mux)->doctype = GST_MATROSKA_DOCTYPE_WEBM;
|
|
Packit |
1f69a5 |
GST_MATROSKA_MUX (mux)->is_webm = TRUE;
|
|
Packit |
1f69a5 |
}
|