Create a stereo_mode metadata tag to specify the stereo 3d video layout
using the StereoMode tag in a matroska/webm video track.
| ... | ... |
@@ -204,4 +204,67 @@ Alternatively you can write the command as: |
| 204 | 204 |
ffmpeg -benchmark -i INPUT -f null - |
| 205 | 205 |
@end example |
| 206 | 206 |
|
| 207 |
+@section matroska |
|
| 208 |
+ |
|
| 209 |
+Matroska container muxer. |
|
| 210 |
+ |
|
| 211 |
+This muxer implements the matroska and webm container specs. |
|
| 212 |
+ |
|
| 213 |
+The recognized metadata settings in this muxer are: |
|
| 214 |
+ |
|
| 215 |
+@table @option |
|
| 216 |
+ |
|
| 217 |
+@item title=@var{title name}
|
|
| 218 |
+Name provided to a single track |
|
| 219 |
+@end table |
|
| 220 |
+ |
|
| 221 |
+@table @option |
|
| 222 |
+ |
|
| 223 |
+@item language=@var{language name}
|
|
| 224 |
+Specifies the language of the track in the Matroska languages form |
|
| 225 |
+@end table |
|
| 226 |
+ |
|
| 227 |
+@table @option |
|
| 228 |
+ |
|
| 229 |
+@item STEREO_MODE=@var{mode}
|
|
| 230 |
+Stereo 3D video layout of two views in a single video track |
|
| 231 |
+@table @option |
|
| 232 |
+@item mono |
|
| 233 |
+video is not stereo |
|
| 234 |
+@item left_right |
|
| 235 |
+Both views are arranged side by side, Left-eye view is on the left |
|
| 236 |
+@item bottom_top |
|
| 237 |
+Both views are arranged in top-bottom orientation, Left-eye view is at bottom |
|
| 238 |
+@item top_bottom |
|
| 239 |
+Both views are arranged in top-bottom orientation, Left-eye view is on top |
|
| 240 |
+@item checkerboard_rl |
|
| 241 |
+Each view is arranged in a checkerboard interleaved pattern, Left-eye view being first |
|
| 242 |
+@item checkerboard_lr |
|
| 243 |
+Each view is arranged in a checkerboard interleaved pattern, Right-eye view being first |
|
| 244 |
+@item row_interleaved_rl |
|
| 245 |
+Each view is constituted by a row based interleaving, Right-eye view is first row |
|
| 246 |
+@item row_interleaved_lr |
|
| 247 |
+Each view is constituted by a row based interleaving, Left-eye view is first row |
|
| 248 |
+@item col_interleaved_rl |
|
| 249 |
+Both views are arranged in a column based interleaving manner, Right-eye view is first column |
|
| 250 |
+@item col_interleaved_lr |
|
| 251 |
+Both views are arranged in a column based interleaving manner, Left-eye view is first column |
|
| 252 |
+@item anaglyph_cyan_red |
|
| 253 |
+All frames are in anaglyph format viewable through red-cyan filters |
|
| 254 |
+@item right_left |
|
| 255 |
+Both views are arranged side by side, Right-eye view is on the left |
|
| 256 |
+@item anaglyph_green_magenta |
|
| 257 |
+All frames are in anaglyph format viewable through green-magenta filters |
|
| 258 |
+@item block_lr |
|
| 259 |
+Both eyes laced in one Block, Left-eye view is first |
|
| 260 |
+@item block_rl |
|
| 261 |
+Both eyes laced in one Block, Right-eye view is first |
|
| 262 |
+@end table |
|
| 263 |
+@end table |
|
| 264 |
+ |
|
| 265 |
+For example a 3D WebM clip can be created using the following command line: |
|
| 266 |
+@example |
|
| 267 |
+ffmpeg -i sample_left_right_clip.mpg -an -vcodec libvpx -metadata STEREO_MODE=left_right -y stereo_clip.webm |
|
| 268 |
+@end example |
|
| 269 |
+ |
|
| 207 | 270 |
@c man end MUXERS |
| ... | ... |
@@ -111,7 +111,7 @@ |
| 111 | 111 |
#define MATROSKA_ID_VIDEOPIXELCROPR 0x54DD |
| 112 | 112 |
#define MATROSKA_ID_VIDEODISPLAYUNIT 0x54B2 |
| 113 | 113 |
#define MATROSKA_ID_VIDEOFLAGINTERLACED 0x9A |
| 114 |
-#define MATROSKA_ID_VIDEOSTEREOMODE 0x53B9 |
|
| 114 |
+#define MATROSKA_ID_VIDEOSTEREOMODE 0x53B8 |
|
| 115 | 115 |
#define MATROSKA_ID_VIDEOASPECTRATIO 0x54B3 |
| 116 | 116 |
#define MATROSKA_ID_VIDEOCOLORSPACE 0x2EB524 |
| 117 | 117 |
|
| ... | ... |
@@ -218,6 +218,24 @@ typedef enum {
|
| 218 | 218 |
MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP = 3, |
| 219 | 219 |
} MatroskaTrackEncodingCompAlgo; |
| 220 | 220 |
|
| 221 |
+typedef enum {
|
|
| 222 |
+ MATROSKA_VIDEO_STEREOMODE_TYPE_MONO = 0, |
|
| 223 |
+ MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT = 1, |
|
| 224 |
+ MATROSKA_VIDEO_STEREOMODE_TYPE_BOTTOM_TOP = 2, |
|
| 225 |
+ MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM = 3, |
|
| 226 |
+ MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_RL = 4, |
|
| 227 |
+ MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR = 5, |
|
| 228 |
+ MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_RL = 6, |
|
| 229 |
+ MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR = 7, |
|
| 230 |
+ MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_RL = 8, |
|
| 231 |
+ MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR = 9, |
|
| 232 |
+ MATROSKA_VIDEO_STEREOMODE_TYPE_ANAGLYPH_CYAN_RED = 10, |
|
| 233 |
+ MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT = 11, |
|
| 234 |
+ MATROSKA_VIDEO_STEREOMODE_TYPE_ANAGLYPH_GREEN_MAG = 12, |
|
| 235 |
+ MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR = 13, |
|
| 236 |
+ MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_RL = 14, |
|
| 237 |
+} MatroskaVideoStereoModeType; |
|
| 238 |
+ |
|
| 221 | 239 |
/* |
| 222 | 240 |
* Matroska Codec IDs, strings |
| 223 | 241 |
*/ |
| ... | ... |
@@ -586,6 +586,25 @@ static int mkv_write_tracks(AVFormatContext *s) |
| 586 | 586 |
// XXX: interlace flag? |
| 587 | 587 |
put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELWIDTH , codec->width); |
| 588 | 588 |
put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELHEIGHT, codec->height); |
| 589 |
+ if ((tag = av_metadata_get(s->metadata, "stereo_mode", NULL, 0))) {
|
|
| 590 |
+ uint8_t stereo_fmt = atoi(tag->value); |
|
| 591 |
+ int valid_fmt = 0; |
|
| 592 |
+ |
|
| 593 |
+ switch (mkv->mode) {
|
|
| 594 |
+ case MODE_WEBM: |
|
| 595 |
+ if (stereo_fmt <= MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM |
|
| 596 |
+ || stereo_fmt == MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT) |
|
| 597 |
+ valid_fmt = 1; |
|
| 598 |
+ break; |
|
| 599 |
+ case MODE_MATROSKAv2: |
|
| 600 |
+ if (stereo_fmt <= MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_RL) |
|
| 601 |
+ valid_fmt = 1; |
|
| 602 |
+ break; |
|
| 603 |
+ } |
|
| 604 |
+ |
|
| 605 |
+ if (valid_fmt) |
|
| 606 |
+ put_ebml_uint (pb, MATROSKA_ID_VIDEOSTEREOMODE, stereo_fmt); |
|
| 607 |
+ } |
|
| 589 | 608 |
if (st->sample_aspect_ratio.num) {
|
| 590 | 609 |
int d_width = codec->width*av_q2d(st->sample_aspect_ratio); |
| 591 | 610 |
put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , d_width); |