From 4a5af7a7265164346ff8301579be876d503bf52e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbjo=CC=88rn=20Einarsson?= Date: Fri, 15 Jan 2021 16:44:35 +0100 Subject: [PATCH 1/2] improvement: mp4ff-nallister auto detect codec when moov box is present --- cmd/mp4ff-nallister/main.go | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/cmd/mp4ff-nallister/main.go b/cmd/mp4ff-nallister/main.go index 91eb8ee0..8e962156 100644 --- a/cmd/mp4ff-nallister/main.go +++ b/cmd/mp4ff-nallister/main.go @@ -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 ( @@ -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 ] \n", name) + fmt.Fprintf(os.Stderr, "%s [-m ] [-c codec] \n", name) flag.PrintDefaults() } @@ -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() @@ -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)) @@ -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 { From cb68d66fc0aeb9344ff94795d99317049d1534f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbjo=CC=88rn=20Einarsson?= Date: Fri, 15 Jan 2021 16:49:41 +0100 Subject: [PATCH 2/2] doc: Version 0.17.0 --- Versions.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Versions.md b/Versions.md index 48a80a54..a77f0bb7 100644 --- a/Versions.md +++ b/Versions.md @@ -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 |