aboutsummaryrefslogtreecommitdiff
path: root/scanner.go
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-02-16 06:56:58 +0100
committerOnur Gündüz <ogunduz@gmail.com>2026-02-16 06:56:58 +0100
commit1034f4d97732e3788dc67edae97ca6030b2934c8 (patch)
tree3270deaf4d7fa89ea0cb763ac9d0d7e9b258fd80 /scanner.go
parent7366f91c9a735b16c70dfc2c5c65ba6651497ecc (diff)
downloadmp4-1034f4d97732e3788dc67edae97ca6030b2934c8.tar.gz
mp4-1034f4d97732e3788dc67edae97ca6030b2934c8.zip
Improve documentation
Diffstat (limited to 'scanner.go')
-rw-r--r--scanner.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/scanner.go b/scanner.go
index 30c3098..4169f1f 100644
--- a/scanner.go
+++ b/scanner.go
@@ -1,4 +1,4 @@
-package bmff
+package mp4
import "io"
@@ -15,21 +15,26 @@ func (e ScanEntry) DataSize() int64 {
return e.Size - int64(e.HeaderSize)
}
-// Scanner reads top-level box headers from an io.ReadSeeker without
-// loading box contents into memory. This lets callers discover box
-// positions and sizes, then selectively read only the boxes they need
-// (e.g. moov) into a buffer for parsing with NewReader.
+// DataOffset returns the byte offset where the box data begins (after the header).
+// Use it with [io.ReaderAt.ReadAt] to read box data without seeking.
+func (e ScanEntry) DataOffset() int64 {
+ return e.Offset + int64(e.HeaderSize)
+}
+
+// Scanner reads top-level box headers from an [io.ReadSeeker] without loading
+// box contents into memory. Use it to discover box positions and sizes, then
+// selectively read only the boxes you need.
//
// Typical usage:
//
// f, _ := os.Open("video.mp4")
-// sc := bmff.NewScanner(f)
+// sc := mp4.NewScanner(f)
// for sc.Next() {
// e := sc.Entry()
-// if e.Type == bmff.TypeMoov {
+// if e.Type == mp4.TypeMoov {
// buf := make([]byte, e.DataSize())
// sc.ReadBody(buf)
-// r := bmff.NewReader(buf)
+// r := mp4.NewReader(buf)
// // parse moov contents...
// }
// }