aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Zern <jzern@google.com>2010-06-09 15:54:27 +0000
committerReinhard Tartler <siretart@tauware.de>2010-06-09 15:54:27 +0000
commitdb06ddf8c6711d99eb903359c0118b63ec129c27 (patch)
tree27eea059864f74bcd256eaea6ff2e86cc4edad56
parenteb4b8b96fcb2192ba118315bfee6651400888323 (diff)
downloadffmpeg-db06ddf8c6711d99eb903359c0118b63ec129c27.tar.gz
Add WebM muxer
Patch by James Zern <jzern at google> backport r23474 by conrad Originally committed as revision 23549 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6
-rw-r--r--Changelog1
-rw-r--r--doc/general.texi2
-rw-r--r--libavcodec/Makefile2
-rw-r--r--libavformat/Makefile3
-rw-r--r--libavformat/allformats.c1
-rw-r--r--libavformat/avformat.h2
-rw-r--r--libavformat/matroskaenc.c42
7 files changed, 48 insertions, 5 deletions
diff --git a/Changelog b/Changelog
index 9fc9bbc0c4..ef59fd7e17 100644
--- a/Changelog
+++ b/Changelog
@@ -76,6 +76,7 @@ version 0.6:
- 35% faster VP3/Theora decoding
- faster AAC decoding
- faster H.264 decoding
+- WebM support in Matroska de/muxer
- low overhead Ogg muxing
- WebM support in Matroska demuxer
- VP8 de/encoding via libvpx
diff --git a/doc/general.texi b/doc/general.texi
index e7eb83f04c..dfa5b07e18 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -234,7 +234,7 @@ library:
@item VC-1 test bitstream @tab X @tab X
@item WAV @tab X @tab X
@item WavPack @tab @tab X
-@item WebM @tab @tab X
+@item WebM @tab X @tab X
@item Wing Commander III movie @tab @tab X
@tab Multimedia format used in Origin's Wing Commander III computer game.
@item Westwood Studios audio @tab @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 562e162511..00e6b57fd3 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -501,6 +501,8 @@ OBJS-$(CONFIG_OGG_DEMUXER) += flacdec.o flacdata.o flac.o \
dirac.o mpeg12data.o
OBJS-$(CONFIG_OGG_MUXER) += xiph.o flacdec.o flacdata.o flac.o
OBJS-$(CONFIG_RTP_MUXER) += mpegvideo.o
+OBJS-$(CONFIG_WEBM_MUXER) += xiph.o mpeg4audio.o \
+ flacdec.o flacdata.o flac.o
# external codec libraries
OBJS-$(CONFIG_LIBDIRAC_DECODER) += libdiracdec.o
diff --git a/libavformat/Makefile b/libavformat/Makefile
index a671e283e2..7a2d00fb45 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -255,6 +255,9 @@ OBJS-$(CONFIG_W64_DEMUXER) += wav.o riff.o raw.o
OBJS-$(CONFIG_WAV_DEMUXER) += wav.o riff.o raw.o
OBJS-$(CONFIG_WAV_MUXER) += wav.o riff.o
OBJS-$(CONFIG_WC3_DEMUXER) += wc3movie.o
+OBJS-$(CONFIG_WEBM_MUXER) += matroskaenc.o matroska.o \
+ riff.o isom.o avc.o \
+ flacenc_header.o
OBJS-$(CONFIG_WSAUD_DEMUXER) += westwood.o
OBJS-$(CONFIG_WSVQA_DEMUXER) += westwood.o
OBJS-$(CONFIG_WV_DEMUXER) += wv.o apetag.o id3v1.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 27dba103d2..27a955594b 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -203,6 +203,7 @@ void av_register_all(void)
REGISTER_DEMUXER (W64, w64);
REGISTER_MUXDEMUX (WAV, wav);
REGISTER_DEMUXER (WC3, wc3);
+ REGISTER_MUXER (WEBM, webm);
REGISTER_DEMUXER (WSAUD, wsaud);
REGISTER_DEMUXER (WSVQA, wsvqa);
REGISTER_DEMUXER (WV, wv);
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index c312d98ab8..0e93376bdb 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -23,7 +23,7 @@
#define LIBAVFORMAT_VERSION_MAJOR 52
#define LIBAVFORMAT_VERSION_MINOR 64
-#define LIBAVFORMAT_VERSION_MICRO 1
+#define LIBAVFORMAT_VERSION_MICRO 2
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 01e6e79f3f..c004bd6464 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -65,7 +65,11 @@ typedef struct {
int write_dts;
} mkv_track;
+#define MODE_MATROSKAv2 0x01
+#define MODE_WEBM 0x02
+
typedef struct MatroskaMuxContext {
+ int mode;
ByteIOContext *dyn_bc;
ebml_master segment;
int64_t segment_offset;
@@ -563,6 +567,13 @@ static int mkv_write_tracks(AVFormatContext *s)
}
}
+ if (mkv->mode == MODE_WEBM && !(codec->codec_id == CODEC_ID_VP8 ||
+ codec->codec_id == CODEC_ID_VORBIS)) {
+ av_log(s, AV_LOG_ERROR,
+ "Only VP8 video and Vorbis audio are supported for WebM.\n");
+ return AVERROR(EINVAL);
+ }
+
switch (codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_VIDEO);
@@ -684,6 +695,9 @@ static int mkv_write_header(AVFormatContext *s)
AVMetadataTag *tag;
int ret;
+ if (!strcmp(s->oformat->name, "webm")) mkv->mode = MODE_WEBM;
+ else mkv->mode = MODE_MATROSKAv2;
+
mkv->md5_ctx = av_mallocz(av_md5_size);
av_md5_init(mkv->md5_ctx);
mkv->tracks = av_mallocz(s->nb_streams * sizeof(*mkv->tracks));
@@ -693,7 +707,7 @@ static int mkv_write_header(AVFormatContext *s)
put_ebml_uint (pb, EBML_ID_EBMLREADVERSION , 1);
put_ebml_uint (pb, EBML_ID_EBMLMAXIDLENGTH , 4);
put_ebml_uint (pb, EBML_ID_EBMLMAXSIZELENGTH , 8);
- put_ebml_string (pb, EBML_ID_DOCTYPE , "matroska");
+ put_ebml_string (pb, EBML_ID_DOCTYPE , s->oformat->name);
put_ebml_uint (pb, EBML_ID_DOCTYPEVERSION , 2);
put_ebml_uint (pb, EBML_ID_DOCTYPEREADVERSION , 2);
end_ebml_master(pb, ebml_header);
@@ -736,8 +750,10 @@ static int mkv_write_header(AVFormatContext *s)
ret = mkv_write_tracks(s);
if (ret < 0) return ret;
- ret = mkv_write_chapters(s);
- if (ret < 0) return ret;
+ if (mkv->mode != MODE_WEBM) {
+ ret = mkv_write_chapters(s);
+ if (ret < 0) return ret;
+ }
if (url_is_streamed(s->pb))
mkv_write_seekhead(pb, mkv->main_seekhead);
@@ -974,6 +990,7 @@ static int mkv_write_trailer(AVFormatContext *s)
return 0;
}
+#if CONFIG_MATROSKA_MUXER
AVOutputFormat matroska_muxer = {
"matroska",
NULL_IF_CONFIG_SMALL("Matroska file format"),
@@ -989,7 +1006,25 @@ AVOutputFormat matroska_muxer = {
.codec_tag = (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0},
.subtitle_codec = CODEC_ID_TEXT,
};
+#endif
+
+#if CONFIG_WEBM_MUXER
+AVOutputFormat webm_muxer = {
+ "webm",
+ NULL_IF_CONFIG_SMALL("WebM file format"),
+ "video/webm",
+ "webm",
+ sizeof(MatroskaMuxContext),
+ CODEC_ID_VORBIS,
+ CODEC_ID_VP8,
+ mkv_write_header,
+ mkv_write_packet,
+ mkv_write_trailer,
+ .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
+};
+#endif
+#if CONFIG_MATROSKA_AUDIO_MUXER
AVOutputFormat matroska_audio_muxer = {
"matroska",
NULL_IF_CONFIG_SMALL("Matroska file format"),
@@ -1004,3 +1039,4 @@ AVOutputFormat matroska_audio_muxer = {
.flags = AVFMT_GLOBALHEADER,
.codec_tag = (const AVCodecTag* const []){ff_codec_wav_tags, 0},
};
+#endif