-
Notifications
You must be signed in to change notification settings - Fork 1
/
doc.go
56 lines (34 loc) · 1.76 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
Package mp4 - library for parsing and writing MP4/ISOBMFF files with a focus on fragmented files.
Most boxes have their own file named after the box four-letter name in the ISO/IEC 14996-12 standard,
but in some cases, there may be multiple boxes that have the same content, and the code is then having a
generic name like visualsampleentry.go.
The Box interface is specified in box.go. It decodes box size and type in the box header and
dispatched decode for each individual box depending on its type.
Implement a new box
To implement a new box "fooo", the following is needed:
Create a file fooo.go and with struct type FoooBox.
FoooBox should then implement the Box interface methods:
Type()
Size()
Encode()
Info()
but also its own decode method `DecodeFooo`, and register that method in the `decoders` map in `box.go`.
For a simple example, look at the `prft` box in `prft.go`.
Container Boxes
Container boxes like moof, have a list of all their children called Children,
but also direct pointers to the children with appropriate names,
like Mfhd and Traf. This makes it easy to chain box paths to reach an
element like a TfhdBox as
file.Moof.Traf.Tfhd
When there may be multiple children with the same name, there may be both a
pointer to a slice Trafs with all boxes and Traf that points to the first.
Media Sample Data Structures
To handle media sample data there are two structures:
1. `Sample` stores the sample information used in trun
2. `FullSample` also carries a slice with the samples binary data as well as decode time
Fragmenting segments
A MediaSegment can be fragmented into multiple fragments by the method
func (s *MediaSegment) Fragmentify(timescale uint64, trex *TrexBox, duration uint32) ([]*Fragment, error)
*/
package mp4