aboutsummaryrefslogtreecommitdiff
path: root/writer.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 /writer.go
parent7366f91c9a735b16c70dfc2c5c65ba6651497ecc (diff)
downloadmp4-1034f4d97732e3788dc67edae97ca6030b2934c8.tar.gz
mp4-1034f4d97732e3788dc67edae97ca6030b2934c8.zip
Improve documentation
Diffstat (limited to 'writer.go')
-rw-r--r--writer.go20
1 files changed, 16 insertions, 4 deletions
diff --git a/writer.go b/writer.go
index 8c57e19..3bb111d 100644
--- a/writer.go
+++ b/writer.go
@@ -1,4 +1,4 @@
-package bmff
+package mp4
import "errors"
@@ -10,6 +10,21 @@ type writerFrame struct {
// ErrBoxTooLarge is returned by [Writer.Err] when a box exceeds the 4 GB
// limit for standard (32-bit) box sizes.
var ErrBoxTooLarge = errors.New("mp4: box size exceeds 4GB limit")
+
+// Writer encodes ISOBMFF boxes into the provided buffer.
+//
+// The buffer must be large enough to hold all written data; writes beyond
+// the buffer boundary will panic.
+//
+// Use [Writer.StartBox] and [Writer.EndBox] to write nested boxes:
+//
+// w := mp4.NewWriter(buf)
+// w.StartBox(mp4.TypeMoov)
+// w.WriteMvhd(1000, 30000, 3)
+// w.EndBox()
+// output := w.Bytes()
+//
+// After all writes, check [Writer.Err] for errors.
type Writer struct {
buf []byte
pos int
@@ -414,9 +429,6 @@ func (w *Writer) WriteTfdt(baseMediaDecodeTime uint64) {
w.StartFullBox(TypeTfdt, 0, 0)
w.putUint32(uint32(baseMediaDecodeTime))
}
- // TODO: maybe always use version 1 (64-bit)?
- // w.StartFullBox(TypeTfdt, 1, 0)
- // w.putUint64(baseMediaDecodeTime)
w.EndBox()
}