aboutsummaryrefslogtreecommitdiff
path: root/cmd/mp4probe
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-02-13 08:07:38 +0100
committerOnur Gündüz <ogunduz@gmail.com>2026-02-13 08:07:38 +0100
commit8502816a943bb33705a7775838c760ed72046ae8 (patch)
tree0239df7a4df76414e59956bd679b32eb40054a6c /cmd/mp4probe
parent34bb3e8c7e644ad8fb3d8546f68595d76b85cd00 (diff)
downloadmp4-8502816a943bb33705a7775838c760ed72046ae8.tar.gz
mp4-8502816a943bb33705a7775838c760ed72046ae8.zip
Remove remuxer
Diffstat (limited to 'cmd/mp4probe')
-rw-r--r--cmd/mp4probe/main.go121
1 files changed, 0 insertions, 121 deletions
diff --git a/cmd/mp4probe/main.go b/cmd/mp4probe/main.go
deleted file mode 100644
index eb163bb..0000000
--- a/cmd/mp4probe/main.go
+++ /dev/null
@@ -1,121 +0,0 @@
-// Command mp4probe gathers information about tracks and keyframe distribution from an MP4 file.
-package main
-
-import (
- "fmt"
- "os"
-
- "github.com/tetsuo/mp4/remux"
-)
-
-func main() {
- if len(os.Args) < 2 {
- fmt.Fprintf(os.Stderr, "usage: %s <file.mp4>\n", os.Args[0])
- os.Exit(1)
- }
-
- f, err := os.Open(os.Args[1])
- if err != nil {
- fmt.Fprintf(os.Stderr, "error: %v\n", err)
- os.Exit(1)
- }
- defer f.Close()
-
- remuxer, err := remux.NewRemuxer(f)
- if err != nil {
- fmt.Fprintf(os.Stderr, "error: %v\n", err)
- os.Exit(1)
- }
-
- for i, track := range remuxer.Tracks {
- fmt.Printf("Track %d: %s\n", i, track.Codec)
- fmt.Printf(" Total samples: %d\n", len(track.Samples))
- fmt.Printf(" Duration: %.2fs\n", track.Duration())
- fmt.Printf(" TimeScale: %d\n\n", track.TimeScale)
-
- // Count keyframes
- keyframes := 0
- var prevKfTime float64
- var intervals []float64
-
- fmt.Println(" Keyframes:")
- for j, s := range track.Samples {
- if s.Sync {
- pts := float64(s.DTS+int64(s.PresentationOffset)) / float64(track.TimeScale)
- fmt.Printf(" [%5d] %.3fs", j, pts)
-
- if keyframes > 0 {
- interval := pts - prevKfTime
- intervals = append(intervals, interval)
- fmt.Printf(" (%.3fs since last)", interval)
- }
- fmt.Println()
-
- prevKfTime = pts
- keyframes++
-
- if keyframes >= 20 {
- fmt.Printf(" ... (%d more keyframes)\n", countRemainingKeyframes(track.Samples[j+1:]))
- break
- }
- }
- }
-
- fmt.Printf("\n Total keyframes: %d\n", countTotalKeyframes(track.Samples))
- if len(intervals) > 0 {
- avg := average(intervals)
- min := minimum(intervals)
- max := maximum(intervals)
- fmt.Printf(" Keyframe interval: avg=%.3fs min=%.3fs max=%.3fs\n", avg, min, max)
- }
- fmt.Println()
- }
-}
-
-func countRemainingKeyframes(samples []remux.Sample) int {
- count := 0
- for _, s := range samples {
- if s.Sync {
- count++
- }
- }
- return count
-}
-
-func countTotalKeyframes(samples []remux.Sample) int {
- count := 0
- for _, s := range samples {
- if s.Sync {
- count++
- }
- }
- return count
-}
-
-func average(vals []float64) float64 {
- sum := 0.0
- for _, v := range vals {
- sum += v
- }
- return sum / float64(len(vals))
-}
-
-func minimum(vals []float64) float64 {
- min := vals[0]
- for _, v := range vals {
- if v < min {
- min = v
- }
- }
- return min
-}
-
-func maximum(vals []float64) float64 {
- max := vals[0]
- for _, v := range vals {
- if v > max {
- max = v
- }
- }
- return max
-}