Documentation ¶
Overview ¶
Package video provides video file related types and abstractions.
Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved.
This program is free software: you can redistribute it and/or modify it under Version 3 of the GNU Affero General Public License (the "AGPL"): <https://docs.photoprism.app/license/agpl> This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. The AGPL is supplemented by our Trademark and Brand Guidelines, which describe how our Brand Assets may be used: <https://www.photoprism.app/trademark>
Feel free to send an email to hello@photoprism.app if you have questions, want to support our work, or just want to say hello.
Additional information can be found in our Developer Guide: <https://docs.photoprism.app/developer-guide/>
Index ¶
Constants ¶
const ( ContentTypeDefault = "application/octet-stream" ContentTypeAVC = fs.MimeTypeMP4 + `; codecs="avc1"` ContentTypeMOV = fs.MimeTypeMOV )
Standard content types.
Variables ¶
var ( ChunkFTYP = Chunk{'f', 't', 'y', 'p'} ChunkQT = Chunk{'q', 't', ' ', ' '} ChunkISOM = Chunk{'i', 's', 'o', 'm'} ChunkISO2 = Chunk{'i', 's', 'o', '2'} ChunkISO3 = Chunk{'i', 's', 'o', '3'} ChunkISO4 = Chunk{'i', 's', 'o', '4'} ChunkISO5 = Chunk{'i', 's', 'o', '5'} ChunkISO6 = Chunk{'i', 's', 'o', '6'} ChunkISO7 = Chunk{'i', 's', 'o', '7'} ChunkISO8 = Chunk{'i', 's', 'o', '8'} ChunkISO9 = Chunk{'i', 's', 'o', '9'} ChunkAVC1 = Chunk{'a', 'v', 'c', '1'} ChunkHEV1 = Chunk{'h', 'e', 'v', '1'} ChunkHVC1 = Chunk{'h', 'v', 'c', '1'} ChunkAV01 = Chunk{'a', 'v', '0', '1'} ChunkAV1C = Chunk{'a', 'v', '1', 'C'} ChunkMMP4 = Chunk{'m', 'm', 'p', '4'} ChunkMP4V = Chunk{'m', 'p', '4', 'v'} ChunkMP41 = Chunk{'m', 'p', '4', '1'} ChunkMP42 = Chunk{'m', 'p', '4', '2'} ChunkMP71 = Chunk{'m', 'p', '7', '1'} ChunkHEIC = Chunk{'h', 'e', 'i', 'c'} )
ChunkFTYP specifies the start chunk of the ISO base media format, it must be followed by a valid subtype chunk. https://en.wikipedia.org/wiki/ISO_base_media_file_format
var AV1 = Type{ Codec: CodecAV1, FileType: fs.VideoWebM, WidthLimit: 0, HeightLimit: 0, Public: false, }
AV1 + Google WebM.
var AVC = Type{ Codec: CodecAVC, FileType: fs.VideoAVC, WidthLimit: 8192, HeightLimit: 4320, Public: true, }
AVC aka Advanced Video Coding (H.264).
var Codecs = StandardCodecs{ "": CodecUnknown, "a_opus": CodecUnknown, "a_vorbis": CodecUnknown, "avc": CodecAVC, "avc1": CodecAVC, "v_avc": CodecAVC, "v_avc1": CodecAVC, "hevc": CodecHVC, "hvc": CodecHVC, "hvc1": CodecHVC, "v_hvc": CodecHVC, "v_hvc1": CodecHVC, "vvc": CodecVVC, "v_vvc": CodecVVC, "av1": CodecAV1, "av01": CodecAV1, "v_av1": CodecAV1, "v_av01": CodecAV1, "vp8": CodecVP8, "vp80": CodecVP8, "v_vp8": CodecVP8, "vp9": CodecVP9, "vp09": CodecVP9, "vp90": CodecVP9, "v_vp9": CodecVP9, "ogv": CodecOGV, "webm": CodecWebM, }
Codecs maps identifiers to codecs.
var CompatibleBrands = Chunks{ ChunkQT, ChunkISOM, ChunkISO2, ChunkISO3, ChunkISO4, ChunkISO5, ChunkISO6, ChunkISO7, ChunkISO8, ChunkISO9, ChunkAVC1, ChunkHEV1, ChunkHVC1, ChunkAV01, ChunkAV1C, ChunkMMP4, ChunkMP4V, ChunkMP41, ChunkMP42, ChunkMP71, }
CompatibleBrands contains compatible subtypes chunks.
var HEVC = Type{ Codec: CodecHVC, FileType: fs.VideoHEVC, WidthLimit: 0, HeightLimit: 0, Public: false, }
HEVC aka High Efficiency Video Coding (H.265).
var LiveDuration = time.Millisecond * 3100
LiveDuration is the maximum duration for a video to play inline like a live photo.
var MOV = Type{ Codec: CodecAVC, FileType: fs.VideoMOV, WidthLimit: 8192, HeightLimit: 4320, Public: true, }
MOV are QuickTime videos based on the MPEG-4 format,
var MP4 = Type{ Codec: CodecAVC, FileType: fs.VideoMP4, WidthLimit: 8192, HeightLimit: 4320, Public: true, }
MP4 is a Multimedia Container (MPEG-4 Part 14).
var OGV = Type{ Codec: CodecOGV, FileType: fs.VideoOGV, WidthLimit: 0, HeightLimit: 0, Public: false, }
OGV aka Ogg/Theora.
var Types = Standards{ "": AVC, "mp4": MP4, "mpeg4": MP4, "avc": AVC, "avc1": AVC, "hvc": HEVC, "hvc1": HEVC, "hevc": HEVC, "vvc": VVC, "vvc1": VVC, "vp8": VP8, "vp80": VP8, "vp9": VP9, "vp90": VP9, "av1": AV1, "av01": AV1, "ogg": OGV, "ogv": OGV, "webm": WebM, }
Types maps identifiers to standards.
var Unknown = Type{ Codec: CodecUnknown, FileType: fs.TypeUnknown, }
Unknown represents an unknown video file type.
var VP8 = Type{ Codec: CodecVP8, FileType: fs.VideoWebM, WidthLimit: 0, HeightLimit: 0, Public: false, }
VP8 + Google WebM.
var VP9 = Type{ Codec: CodecVP9, FileType: fs.VideoWebM, WidthLimit: 0, HeightLimit: 0, Public: false, }
VP9 + Google WebM.
var VVC = Type{ Codec: CodecVVC, FileType: fs.VideoVVC, WidthLimit: 0, HeightLimit: 0, Public: false, }
VVC aka Versatile Video Coding (H.266).
var WebM = Type{ Codec: CodecUnknown, FileType: fs.VideoWebM, WidthLimit: 0, HeightLimit: 0, Public: false, }
WebM Container.
Functions ¶
func ContentType ¶
ContentType composes the video content type from the given mime type and codec.
Types ¶
type Chunk ¶
type Chunk [4]byte
Chunk represents a fixed length file chunk.
func (Chunk) DataOffset ¶
func (c Chunk) DataOffset(file io.ReadSeeker) (int, error)
DataOffset returns the index of the chunk in file, or -1 if it was not found.
func (Chunk) FileOffset ¶
FileOffset returns the index of the chunk, or -1 if it was not found.
type Chunks ¶
type Chunks []Chunk
Chunks represents a list of file chunks.
func (Chunks) ContainsAny ¶
ContainsAny checks if at least one common chunk exists in this list.
func (Chunks) FileTypeOffset ¶
func (c Chunks) FileTypeOffset(file io.ReadSeeker) (int, error)
FileTypeOffset returns the file type start offset in f, or -1 if it was not found.
type Info ¶
type Info struct { FileName string FileSize int64 FileType fs.Type MediaType media.Type ThumbOffset int64 ThumbMimeType string VideoOffset int64 VideoMimeType string VideoType Type VideoCodec Codec VideoWidth int VideoHeight int Duration time.Duration Frames int FPS float64 Tracks int Encrypted bool FastStart bool Compatible bool }
Info represents video file information.
func Probe ¶
func Probe(file io.ReadSeeker) (info Info, err error)
Probe returns information on the provided video file. see https://pkg.go.dev/github.com/abema/go-mp4#ProbeInfo
func (Info) VideoBitrate ¶
VideoBitrate returns the bitrate of the embedded video in MBit/s.
func (Info) VideoContentType ¶
VideoContentType composes the video content type from its mime type and codec.
func (Info) VideoFileExt ¶
VideoFileExt returns the appropriate video file extension based on the mime type and defaults to fs.ExtMP4 otherwise.
func (Info) VideoFileType ¶
VideoFileType returns the video type based on the mime type and defaults to fs.VideoMP4 otherwise.
type ReadSeeker ¶
type ReadSeeker struct {
// contains filtered or unexported fields
}
ReadSeeker reads an existing file from an offset until the end.
func NewReadSeeker ¶
func NewReadSeeker(file io.ReadSeeker, offset int64) *ReadSeeker
NewReadSeeker creates a new ReadSeeker.
func (*ReadSeeker) Read ¶
func (r *ReadSeeker) Read(p []byte) (n int, err error)
Read reads up to len(p) bytes into p. It returns the number of bytes read and any error encountered.
func (*ReadSeeker) Seek ¶
func (r *ReadSeeker) Seek(offset int64, whence int) (pos int64, err error)
Seek sets the offset for the next Read or Write to offset, interpreted according to whence: - SeekStart means relative to the start of the file - SeekCurrent means relative to the current offset - SeekEnd means relative to the end (for example, offset = -2 specifies the penultimate byte of the file)
Seek returns the new offset relative to the start of the file or an error, if any. Seeking to an offset before the start of the file is an error.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads an existing file from an offset until the end.
type StandardCodecs ¶
StandardCodecs maps names to known codecs.