Network Working Group M. Niedermayer Internet-Draft FFmpeg Intended status: Standards Track L. Barbato, Ed. Expires: March 28, 2008 Politecnico di Torino September 25, 2007 NUT Multimedia Container File Format Status of This Memo By submitting this Internet-Draft, each author represents that any applicable patent or other IPR claims of which he or she is aware have been or will be disclosed, and any of which he or she becomes aware will be disclosed, in accordance with Section 6 of BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF), its areas, and its working groups. Note that other groups may also distribute working documents as Internet- Drafts. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." The list of current Internet-Drafts can be accessed at http://www.ietf.org/ietf/1id-abstracts.txt. The list of Internet-Draft Shadow Directories can be accessed at http://www.ietf.org/shadow.html. This Internet-Draft will expire on March 28, 2008. Copyright Notice Copyright (C) The IETF Trust (2007). Abstract This memo defines a method for efficiently storing generic multimedia streams so that operation like seeking and recover for error can be performed with minimal computational cost. Minimal overhead and maximal extensibility had been considered in the development of the format. Niedermayer & Barbato Expires March 28, 2008 [Page 1] Internet-Draft NUT Container Format September 2007 Editors Note All references to RFC XXXX are to be replaced by references to the RFC number of this memo, when published. Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2. Syntax Convetions . . . . . . . . . . . . . . . . . . . . . 4 1.2.1. Datatypes . . . . . . . . . . . . . . . . . . . . . . . 4 2. NUT file layout . . . . . . . . . . . . . . . . . . . . . . . . 5 2.1. High level File structure . . . . . . . . . . . . . . . . . 5 2.2. Main Header . . . . . . . . . . . . . . . . . . . . . . . . 5 2.3. Reserved Headers . . . . . . . . . . . . . . . . . . . . . 5 2.4. Stream Header . . . . . . . . . . . . . . . . . . . . . . . 5 2.5. Info Packet . . . . . . . . . . . . . . . . . . . . . . . . 5 2.6. Index . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.7. Syncpoint . . . . . . . . . . . . . . . . . . . . . . . . . 6 3. Interleaving Rules . . . . . . . . . . . . . . . . . . . . . . 6 4. IANA Considerations . . . . . . . . . . . . . . . . . . . . . . 6 5. Security Considerations . . . . . . . . . . . . . . . . . . . . 6 6. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 6 7. References . . . . . . . . . . . . . . . . . . . . . . . . . . 6 7.1. Normative References . . . . . . . . . . . . . . . . . . . 6 7.2. Informative References . . . . . . . . . . . . . . . . . . 6 Niedermayer & Barbato Expires March 28, 2008 [Page 2] Internet-Draft NUT Container Format September 2007 1. Introduction NUT is a multimedia container format for storage of audio, video, subtitles and related user defined streams, it provides exact timestamps for synchronization and seeking, is simple, has low overhead and can recover in case of errors in the stream. This document defines: The file format layout The common stream interleaving rules 1.1. Terminology The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119]. This document refers to the following definitions pts Presentation time of the first frame/sample that is completed by decoding the coded frame. dts The time when a frame is input into a synchronous 1-in-1-out decoder. frame Minimal unit of information that can be decoded completely, it is usually holds a full frame video frame, a group of audio samples or a subtitle line. Keyframe A keyframe is a frame from which you can start decoding. The nth frame is a keyframe if and only if frames n, n+1, ... in presentation order (that are all frames with a pts >= frame[n].pts) can be decoded successfully without reference to frames prior n in storage order (that are all frames with a dts < frame[n].dts). If no such frames exist (for example due to using overlapped transforms like the MDCT in an audio codec), then the definition shall be extended by dropping n out of the set of frames which must be decodable, if this is still insufficient then n+1 shall be dropped, and so on until there is a keyframe. Every frame which is marked as a keyframe MUST be a keyframe according to the definition above, a muxer MUST mark every frame it knows is a keyframe as such, a muxer SHOULD NOT analyze future frames to determine the keyframe status of the current frame but instead just set the frame as non-keyframe. Niedermayer & Barbato Expires March 28, 2008 [Page 3] Internet-Draft NUT Container Format September 2007 1.2. Syntax Convetions Since NUT heavily uses variable length fields, the simplest way to describe it is using a pseudocode approach instead of graphical bitfield descriptions. The syntax uses datatypes, tagnames and C-like constructs. 1.2.1. Datatypes f(n) n fixed bits in bigendian order u(n) Unsigned value encoded in n bits MSB-first v Unsigned variable length value. value=0 do{ more_data u(1) data u(7) value= 128*value + data }while(more_data) Figure 1: Variable Length Unsigned Value Values can be encoded using the following logic: the data is in network order, every byte has the most significant bit used as flag and the following 7 used to store the value. The first N bit are to be taken, where N is number of bits representing the value modulo 7, and stored in the first byte. If there are more bits, the flag bit is set to 1 and the subsequent 7bit are stored in the following byte, if there are remaining bits set the flag to 1 and the same procedure is repeated. The ending byte has the flag bit set to 0. In order to decode it is enough to iterate over the bytes until the flag bit set to 0, for every byte the data is added to the accumulated value multiplied by 128. s Signed variable length value. temp v temp++ if(temp&1) value= -(temp>>1) else value= (temp>>1) Figure 2: Variable Length Signed Value The signed values are encoded as the absolute value multiplied by 2, positive numbers have 1 subtracted to the value. [FIXME: why Niedermayer & Barbato Expires March 28, 2008 [Page 4] Internet-Draft NUT Container Format September 2007 not just shift&sign] vb Variable length binary data (or utf-8 string). length v for(i=0; i