aboutsummaryrefslogtreecommitdiff
path: root/box.go
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-02-16 06:05:26 +0100
committerOnur Gündüz <ogunduz@gmail.com>2026-02-16 06:05:26 +0100
commitfacc870d1dfbe59867e48da07a5b88c42571ed1d (patch)
tree1b65a0525ba3199925df520228ed2640d28b88e4 /box.go
parent99431d8e390ee1e2bee3eced47ba79c57698d822 (diff)
downloadmp4-facc870d1dfbe59867e48da07a5b88c42571ed1d.tar.gz
mp4-facc870d1dfbe59867e48da07a5b88c42571ed1d.zip
Enhance documentation for box types and their purposes
Diffstat (limited to 'box.go')
-rw-r--r--box.go158
1 files changed, 89 insertions, 69 deletions
diff --git a/box.go b/box.go
index aaff9fd..9b56423 100644
--- a/box.go
+++ b/box.go
@@ -10,75 +10,95 @@ func (t BoxType) String() string {
// Known box types.
var (
- TypeFtyp = BoxType{'f', 't', 'y', 'p'}
- TypeStyp = BoxType{'s', 't', 'y', 'p'} // Segment type box (used in fragmented MP4)
- TypeMoov = BoxType{'m', 'o', 'o', 'v'}
- TypeMvhd = BoxType{'m', 'v', 'h', 'd'}
- TypeTrak = BoxType{'t', 'r', 'a', 'k'}
- TypeTkhd = BoxType{'t', 'k', 'h', 'd'}
- TypeTref = BoxType{'t', 'r', 'e', 'f'}
- TypeTrgr = BoxType{'t', 'r', 'g', 'r'}
- TypeEdts = BoxType{'e', 'd', 't', 's'}
- TypeElst = BoxType{'e', 'l', 's', 't'}
- TypeMdia = BoxType{'m', 'd', 'i', 'a'}
- TypeMdhd = BoxType{'m', 'd', 'h', 'd'}
- TypeHdlr = BoxType{'h', 'd', 'l', 'r'}
- TypeElng = BoxType{'e', 'l', 'n', 'g'}
- TypeMinf = BoxType{'m', 'i', 'n', 'f'}
- TypeVmhd = BoxType{'v', 'm', 'h', 'd'}
- TypeSmhd = BoxType{'s', 'm', 'h', 'd'}
- TypeHmhd = BoxType{'h', 'm', 'h', 'd'}
- TypeSthd = BoxType{'s', 't', 'h', 'd'}
- TypeNmhd = BoxType{'n', 'm', 'h', 'd'}
- TypeDinf = BoxType{'d', 'i', 'n', 'f'}
- TypeDref = BoxType{'d', 'r', 'e', 'f'}
- TypeStbl = BoxType{'s', 't', 'b', 'l'}
- TypeStsd = BoxType{'s', 't', 's', 'd'}
- TypeStts = BoxType{'s', 't', 't', 's'}
- TypeCtts = BoxType{'c', 't', 't', 's'}
- TypeCslg = BoxType{'c', 's', 'l', 'g'}
- TypeStsc = BoxType{'s', 't', 's', 'c'}
- TypeStsz = BoxType{'s', 't', 's', 'z'}
- TypeStz2 = BoxType{'s', 't', 'z', '2'}
- TypeStco = BoxType{'s', 't', 'c', 'o'}
- TypeCo64 = BoxType{'c', 'o', '6', '4'}
- TypeStss = BoxType{'s', 't', 's', 's'}
- TypeStsh = BoxType{'s', 't', 's', 'h'}
- TypePadb = BoxType{'p', 'a', 'd', 'b'}
- TypeStdp = BoxType{'s', 't', 'd', 'p'}
- TypeSdtp = BoxType{'s', 'd', 't', 'p'}
- TypeSbgp = BoxType{'s', 'b', 'g', 'p'}
- TypeSgpd = BoxType{'s', 'g', 'p', 'd'}
- TypeSubs = BoxType{'s', 'u', 'b', 's'}
- TypeSaiz = BoxType{'s', 'a', 'i', 'z'}
- TypeSaio = BoxType{'s', 'a', 'i', 'o'}
- // Fragment movie boxes
- TypeMvex = BoxType{'m', 'v', 'e', 'x'}
- TypeMehd = BoxType{'m', 'e', 'h', 'd'}
- TypeTrex = BoxType{'t', 'r', 'e', 'x'}
- TypeLeva = BoxType{'l', 'e', 'v', 'a'}
- TypeMoof = BoxType{'m', 'o', 'o', 'f'}
- TypeMfhd = BoxType{'m', 'f', 'h', 'd'}
- TypeTraf = BoxType{'t', 'r', 'a', 'f'}
- TypeTfhd = BoxType{'t', 'f', 'h', 'd'}
- TypeTfdt = BoxType{'t', 'f', 'd', 't'}
- TypeTrun = BoxType{'t', 'r', 'u', 'n'}
- TypeSidx = BoxType{'s', 'i', 'd', 'x'} // Segment index box
- TypeEmsg = BoxType{'e', 'm', 's', 'g'} // Event message box
- // Metadata boxes
- TypeMeta = BoxType{'m', 'e', 't', 'a'}
- TypeUdta = BoxType{'u', 'd', 't', 'a'}
- // Data boxes
- TypeMdat = BoxType{'m', 'd', 'a', 't'}
- TypeFree = BoxType{'f', 'r', 'e', 'e'}
- TypeSkip = BoxType{'s', 'k', 'i', 'p'}
- // Sample entry boxes
- TypeAvc1 = BoxType{'a', 'v', 'c', '1'}
- TypeAvcC = BoxType{'a', 'v', 'c', 'C'}
- TypeBtrt = BoxType{'b', 't', 'r', 't'} // MPEG-4 Bit rate box
- TypePasp = BoxType{'p', 'a', 's', 'p'} // Pixel aspect ratio box
- TypeMp4a = BoxType{'m', 'p', '4', 'a'}
- TypeEsds = BoxType{'e', 's', 'd', 's'}
+ TypeFtyp = BoxType{'f', 't', 'y', 'p'} // File type and compatibility
+ TypeStyp = BoxType{'s', 't', 'y', 'p'} // Segment type (fragmented MP4)
+)
+
+// Movie structure boxes (moov and children).
+var (
+ TypeMoov = BoxType{'m', 'o', 'o', 'v'} // Movie metadata container
+ TypeMvhd = BoxType{'m', 'v', 'h', 'd'} // Movie header (timescale, duration)
+ TypeTrak = BoxType{'t', 'r', 'a', 'k'} // Track container
+ TypeTkhd = BoxType{'t', 'k', 'h', 'd'} // Track header (ID, dimensions)
+ TypeTref = BoxType{'t', 'r', 'e', 'f'} // Track reference container
+ TypeTrgr = BoxType{'t', 'r', 'g', 'r'} // Track grouping indication
+ TypeEdts = BoxType{'e', 'd', 't', 's'} // Edit list container
+ TypeElst = BoxType{'e', 'l', 's', 't'} // Edit list entries
+ TypeMdia = BoxType{'m', 'd', 'i', 'a'} // Media information container
+ TypeMdhd = BoxType{'m', 'd', 'h', 'd'} // Media header (timescale, duration)
+ TypeHdlr = BoxType{'h', 'd', 'l', 'r'} // Handler reference (vide/soun)
+ TypeElng = BoxType{'e', 'l', 'n', 'g'} // Extended language tag
+ TypeMinf = BoxType{'m', 'i', 'n', 'f'} // Media information container
+ TypeVmhd = BoxType{'v', 'm', 'h', 'd'} // Video media header
+ TypeSmhd = BoxType{'s', 'm', 'h', 'd'} // Sound media header
+ TypeHmhd = BoxType{'h', 'm', 'h', 'd'} // Hint media header
+ TypeSthd = BoxType{'s', 't', 'h', 'd'} // Subtitle media header
+ TypeNmhd = BoxType{'n', 'm', 'h', 'd'} // Null media header
+ TypeDinf = BoxType{'d', 'i', 'n', 'f'} // Data information container
+ TypeDref = BoxType{'d', 'r', 'e', 'f'} // Data reference (URL/URN entries)
+)
+
+// Sample table boxes (stbl children).
+var (
+ TypeStbl = BoxType{'s', 't', 'b', 'l'} // Sample table container
+ TypeStsd = BoxType{'s', 't', 's', 'd'} // Sample descriptions (codec config)
+ TypeStts = BoxType{'s', 't', 't', 's'} // Decoding time-to-sample
+ TypeCtts = BoxType{'c', 't', 't', 's'} // Composition time-to-sample
+ TypeCslg = BoxType{'c', 's', 'l', 'g'} // Composition to decode timeline mapping
+ TypeStsc = BoxType{'s', 't', 's', 'c'} // Sample-to-chunk mapping
+ TypeStsz = BoxType{'s', 't', 's', 'z'} // Sample sizes
+ TypeStz2 = BoxType{'s', 't', 'z', '2'} // Compact sample sizes
+ TypeStco = BoxType{'s', 't', 'c', 'o'} // Chunk offsets (32-bit)
+ TypeCo64 = BoxType{'c', 'o', '6', '4'} // Chunk offsets (64-bit)
+ TypeStss = BoxType{'s', 't', 's', 's'} // Sync sample table (keyframes)
+ TypeStsh = BoxType{'s', 't', 's', 'h'} // Shadow sync sample table
+ TypePadb = BoxType{'p', 'a', 'd', 'b'} // Padding bits
+ TypeStdp = BoxType{'s', 't', 'd', 'p'} // Sample degradation priority
+ TypeSdtp = BoxType{'s', 'd', 't', 'p'} // Sample dependency type
+ TypeSbgp = BoxType{'s', 'b', 'g', 'p'} // Sample-to-group
+ TypeSgpd = BoxType{'s', 'g', 'p', 'd'} // Sample group description
+ TypeSubs = BoxType{'s', 'u', 'b', 's'} // Sub-sample information
+ TypeSaiz = BoxType{'s', 'a', 'i', 'z'} // Sample auxiliary information sizes
+ TypeSaio = BoxType{'s', 'a', 'i', 'o'} // Sample auxiliary information offsets
+)
+
+// Fragment boxes (moof and children, mvex).
+var (
+ TypeMvex = BoxType{'m', 'v', 'e', 'x'} // Movie extends (signals fragmented file)
+ TypeMehd = BoxType{'m', 'e', 'h', 'd'} // Movie extends header (fragment duration)
+ TypeTrex = BoxType{'t', 'r', 'e', 'x'} // Track extends defaults
+ TypeLeva = BoxType{'l', 'e', 'v', 'a'} // Level assignment
+ TypeMoof = BoxType{'m', 'o', 'o', 'f'} // Movie fragment container
+ TypeMfhd = BoxType{'m', 'f', 'h', 'd'} // Movie fragment header (sequence number)
+ TypeTraf = BoxType{'t', 'r', 'a', 'f'} // Track fragment container
+ TypeTfhd = BoxType{'t', 'f', 'h', 'd'} // Track fragment header
+ TypeTfdt = BoxType{'t', 'f', 'd', 't'} // Track fragment decode time
+ TypeTrun = BoxType{'t', 'r', 'u', 'n'} // Track run (per-sample metadata)
+ TypeSidx = BoxType{'s', 'i', 'd', 'x'} // Segment index
+ TypeEmsg = BoxType{'e', 'm', 's', 'g'} // Event message
+)
+
+// Metadata boxes.
+var (
+ TypeMeta = BoxType{'m', 'e', 't', 'a'} // Metadata container
+ TypeUdta = BoxType{'u', 'd', 't', 'a'} // User data container
+)
+
+// Data boxes.
+var (
+ TypeMdat = BoxType{'m', 'd', 'a', 't'} // Media data payload
+ TypeFree = BoxType{'f', 'r', 'e', 'e'} // Free space (can be skipped)
+ TypeSkip = BoxType{'s', 'k', 'i', 'p'} // Free space (can be skipped)
+)
+
+// Sample entry boxes (children of stsd).
+var (
+ TypeAvc1 = BoxType{'a', 'v', 'c', '1'} // AVC/H.264 visual sample entry
+ TypeAvcC = BoxType{'a', 'v', 'c', 'C'} // AVC decoder configuration record
+ TypeBtrt = BoxType{'b', 't', 'r', 't'} // MPEG-4 bit rate
+ TypePasp = BoxType{'p', 'a', 's', 'p'} // Pixel aspect ratio
+ TypeMp4a = BoxType{'m', 'p', '4', 'a'} // MPEG-4 audio sample entry
+ TypeEsds = BoxType{'e', 's', 'd', 's'} // ES descriptor
)
// IsFullBox returns true if the box type has version and flags fields.