[FFmpeg-cvslog] webm: support stereo videos in matroska/webm muxer

Alok Ahuja git at videolan.org
Sun May 29 03:46:43 CEST 2011


ffmpeg | branch: master | Alok Ahuja <waveletcoeff at gmail.com> | Sat May 28 08:12:22 2011 +0200| [945dda41a2085b3c8fb5cf99026c224aa3d2cbfa] | committer: Reinhard Tartler

webm: support stereo videos in matroska/webm muxer

Create a stereo_mode metadata tag to specify the stereo 3d video layout
using the StereoMode tag in a matroska/webm video track.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=945dda41a2085b3c8fb5cf99026c224aa3d2cbfa
---

 doc/muxers.texi           |   63 +++++++++++++++++++++++++++++++++++++++++++++
 libavformat/matroska.h    |   20 +++++++++++++-
 libavformat/matroskaenc.c |   19 +++++++++++++
 3 files changed, 101 insertions(+), 1 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 82f17ba..74c014b 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -204,4 +204,67 @@ Alternatively you can write the command as:
 ffmpeg -benchmark -i INPUT -f null -
 @end example
 
+ at section matroska
+
+Matroska container muxer.
+
+This muxer implements the matroska and webm container specs.
+
+The recognized metadata settings in this muxer are:
+
+ at table @option
+
+ at item title=@var{title name}
+Name provided to a single track
+ at end table
+
+ at table @option
+
+ at item language=@var{language name}
+Specifies the language of the track in the Matroska languages form
+ at end table
+
+ at table @option
+
+ at item STEREO_MODE=@var{mode}
+Stereo 3D video layout of two views in a single video track
+ at table @option
+ at item mono
+video is not stereo
+ at item left_right
+Both views are arranged side by side, Left-eye view is on the left
+ at item bottom_top
+Both views are arranged in top-bottom orientation, Left-eye view is at bottom
+ at item top_bottom
+Both views are arranged in top-bottom orientation, Left-eye view is on top
+ at item checkerboard_rl
+Each view is arranged in a checkerboard interleaved pattern, Left-eye view being first
+ at item checkerboard_lr
+Each view is arranged in a checkerboard interleaved pattern, Right-eye view being first
+ at item row_interleaved_rl
+Each view is constituted by a row based interleaving, Right-eye view is first row
+ at item row_interleaved_lr
+Each view is constituted by a row based interleaving, Left-eye view is first row
+ at item col_interleaved_rl
+Both views are arranged in a column based interleaving manner, Right-eye view is first column
+ at item col_interleaved_lr
+Both views are arranged in a column based interleaving manner, Left-eye view is first column
+ at item anaglyph_cyan_red
+All frames are in anaglyph format viewable through red-cyan filters
+ at item right_left
+Both views are arranged side by side, Right-eye view is on the left
+ at item anaglyph_green_magenta
+All frames are in anaglyph format viewable through green-magenta filters
+ at item block_lr
+Both eyes laced in one Block, Left-eye view is first
+ at item block_rl
+Both eyes laced in one Block, Right-eye view is first
+ at end table
+ at end table
+
+For example a 3D WebM clip can be created using the following command line:
+ at example
+ffmpeg -i sample_left_right_clip.mpg -an -vcodec libvpx -metadata STEREO_MODE=left_right -y stereo_clip.webm
+ at end example
+
 @c man end MUXERS
diff --git a/libavformat/matroska.h b/libavformat/matroska.h
index 45d9747..8e747e6 100644
--- a/libavformat/matroska.h
+++ b/libavformat/matroska.h
@@ -111,7 +111,7 @@
 #define MATROSKA_ID_VIDEOPIXELCROPR 0x54DD
 #define MATROSKA_ID_VIDEODISPLAYUNIT 0x54B2
 #define MATROSKA_ID_VIDEOFLAGINTERLACED 0x9A
-#define MATROSKA_ID_VIDEOSTEREOMODE 0x53B9
+#define MATROSKA_ID_VIDEOSTEREOMODE 0x53B8
 #define MATROSKA_ID_VIDEOASPECTRATIO 0x54B3
 #define MATROSKA_ID_VIDEOCOLORSPACE 0x2EB524
 
@@ -218,6 +218,24 @@ typedef enum {
   MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP = 3,
 } MatroskaTrackEncodingCompAlgo;
 
+typedef enum {
+  MATROSKA_VIDEO_STEREOMODE_TYPE_MONO               = 0,
+  MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT         = 1,
+  MATROSKA_VIDEO_STEREOMODE_TYPE_BOTTOM_TOP         = 2,
+  MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM         = 3,
+  MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_RL    = 4,
+  MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR    = 5,
+  MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_RL = 6,
+  MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR = 7,
+  MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_RL = 8,
+  MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR = 9,
+  MATROSKA_VIDEO_STEREOMODE_TYPE_ANAGLYPH_CYAN_RED  = 10,
+  MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT         = 11,
+  MATROSKA_VIDEO_STEREOMODE_TYPE_ANAGLYPH_GREEN_MAG = 12,
+  MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR = 13,
+  MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_RL = 14,
+} MatroskaVideoStereoModeType;
+
 /*
  * Matroska Codec IDs, strings
  */
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 1bbabc9..ba2ce28 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -586,6 +586,25 @@ static int mkv_write_tracks(AVFormatContext *s)
                 // XXX: interlace flag?
                 put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELWIDTH , codec->width);
                 put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELHEIGHT, codec->height);
+                if ((tag = av_metadata_get(s->metadata, "stereo_mode", NULL, 0))) {
+                    uint8_t stereo_fmt = atoi(tag->value);
+                    int valid_fmt = 0;
+
+                    switch (mkv->mode) {
+                    case MODE_WEBM:
+                        if (stereo_fmt <= MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM
+                            || stereo_fmt == MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT)
+                            valid_fmt = 1;
+                        break;
+                    case MODE_MATROSKAv2:
+                        if (stereo_fmt <= MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_RL)
+                            valid_fmt = 1;
+                        break;
+                    }
+
+                    if (valid_fmt)
+                        put_ebml_uint (pb, MATROSKA_ID_VIDEOSTEREOMODE, stereo_fmt);
+                }
                 if (st->sample_aspect_ratio.num) {
                     int d_width = codec->width*av_q2d(st->sample_aspect_ratio);
                     put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , d_width);



More information about the ffmpeg-cvslog mailing list