# mp4

[![release](https://git.martin-riedl.de/golang/mp4/badges/release.svg)](https://git.martin-riedl.de/golang/mp4/tags)
[![pipeline status](https://git.martin-riedl.de/golang/mp4/badges/workflows/build.yml/badge.svg)](https://git.martin-riedl.de/golang/mp4/actions)

mp4 implementation in golang based on spec ISO/IEC 14496-12:2015

## Parser

```go
parser := mp4.NewParser(file)
if err := parser.Parse(); err != nil {
    panic(err)
}
```

## Progress

Implementation progress of ISO/IEC 14496-12:2015:

| Chapter                                            | Box Types      | Parser |
|----------------------------------------------------|----------------|-------:|
| 4.3 File Type Box                                  | ftyp           |   100% |
| 8.1.1 Media Data Box                               | mdat           |   100% |
| 8.1.2 Free Space Box                               | free, skip     |      - |
| 8.1.3 Progressive Download Information Box         | pdin           |      - |
| 8.2.1 Movie Box                                    | moov           |   100% |
| 8.2.2 Movie Header Box                             | mvhd           |   100% |
| 8.3.1 Track Box                                    | trak           |   100% |
| 8.3.2 Track Header Box                             | tkhd           |   100% |
| 8.3.3 Track Reference Box                          | tref           |      - |
| 8.3.4 Track Group Box                              | trgr           |      - |
| 8.4.1 Media Box                                    | mdia           |   100% |
| 8.4.2 Media Header Box                             | mdhd           |    80% |
| 8.4.3 Handler Reference Box                        | hdlr           |   100% |
| 8.4.4 Media Information Box                        | minf           |   100% |
| 8.4.5.2 Null Media Header Box                      | nmhd           |      - |
| 8.4.6 Extended language tag                        | elng           |      - |
| 8.5.1 Sample Table Box                             | stbl           |   100% |
| 8.5.2 Sample Description Box                       | stsd           |   100% |
| 8.5.3 Degradation Priority Box                     | stdp           |      - |
| 8.6.1.2 Decoding Time to Sample Box                | stts           |   100% |
| 8.6.1.3 Composition Time to Sample Box             | ctts           |      - |
| 8.6.1.4 Composition to Decode Box                  | cslg           |      - |
| 8.6.2 Sync Sample Box                              | stss           |      - |
| 8.6.3 Shadow Sync Sample Box                       | stsh           |      - |
| 8.6.4 Independent and Disposable Samples Box       | sdtp           |      - |
| 8.6.5 Edit Box                                     | edts           |      - |
| 8.6.6 Edit List Box                                | elst           |      - |
| 8.7.1 Data Information Box                         | dinf           |   100% |
| 8.7.2 Data Reference Box                           | dref, url, urn |   100% |
| 8.7.3 Sample Size Boxes                            | stsz, stz2     |    50% |
| 8.7.4 Sample To Chunk Box                          | stsc           |   100% |
| 8.7.5 Chunk Offset Box                             | stco, co64     |    50% |
| 8.7.6 Padding Bits Box                             | padb           |      - |
| 8.7.7 Sub-Sample Information Box                   | subs           |      - |
| 8.7.8 Sample Auxiliary Information Sizes Box       | saiz           |      - |
| 8.7.9 Sample Auxiliary Information Offsets Box     | saio           |      - |
| 8.8.1 Movie Extends Box                            | mvex           |   100% |
| 8.8.2 Movie Extends Header Box                     | mehd           |      - |
| 8.8.3 Track Extends Box                            | trex           |   100% |
| 8.8.4 Movie Fragment Box                           | moof           |   100% |
| 8.8.5 Movie Fragment Header Box                    | mfhd           |   100% |
| 8.8.6 Track Fragment Box                           | traf           |   100% |
| 8.8.7 Track Fragment Header Box                    | tfhd           |    20% |
| 8.8.8 Track Fragment Run Box                       | traf           |   100% |
| 8.8.9 Movie Fragment Random Access Box             | mfra           |      - |
| 8.8.10 Track Fragment Random Access Box            | tfra           |      - |
| 8.8.11 Movie Fragment Random Access Offset Box     | mfro           |      - |
| 8.8.12 Track fragment decode time                  | tfdt           |   100% |
| 8.8.13 Level Assignment Box                        | leva           |      - |
| 8.8.15 Track Extension Properties Box              | trep           |      - |
| 8.8.16 Alternative Startup Sequence Properties Box | assp           |      - |
| 8.9.2 Sample to Group Box                          | sbgp           |      - |
| 8.9.3 Sample Group Description Box                 | sgpd           |      - |
| 8.10.1 User Data Box                               | udta           |      - |
| 8.10.2 Copyright Box                               | cprt           |      - |
| 8.10.3 Track Selection Box                         | tsel           |      - |
| 8.10.4 Track kind                                  | kind           |      - |
| 8.11.1 The Meta box                                | meta           |      - |
| 8.11.2 XML Boxes                                   | xml, bxml      |      - |
| 8.11.3 The Item Location Box                       | iloc           |      - |
| 8.11.4 Primary Item Box                            | pitm           |      - |
| 8.11.5 Item Protection Box                         | ipro           |      - |
| 8.11.6 Item Information Box                        | iinf           |      - |
| 8.11.7 Additional Metadata Container Box           | meco           |      - |
| 8.11.8 Metabox Relation Box                        | mere           |      - |
| 8.11.11 Item Data Box                              | idat           |      - |
| 8.11.12 Item Reference Box                         | iref           |      - |
| 8.12.1 Protection Scheme Information Box           | sinf           |      - |
| 8.12.2 Original Format Box                         | frma           |      - |
| 8.12.5 Scheme Type Box                             | schm           |      - |
| 8.12.6 Scheme Information Box                      | schi           |      - |
| 8.13.2 FD Item Information Box                     | fiin           |      - |
| 8.13.3 File Partition Box                          | fpar           |      - |
| 8.13.4 FEC Reservoir Box                           | fecr           |      - |
| 8.13.5 FD Session Group Box                        | segr           |      - |
| 8.13.6 Group ID to Name Box                        | gitn           |      - |
| 8.13.7 File Reservoir Box                          | fire           |      - |
| 8.14.3 Sub Track box                               | strk           |      - |
| 8.14.4 Sub Track Information box                   | stri           |      - |
| 8.14.5 Sub Track Definition box                    | strd           |      - |
| 8.14.6 Sub Track Sample Group box                  | stsg           |      - |
| 8.15.3 Restricted Scheme Information box           | rinf           |      - |
| 8.15.4.2 Stereo video box                          | stvi           |      - |
| 8.16.2 Segment Type Box                            | styp           |      - |
| 8.16.3 Segment Index Box                           | sidx           |      - |
| 8.16.4 Subsegment Index Box                        | ssix           |      - |
| 8.16.5 Producer Reference Time Box                 | prft           |      - |
| 8.17.3 Complete Track Information Box              | cinf           |      - |
| 9.1.2.1 SRTP Process box                           | srpp           |      - |
| 9.2.4.7 FEC Information Box                        | feci           |      - |
| 12.1.2 Video media header                          | vmhd           |   100% |
| 12.2.1 Media handler                               | soun           |      - |
| 12.2.2 Sound media header                          | smhd           |      - |
| 12.2.4 Channel layout                              | chnl           |      - |
| 12.2.5 Downmix Instructions                        | dmix           |      - |
| 12.2.7 Audio stream loudness                       | ludt           |      - |
| 12.4.2 Hint Media Header Box                       | hmhd           |      - |

Implementation progress of ISO/IEC 14496-15:2017:

| Chapter                                            | Box Types                                | Parser |
|----------------------------------------------------|------------------------------------------|-------:|
| 5.4.2 AVC video stream definition                  | avc1, avc2, avc3, avc4, avcC, m4ds, btrt |    10% |

## Helper Tools

- [Online MP4 file parser](https://www.onlinemp4parser.com/)
