Documentation
¶
Overview ¶
Package bmff reads ISOBMFF boxes, as used by HEIF, AVIF, CR3, etc. and other riff based files
Index ¶
- Variables
- func DebugLogger(logger Logger)
- type Box
- type BoxType
- type Brand
- type CNCVBox
- type CR3MetaBox
- type CR3Trak
- type CTBOBox
- type CrxMoovBox
- type DataInformationBox
- type FileTypeBox
- type Flags
- type HandlerBox
- type HandlerType
- type ImageRotation
- type ImageSpatialExtentsProperty
- type IndexOffset
- type ItemInfoBox
- type ItemInfoEntry
- type ItemLocationBox
- type ItemLocationBoxEntry
- type ItemPropertiesBox
- type ItemProperty
- type ItemPropertyAssociation
- type ItemPropertyAssociationItem
- type ItemPropertyContainerBox
- type ItemType
- type ItemTypeReferenceBox
- type Logger
- type MetaBox
- type MoovBox
- type OffsetLength
- type PrimaryItemBox
- type Reader
- type STDLogger
- type UUIDBox
- type UnknownBox
Constants ¶
This section is empty.
Variables ¶
var ( ErrBrandNotSupported = errors.New("error brand not supported") ErrWrongBoxType = errors.New("error wrong box type") ErrNoMoreBoxes = errors.New("no more boxes to be parsed") )
Common Errors
var ( ErrBufLength = errors.New("insufficient buffer length") ErrItemTypeWS = errors.New("bufReader error: itemType doesn't end on whitespace") ErrRemainLengthInsufficient = errors.New("bufReader error: remain length insufficient") ErrBufReaderFlags = errors.New("bufReader error: failed to read 4 bytes of Flags") ErrItemTypeLength = errors.New("bufReader: insufficient itemType Length") )
Errors
var ( // CR3MetaBoxUUID is the uuid that corresponds with Canon CR3 Metadata. CR3MetaBoxUUID = meta.UUIDFromString("85c0b687-820f-11e0-8111-f4ce462b6a48") // CR3XPacketUUID is the uuid that corresponds with Canon CR3 xpacket data CR3XPacketUUID = meta.UUIDFromString("be7acfcb-97a9-42e8-9c71-999491e3afac") // CR3PreviewDataUUID is the uuid that corresponds with Canon CR3 Perview Data CR3PreviewDataUUID = meta.UUIDFromString("eaf42b5e-1c98-4b88-b9fb-b7dc406e4d16") // CR3CMTAUUID is the uuid that corresponds with Canon CR3 CMTA box CR3CMTAUUID = meta.UUIDFromString("5766b829-bb6a-47c5-bcfb-8b9f2260d06d") // CR3CNOPUUID is the uuid that corresponds with Canon CR3 CNOP "Optional data" CR3CNOPUUID = meta.UUIDFromString("210f1687-9149-11e4-8111-00242131fce4") )
var ( // ErrItemNotFound is returned as en error when an Item was not Found. ErrItemNotFound = errors.New("item not found") // ErrInfeVersionNotSupported is returned when an infe box with an unsupported was found. ErrInfeVersionNotSupported = errors.New("infe box version not supported") )
var ( ItemTypeInfe = itemType([]byte("infe")) ItemTypeMime = itemType([]byte("mime")) ItemTypeURI = itemType([]byte("uri ")) ItemTypeAv01 = itemType([]byte("av01")) ItemTypeHvc1 = itemType([]byte("hvc1")) ItemTypeGrid = itemType([]byte("grid")) ItemTypeExif = itemType([]byte("Exif")) ItemTypeUnknown = itemType([]byte{0, 0, 0, 0}) )
Common ItemTypes
var MinorVersionNul = [4]byte{}
Functions ¶
Types ¶
type BoxType ¶
type BoxType uint8
BoxType is an ISOBMFF box
const ( TypeUnknown BoxType = iota TypeAuxC // 'auxC' TypeAuxl // 'auxl' TypeAv01 // 'av01' TypeAv1C // 'av1C' TypeAvcC // 'avcC' TypeCCDT // 'CCDT' TypeCCTP // 'CCTP' TypeCdsc // 'cdsc' TypeClap // 'clap' TypeCMT1 // 'CMT1' TypeCMT2 // 'CMT2' TypeCMT3 // 'CMT3' TypeCMT4 // 'CMT4' TypeCNCV // 'CNCV' TypeCo64 // 'co64' TypeColr // 'colr' TypeCRAW // 'CRAW' TypeCrtt // 'crtt' TypeCTBO // 'CTBO' TypeCTMD // 'CTMD' TypeDimg // 'dimg' TypeDinf // 'dinf' TypeDref // 'dref' TypeEtyp // 'etyp' TypeFree // 'free' TypeFtyp // 'ftyp' TypeGrpl // 'grpl' TypeHdlr // 'hdlr' TypeHvcC // 'hvcC' TypeIdat // 'idat' TypeIinf // 'iinf' TypeIloc // 'iloc' TypeImir // 'imir' TypeInfe // 'infe' TypeIovl // 'iovl' TypeIpco // 'ipco TypeIpma // 'ipma' TypeIprp // 'iprp' TypeIref // 'iref' TypeIrot // 'irot' TypeIspe // 'ispe' TypeLhvC // 'lhvC' TypeMdat // 'mdat' TypeMdft // 'mdft' TypeMdhd // 'mdhd' TypeMdia // 'mdia' TypeMeta // 'meta' TypeMinf // 'minf' TypeMoov // 'moov' TypeMvhd // 'mvhd' TypeNmhd // 'nmhd' TypeOinf // 'oinf' TypePasp // 'pasp' TypePitm // 'pitm' TypePixi // 'pixi' TypePRVW // 'PRVW' TypeStbl // 'stbl' TypeStsc // 'stsc' TypeStsd // 'stsd' TypeStsz // 'stsz' TypeStts // 'stts' TypeThmb // 'thmb' TypeTHMB // 'THMB' TypeTkhd // 'tkhd' TypeTols // 'tols' TypeTrak // 'trak' TypeUUID // 'uuid' TypeVmhd // 'vmhd' )
Common box types.
type CNCVBox ¶
type CNCVBox struct {
// contains filtered or unexported fields
}
CNCVBox is Canon Compressor Version box CaNon Codec Version?
type CR3MetaBox ¶
type CR3MetaBox struct {
//CCTP CCTPBox
//THMB THMBBox
CNCV CNCVBox
CTBO CTBOBox
Exif [4]meta.ExifHeader
}
CR3MetaBox is a uuidBox that contains Metadata for CR3 files
func (CR3MetaBox) XPacketData ¶
func (cr3 CR3MetaBox) XPacketData() (offset, length uint32, err error)
XPacketData returns CTBO[0] which corresponds to XPacket data First 24 bytes are a UUID box. uuid = be7acfcb-97a9-42e8-9c71-999491e3afac
type CTBOBox ¶
type CTBOBox struct {
// contains filtered or unexported fields
}
CTBOBox is a Canon tracks base offsets Box?
type CrxMoovBox ¶
type CrxMoovBox struct {
Meta CR3MetaBox
Trak [4]CR3Trak
}
CrxMoovBox is a Canon Raw Moov Box
type DataInformationBox ¶
type DataInformationBox struct {
Children []Box
}
DataInformationBox is a "dinf" box
func (DataInformationBox) Type ¶
func (dinf DataInformationBox) Type() BoxType
Type returns TypeDinf
type FileTypeBox ¶
type FileTypeBox struct {
Compatible [brandCount]Brand // all 4 bytes
MinorVersion [4]byte // 4 bytes
MajorBrand Brand // 4 bytes
}
FileTypeBox is a BMFF FileTypeBox
func (FileTypeBox) IsCR3 ¶
func (ftyp FileTypeBox) IsCR3() bool
IsCR3 returns true if major brand is crx (Canon CR3)
func (FileTypeBox) String ¶
func (ftyp FileTypeBox) String() string
type Flags ¶
type Flags uint32
Flags for a FullBox 8 bits -> Version 24 bits -> Flags
type HandlerBox ¶
type HandlerBox struct {
Flags Flags
//Name string
HandlerType HandlerType
// contains filtered or unexported fields
}
HandlerBox is a "hdlr" box.
Handler box hdlr tells the metadata type. For HEIF, it is always ’pict’.
type HandlerType ¶
type HandlerType uint8
HandlerType always 4 bytes; usually "pict" for HEIF images.
func (HandlerType) String ¶
func (ht HandlerType) String() string
type ImageRotation ¶
type ImageRotation uint8
ImageRotation is an "irot" - image rotation property. Represents the Image Rotation Angle at 90 degree intervals.
func (ImageRotation) String ¶
func (irot ImageRotation) String() string
type ImageSpatialExtentsProperty ¶
ImageSpatialExtentsProperty is an "ispe" Property
func (ImageSpatialExtentsProperty) String ¶
func (ispe ImageSpatialExtentsProperty) String() string
func (ImageSpatialExtentsProperty) Type ¶
func (ispe ImageSpatialExtentsProperty) Type() BoxType
Type returns TypeIspe
type IndexOffset ¶
type IndexOffset struct {
// contains filtered or unexported fields
}
IndexOffset has an offset and a length.
type ItemInfoBox ¶
type ItemInfoBox struct {
//size int64
//Flags Flags
//Count uint16
ItemInfos []ItemInfoEntry
}
ItemInfoBox represents an "iinf" box.
func (ItemInfoBox) ItemByID ¶
func (iinf ItemInfoBox) ItemByID(itemID uint16) (ItemInfoEntry, error)
ItemByID returns the Item of a given ID. If the ItemID is not found, the returned error is ErrItemNotFound.
func (ItemInfoBox) LastItemByType ¶
func (iinf ItemInfoBox) LastItemByType(itemType ItemType) (ItemInfoEntry, error)
LastItemByType returns the Last Item of a given Type. If the ItemType is not found, the returned error is ErrItemNotFound.
func (ItemInfoBox) String ¶
func (iinf ItemInfoBox) String() string
type ItemInfoEntry ¶
type ItemInfoEntry struct {
//Flags Flags
ItemID uint16
ProtectionIndex uint16
ItemType ItemType
// contains filtered or unexported fields
}
ItemInfoEntry represents an "infe" box.
TODO: currently only parses Version 2 boxes.
func (ItemInfoEntry) String ¶
func (infe ItemInfoEntry) String() string
type ItemLocationBox ¶
type ItemLocationBox struct {
Items []ItemLocationBoxEntry
ItemCount uint16
// contains filtered or unexported fields
}
ItemLocationBox is a "iloc" box
func (ItemLocationBox) EntryByID ¶
func (iloc ItemLocationBox) EntryByID(id uint16) (ItemLocationBoxEntry, error)
EntryByID returns the last Item Location Box Entry for the given ID. If the ID is not found returns ErrItemNotFound.
func (ItemLocationBox) String ¶
func (iloc ItemLocationBox) String() string
type ItemLocationBoxEntry ¶
type ItemLocationBoxEntry struct {
Extents []OffsetLength
FirstExtent OffsetLength
BaseOffset uint64 // uint32 or uint64, depending on encoding
ItemID uint16
ExtentCount uint16
DataReferenceIndex uint16
ConstructionMethod uint8 // actually uint4
}
ItemLocationBoxEntry is not a box
func (ItemLocationBoxEntry) String ¶
func (ilbe ItemLocationBoxEntry) String() string
type ItemPropertiesBox ¶
type ItemPropertiesBox struct {
PropertyContainer ItemPropertyContainerBox
//Associations []ItemPropertyAssociation // at least 1
Associations ItemPropertyAssociation
}
ItemPropertiesBox is an ISOBMFF "iprp" box
func (ItemPropertiesBox) ContainerByID ¶
func (iprp ItemPropertiesBox) ContainerByID(id uint16, boxType BoxType) (Box, error)
ContainerByID returns a Box for the given id and boxType.
func (ItemPropertiesBox) String ¶
func (iprp ItemPropertiesBox) String() string
type ItemProperty ¶
ItemProperty is not a box
type ItemPropertyAssociation ¶
type ItemPropertyAssociation struct {
//Flags Flags
//EntryCount uint32
Entries []ItemPropertyAssociationItem
}
ItemPropertyAssociation is an ISOBMFF "ipma" box
func (ItemPropertyAssociation) Type ¶
func (ipma ItemPropertyAssociation) Type() BoxType
Type returns TypeIpma
type ItemPropertyAssociationItem ¶
ItemPropertyAssociationItem is not a box
func (ItemPropertyAssociationItem) String ¶
func (ipai ItemPropertyAssociationItem) String() string
type ItemPropertyContainerBox ¶
type ItemPropertyContainerBox struct {
Properties []Box // of ItemProperty or ItemFullProperty
}
ItemPropertyContainerBox is an ISOBMFF "ipco" box
func (ItemPropertyContainerBox) Type ¶
func (ipco ItemPropertyContainerBox) Type() BoxType
Type returns TypeIpco
type ItemTypeReferenceBox ¶
type ItemTypeReferenceBox struct {
Flags Flags
// contains filtered or unexported fields
}
ItemTypeReferenceBox is an "iref" box.
Item Reference box iref enables creating directional links from an item to one or several other items. Item references are extensively used by HEIF. For instance, thumbnail images are recognized from a thumbnail type reference which links from the thumbnail image to the master image.
func (ItemTypeReferenceBox) Type ¶
func (iref ItemTypeReferenceBox) Type() BoxType
Type returns TypeIref.
type Logger ¶
type Logger interface {
Debug(format string, args ...interface{})
}
Logger is a logging Interface
type MetaBox ¶
type MetaBox struct {
//size uint32
Flags Flags
Handler HandlerBox
Primary PrimaryItemBox
ItemInfo ItemInfoBox
Properties ItemPropertiesBox
Location ItemLocationBox
Children []Box
}
MetaBox is a 'meta' box
type MoovBox ¶
type MoovBox struct {
// contains filtered or unexported fields
}
MoovBox is a 'moov' box
type OffsetLength ¶
type OffsetLength struct {
Offset, Length uint64
}
OffsetLength contains an offset and length
func (OffsetLength) String ¶
func (ol OffsetLength) String() string
type PrimaryItemBox ¶
PrimaryItemBox is a "pitm" box.
Primary Item Reference pitm allows setting one image as the primary item.
func (PrimaryItemBox) String ¶
func (pitm PrimaryItemBox) String() string
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is a BMFF reader
func (*Reader) ReadAndParseBox ¶
ReadAndParseBox wraps the ReadBox method, ensuring that the read box is of type typ and parses successfully. It returns the parsed box.
func (*Reader) ReadCrxMoovBox ¶
func (r *Reader) ReadCrxMoovBox() (cmb CrxMoovBox, err error)
ReadCrxMoovBox is a performance focused method for parsing the moov box from a .CR3 file.
func (*Reader) ReadFtypBox ¶
func (r *Reader) ReadFtypBox() (FileTypeBox, error)
ReadFtypBox reads an 'ftyp' box from a BMFF file.
This should be the first read function called.
func (*Reader) ReadMetaBox ¶
ReadMetaBox reads a 'meta' box from a BMFF file.
This should be called in order. First call ReadFtypBox
func (*Reader) ReadMoovBox ¶
ReadMoovBox reads a 'moov' box from a BMFF file.
This should be called in order. First call ReadFtypBox
type UUIDBox ¶
type UUIDBox struct {
// contains filtered or unexported fields
}
UUIDBox is a special type of Box that contains a uuid
type UnknownBox ¶
type UnknownBox struct {
// contains filtered or unexported fields
}
UnknownBox is a box that was unable to be parsed.
func (UnknownBox) String ¶
func (ub UnknownBox) String() string
func (UnknownBox) Type ¶
func (ub UnknownBox) Type() BoxType
Type returns the BoxType of the UnknownBox