Skip to content

Commit

Permalink
Merge pull request #57 from edgeware/v0-17
Browse files Browse the repository at this point in the history
Version 0.17.0
  • Loading branch information
tobbee authored Jan 15, 2021
2 parents de299d1 + cb68d66 commit 7cd86bd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions Versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

| Version | Highlight |
| ------ | --------- |
| 0.17.0 | HEVC support and new tool mp4ff-nallister |
| 0.16.2 | fix: Minor fixes to sampleNumber and tfhd Info |
| 0.16.1 | fix: isNonSync flag declaration and use sdtp values in segmenter example |
| 0.16.0 | New mp4ff-info tool. Many new boxes incl. encryption boxes and sdtp. ADTS support. Test improvements with golden files |
Expand Down
33 changes: 29 additions & 4 deletions cmd/mp4ff-nallister/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// mp4ff-nallister lists NAL units and slice types of first AVC or HEVC track of an mp4 (ISOBMFF) file.
// mp4ff-nallister - list NAL units and slice types of first AVC or HEVC track of an mp4 (ISOBMFF) file.
package main

import (
Expand All @@ -24,7 +24,7 @@ var Usage = func() {
parts := strings.Split(os.Args[0], "/")
name := parts[len(parts)-1]
fmt.Fprintln(os.Stderr, usg)
fmt.Fprintf(os.Stderr, "%s [-m <max>] <mp4File>\n", name)
fmt.Fprintf(os.Stderr, "%s [-m <max>] [-c codec] <mp4File>\n", name)
flag.PrintDefaults()
}

Expand Down Expand Up @@ -78,10 +78,15 @@ func parseProgressiveMp4(f *mp4.File, maxNrSamples int, codec string) error {
break
}
if videoTrak == nil {
return fmt.Errorf("New video track found")
return fmt.Errorf("No video track found")
}

stbl := videoTrak.Mdia.Minf.Stbl
if stbl.Stsd.AvcX != nil {
codec = "avc"
} else if stbl.Stsd.HvcX != nil {
codec = "hevc"
}
nrSamples := stbl.Stsz.SampleNumber
mdat := f.Mdat
mdatPayloadStart := mdat.PayloadAbsoluteOffset()
Expand All @@ -103,7 +108,6 @@ func parseProgressiveMp4(f *mp4.File, maxNrSamples int, codec string) error {
// Next find sample bytes as slice in mdat
offsetInMdatData := uint64(offset) - mdatPayloadStart
sample := mdat.Data[offsetInMdatData : offsetInMdatData+uint64(size)]
err = printAVCNalus(sample, sampleNr, decTime+uint64(cto))
switch codec {
case "avc", "h.264", "h264":
err = printAVCNalus(sample, sampleNr, decTime+uint64(cto))
Expand All @@ -123,6 +127,27 @@ func parseProgressiveMp4(f *mp4.File, maxNrSamples int, codec string) error {
}

func parseFragmentedMp4(f *mp4.File, maxNrSamples int, codec string) error {
if f.Init != nil { // Auto-detect codec if moov box is there
moov := f.Init.Moov
var videoTrak *mp4.TrakBox
for _, inTrak := range moov.Traks {
hdlrType := inTrak.Mdia.Hdlr.HandlerType
if hdlrType != "vide" {
continue
}
videoTrak = inTrak
break
}
if videoTrak == nil {
return fmt.Errorf("No video track found")
}
stbl := videoTrak.Mdia.Minf.Stbl
if stbl.Stsd.AvcX != nil {
codec = "avc"
} else if stbl.Stsd.HvcX != nil {
codec = "hevc"
}
}
iSamples := make([]*mp4.FullSample, 0)
for _, iSeg := range f.Segments {
for _, iFrag := range iSeg.Fragments {
Expand Down

0 comments on commit 7cd86bd

Please sign in to comment.