From 6da165e1853376a9bffcea945aaff3b89c051b80 Mon Sep 17 00:00:00 2001 From: nareix Date: Sat, 19 Mar 2016 15:46:35 +0800 Subject: [PATCH] Update README.md --- README.md | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bd670b3..2c3abd0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,42 @@ -# Golang mp4 muxer/demuxer +# A pure golang mp4 library -Includes h264/aac track muxer, mp4 atoms reader/writer/dumper +Provides mp4 reader/writer and mp4 atom manipulations functions. -# Examples +Open a mp4 file and read the first sample: +``` +file, _ := os.Open("test.mp4") +demuxer := &mp4.Demuxer{R: file} +demuxer.ReadHeader() +pts, dts, isKeyFrame, data, err := demuxer.TrackH264.ReadSample() +``` + +do some seeking: + +``` +demuxer.TrackH264.SeekToTime(2.0) +``` + +demuxer demo code [here](https://github.com/nareix/mp4/blob/master/example/example.go#L11) + +the library also provide atom struct decoding/encoding functions( +learn more about mp4 atoms [here](https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html) +) + +you can access atom structs via `Demuxer.TrackH264.TrackAtom`. for example: + +``` +// Get the raw TimeScale field inside `mvhd` atom +fmt.Println(demuxer.TrackH264.TrackAtom.Media.Header.TimeScale) +``` + +for more see Atom API Docs + +# Documentation + +[API Docs](https://godoc.org/github.com/nareix/mp4) + +[Atom API Docs](https://godoc.org/github.com/nareix/mp4/atom) + + +## Atoms manipulation -[Demuxer example](https://github.com/nareix/mp4/blob/master/example/example.go#L11)