Structure of MP4 Files 

MP4 is an extensible container file, meaning that it does not define a strict structure and allows custom structure and hierarchy for each media type. The data in the MP4 file is divided into two sections, the first containing the media-related data and the second containing metadata. The media data contains audio or video and metadata indicate flags for random access, timestamps, etc. The structures in MP4 are typically referred to as atoms or boxes. The minimum size of an atom is 8 bytes(the first 4 bytes specify size and the next 4 bytes specify type). Here is a list of the root level atoms contained in MP files:
  • ftyp: Contains the file type, description, and the common data structures used.
  • pdin: Contains progressive video loading/downloading information.
  • moov: Container for all the movie metadata.
  • moof: Container with video fragments.
  • mfra: The container with random access to the video fragment
  • mdat: Data container for media.
  • stts: sample-to-time table.
  • stsc: sample-to-chunk table.
  • stsz: sample sizes (framing)
  • meta: The container with the metadata information.

[링크 : https://docs.fileformat.com/video/mp4/]

[링크 : http://www.ftyps.com/]

[링크 : https://m.blog.naver.com/yesing1/70096278829]

 

+

22.01.24

[링크 : https://whitesnake1004.tistory.com/710]

 

+

팟 플레이어 메타 정보

General
Complete name                  : C:\file_example_MP4_480_1_5MG.mp4
Format                         : MPEG-4
Format profile                 : Base Media / Version 2
Codec ID                       : mp42 (mp42/mp41/isom/avc1)
File size                      : 1.50 MiB
Duration                       : 30 s 527 ms
Overall bit rate               : 411 kb/s
Encoded date                   : UTC 2015-08-07 09:13:02
Tagged date                    : UTC 2015-08-07 09:13:02

Video
ID                             : 1
Format                         : AVC
Format/Info                    : Advanced Video Codec
Format profile                 : Baseline@L3
Format settings                : 3 Ref Frames
Format settings, CABAC         : No
Format settings, Reference fra : 3 frames
Format settings, GOP           : M=1, N=90
Codec ID                       : avc1
Codec ID/Info                  : Advanced Video Coding
Duration                       : 30 s 33 ms
Bit rate                       : 300 kb/s
Width                          : 480 pixels
Height                         : 270 pixels
Display aspect ratio           : 16:9
Frame rate mode                : Constant
Frame rate                     : 30.000 FPS
Color space                    : YUV
Chroma subsampling             : 4:2:0
Bit depth                      : 8 bits
Scan type                      : Progressive
Bits/(Pixel*Frame)             : 0.077
Stream size                    : 1.08 MiB (72%)
Writing library                : x264 core 146 r11M 121396c
Encoding settings              : cabac=0 / ref=3 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=48 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / stitchable=1 / constrained_intra=0 / bframes=0 / weightp=0 / keyint=infinite / keyint_min=30 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=2pass / mbtree=1 / bitrate=300 / ratetol=1.0 / qcomp=0.60 / qpmin=5 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=330 / vbv_bufsize=360 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Encoded date                   : UTC 2015-08-07 09:13:02
Tagged date                    : UTC 2015-08-07 09:13:02
Codec configuration box        : avcC

Audio
ID                             : 2
Format                         : AAC LC
Format/Info                    : Advanced Audio Codec Low Complexity
Codec ID                       : mp4a-40-2
Duration                       : 30 s 527 ms
Bit rate mode                  : Constant
Bit rate                       : 112 kb/s
Channel(s)                     : 2 channels
Channel layout                 : L R
Sampling rate                  : 48.0 kHz
Frame rate                     : 46.875 FPS (1024 SPF)
Compression mode               : Lossy
Stream size                    : 417 KiB (27%)
Encoded date                   : UTC 2015-08-07 09:13:02
Tagged date                    : UTC 2015-08-07 09:13:02

size(4byte) + fourcc?(4byte) + data 라는 구조로 보면

 

ftyp 구획은 0x20 =32byte이고 이건 size의 4바이트 포함하여, 포맷의 종류를 적어두는 느낌? mp42 mp41 isom avc1

팟 플레이어 파일 정보 에서는 아래와 같이 나온다.

Codec ID                       : mp42 (mp42/mp41/isom/avc1)

 

moov 구획 0x2E30 길이(11824)

인코더의 메타정보 같기도 하고.. L-SMASH Video Handler, L-SMASH Audio Handler 이런 문구가 나온다.

 

free 구획 8 바이트 길이(내용 없음)

 

mdat 구획 0x17c690 (1,558,160 바이트)

 

일단은 mdat 로 끝나도 파일 재생에는 문제 없다.

[링크 : https://file-examples.com/index.php/sample-video-files/sample-mp4-files/]

 

+

moov 는 비디오 데이터의 인덱스 역할을 합니다.
플레이어가 이 인덱스에 접근할때까지 영상은 재생되지 않습니다.
보통 moov는 파일을 설명하는 모든 정보가 생성된 뒤에 파일의 끝에 저장됩니다.

[링크 : https://duzi077.tistory.com/118]

 

moov : 미디어의 모든 메타 데이타를 저장하는 무비 박스 (movie box)
  mvhd: 무비 헤더 박스 (movie header box)
  trak : 무비 안의 단일 트랙을 정의하는 박스 (track box) ------------ 반복 가능
    tkhd : 트랙의 특성을 기술 (track header box)
    edts : (edit box)
      elst : (edit list box)
    mdia : 트랙의 미디어 타입과 샘플 데이타 (media box)
      mdhd : 미디어의 특성을 기술 (media header box)
      hdlr : (handler reference box)
      minf : (media information box)
        hdlr : (handler reference box)
        stbl : (sample table box)
          stsd : 트랙의 디코딩에 필요한 코덱의 정보 (sample description box)
          stts : 샘플의 시간 (time-to-sample box)
          stsz : 청크 내 샘플의 크기 (sample size box)
          stsc : 청크 내 샘플의 수 (sample to chunk box)
          stco : 청크의 위치 (chunk offset box)

[링크 : https://unipro.tistory.com/104]

'이론 관련 > 컴퓨터 관련' 카테고리의 다른 글

SLP - Superword Level Parallelism  (0) 2022.06.02
digital twin  (0) 2022.04.13
current loop to rs232  (0) 2021.10.22
usb dwc  (0) 2021.09.23
fp16  (0) 2021.05.10
Posted by 구차니