yuv4mpeg(5) | MJPEG Tools Manual | yuv4mpeg(5) |
YUV4MPEG2 - video stream format used by pipe-based MJPEGtools
Many of the MJPEGtools communicate via pipes and act as filters (or sources or sinks). The format of video data used in the pipes is referred to as "YUV4MPEG", or, more precisely, "YUV4MPEG2". (The format was extended and codified during v1.5.x of the tools.)
The basic structure is a stream header followed by an unlimited number of frames. Each frame itself consists of a header followed by video data. The headers are vaguely human-readable ASCII, but the video data is simple byte-size binary.
The MJPEGtools distribution has a C library (libmjpegutils) which contains functions for manipulating YUV4MPEG2 streams. We recommend that you use this library rather than writing your own code if possible. See the header file "yuv4mpeg.h" for a description of these functions.
Design Goals:
Drawbacks:
The precise description of the the YUV4MPEG2 stream format is as follows:
STREAM consists of
STREAM-HEADER consists of
FRAME consists of
FRAME-HEADER consists of
TAGGED-FIELD consists of
VALUE consists of
RATIO consists of
Header tags fall into three categories: optional, required and has-default. Optional tags are completely optional and may be omitted from a header. Required tags must be present in a header. Has-Default tags have a default value which is implied if the tag is not present. Independent of these categories, some tags allow an "unknown" value and some do not.
The supported tags for the STREAM-HEADER:
W[integer] - frame width in pixels, must be > 0 (required)
H[integer] - frame height in pixels, must be > 0 (required)
C[string] - chroma subsampling, image data format (has default)
I[char] - interlacing specification: (has default)
F[ratio] - frame-rate (has default of 0:0 == unknown)
A[ratio] - sample aspect ratio (has default of 0:0 == unknown)
X[string] - 'metadata' (optional; unparsed, but passed around)
The currently supported tags for the FRAME-HEADER:
I[string] - framing and sampling (required if-and-only-if Im is present in stream header). Value is a string of three characters "xyz" which have the following meanings:
X[string] - 'metadata' (optional; unparsed, but passed around)
Note that a filter application must faithfully forward all "X" tags from input pipe to output pipe (unless it uses one of those tags, of course). The supplied library will do this automatically if the functions y4m_copy_stream_info() and y4m_copy_frame_info() are used appropriately.
All image data is in the CCIR-601 Y'CbCr colorspace, presented plane-by-plane in row-major order. Each sample within each plane is one octet (8-bits) in size. When all planes are present, they are transmitted in the order Y', Cb, Cr, potentially followed by an alpha/transparency mask plane (for the 444alpha chroma format). The alpha channel data is follows the same range as the Y' luma channel: full transparency is at 16 and full opacity is at 235.
All Y' and alpha planes consist of (height X width) octets. The size of the chroma planes depends on the subsampling mode:
(More to come here.)
mjpegtools(1), yuv4mpeg.h
This manual page Copyright 2004 Matthew J. Marjanovic.
25 November 2002 | MJPEG Tools Team |