diff --git a/mp4.go b/mp4.go index f18aed1..c83275c 100644 --- a/mp4.go +++ b/mp4.go @@ -69,7 +69,7 @@ func ReadAtoms(r io.ReadSeeker) (Metadata, error) { return m, err } -func (m metadataMP4) readAtoms(r io.Reader) error { +func (m metadataMP4) readAtoms(r io.ReadSeeker) error { for { var size uint32 err := binary.Read(r, binary.BigEndian, &size) @@ -96,7 +96,10 @@ func (m metadataMP4) readAtoms(r io.Reader) error { case "moov", "udta", "ilst": return m.readAtoms(r) case "free": - discardN(r, int64(size-8)) + _, err := r.Seek(int64(size-8), os.SEEK_CUR) + if err != nil { + return err + } continue case "mdat": // stop when we get to the data return nil diff --git a/util.go b/util.go index f01636e..5087ce8 100644 --- a/util.go +++ b/util.go @@ -6,14 +6,8 @@ package tag import ( "io" - "io/ioutil" ) -func discardN(r io.Reader, n int64) error { - _, err := io.CopyN(ioutil.Discard, r, n) - return err -} - func getBit(b byte, n uint) bool { x := byte(1 << n) return (b & x) == x