Soft coded FLV to MP4 container (iv) Fmp4 Overview and basic explanation __ coding

Source: Internet
Author: User
Tags reserved uuid
Https://github.com/332065255/flv2fmp4 code Base

Soft coded FLV to MP4 container (i)
Soft coded FLV to MP4 container (ii) FLV tag Dismantling
Soft coded FLV to MP4 container (iii) FLV METADATA tag parsing
Soft coded FLV to MP4 container (iv) Fmp4 Overview and basic explanation
Soft coded FLV to MP4 container (v) Fmp4 Ftyp box and Moov>mvhd Box detailed
Soft coded FLV to MP4 container (vi) Fmp4 MOOV>TRAK>TKHD box and MOOV>TRAK>MDIA>MDHD box explain
Soft coded FLV to MP4 container (vii) Fmp4 MDIA>HDLR box and mdia>minf> smhd and Dinf box explain
Soft coded FLV to MP4 container (eight) Fmp4 mdia>stbl>stsd box explain
Soft coded FLV to MP4 container (ix) fmp4 stts stsc stsz Stco Box explain
Soft coded FLV to MP4 container (10) Fmp4 Mvex Box explain
Soft coded FLV to MP4 container (11) Fmp4 moof Box detailed
Soft coded FLV to MP4 container (12) Fmp4 Mdat Box detailed
Soft coded FLV to MP4 container (13) Fmp4 The FLV data necessary to generate Ftyp and Moov

First, agree on a few definitions

1, documents, by many box and fullbox composition.
2, box, each box by header and data composition.
3, Fullbox, is the expansion of box, box structure on the basis of the header added 8bits version and 24bits flags.

4, Header, contains the length of the entire box size and type.
When Size==0, this is the last box in the file; When size==1, it means that the box length requires more bits to describe, followed by a 64bits largesize describing the length of the box, and when type is a UUID, The data on behalf of box is a user-defined extension type.
5, data, is the actual box, can be pure data can also be more boxes.
6, when a box of data is a series of child box, this box can become container box.

Container box means container box, which will contain more box, representing Moov box.
Full box is a single box that contains no more box, representing Mvhd box.
Full box consists of the following: 4 byte length + 4 bytes Box type+1 byte version +3 byte reservation + various box-specific content

The standard box begins with 4 bytes (32 bits) for box size, which includes the box header and the size of the box body, so that we can locate each box in the file. If the size is 1, the box is large size and the true size value is obtained on the Largesize field. (In fact, only "mdat" types of box can use the large size.) If the size is 0, the box is the last box of the file, and the end of the box is the ending. (also exists only in "Mdat" type box.) )
The 32-bit followed by the size of box type, typically 4 characters, such as "Ftyp", "Moov", and so on, these box type are predefined, respectively, to indicate the meaning of the fixed. If it is "UUID", the box is a user-extended type. If the box type is undefined, it should be ignored.

The following is a standard MP4 opening binary code

00000000h:00 1C to $  6D (a     );       

            1c length   f   t  y  p     m  p   4  2      0   0 0 0

00000010h:6d 70 34 32  6D to the     6F 6D     ; 
            These 12 bytes indicate a compatible brand       to this 28 byte end   0x463 for 1123
                                        ftyp box end
            m  p  4  2   m  p  4  1      i  s  o  m

00000020h:6d 6F 6F for  6C     6D     , 
           at the same. M   o  v   6c for 108        m  v  h  d
                                        mvhd box for Fullbox, so 0x00000000 for content
Moov is the container, so the latter 4 bytes are the length of the next box

MVHD box content is more cumbersome, not all posted out, the following is the official MP4 document MVHD detailed instructions

Aligned (8) class Movieheaderbox extends Fullbox (' mvhd ', version, 0) 
{ 
    if (version==1) {
   unsigned int (64)  Creation_time;
   unsigned int ()  modification_time;
   unsigned int ()  timescale;
   unsigned int ()  duration;
} else {//version==0
   unsigned int ()  creation_time;
   unsigned int ()  modification_time;
   unsigned int ()  timescale;
   unsigned int ()  duration;
}
template int ()  rate = 0x00010000;//
template int ()  volume = 0x0100;
const bit  reserved = 0;
const unsigned int (a) [2]  reserved = 0;
template int [9]  matrix =
typically 1.0
typically, full volume
{0x00010000,0,0,0,0x00010000, 0,0,0,0x40000000};
      Unity matrix
   bit [6]  pre_defined = 0;
   unsigned int ()  next_track_id;
}

A normal Fmp4 file and his box sort is the case below

-Ftyp-
 moov
     -mvhd
     -Trak
         -TKHD-
         Mdia-MDHD-
             hdlr
             -minf
                 -SMHD
                 -dinf
  
   -dref
                         -url
                 -stbl
                     -  stsd
                         -mp4a (AVC1)
                             -Esds (AvcC)
                     -
                     Stts-STSC- Stsz
                     -Stco


     -Mvex
        -trex
 -moof
    -MFHD
    -Traf
        -tfhd
        --TFDT-SDTP- Trun
 -Mdat
  

Visible from the above illustration. Fmp4 box is very complex, so this series of blogs is a step-by-step approach to the case of each box. in this chapter, we mainly explain the box composition of box and Fmp4 . In the next chapter we will explain the details of mvhd in Ftyp and Moov in Fmp4 .

Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.