Documentation ¶
Index ¶
- Constants
- Variables
- func SetFFProbeBinPath(newBinPath string)
- type Chapter
- type Format
- type FormatTags
- type ProbeData
- func (p *ProbeData) FirstAttachmentStream() *Stream
- func (p *ProbeData) FirstAudioStream() *Stream
- func (p *ProbeData) FirstDataStream() *Stream
- func (p *ProbeData) FirstSubtitleStream() *Stream
- func (p *ProbeData) FirstVideoStream() *Stream
- func (p *ProbeData) StreamType(streamType StreamType) (streams []Stream)
- type SideData
- type SideDataBase
- type SideDataContentLightLevel
- type SideDataDisplayMatrix
- type SideDataList
- func (s SideDataList) FindSideData(sideDataType string) (interface{}, error)
- func (s SideDataList) FindUnknownSideData(sideDataType string) (*SideDataUnknown, error)
- func (s SideDataList) GetContentLightLevel() (*SideDataContentLightLevel, error)
- func (s SideDataList) GetDisplayMatrix() (*SideDataDisplayMatrix, error)
- func (s SideDataList) GetMasteringDisplayMetadata() (*SideDataMasteringDisplayMetadata, error)
- func (s SideDataList) GetSkipSamples() (*SideDataSkipSamples, error)
- func (s SideDataList) GetSphericalMapping() (*SideDataSphericalMapping, error)
- func (s SideDataList) GetStereo3D() (*SideDataStereo3D, error)
- func (s *SideDataList) UnmarshalJSON(b []byte) error
- type SideDataMasteringDisplayMetadata
- type SideDataSkipSamples
- type SideDataSphericalMapping
- type SideDataStereo3D
- type SideDataUnknown
- type Stream
- type StreamDisposition
- type StreamTags
- type StreamType
- type Tags
Constants ¶
const ( SideDataTypeUnknown = "unknown" SideDataTypeDisplayMatrix = "Display Matrix" SideDataTypeStereo3D = "Stereo 3D" SideDataTypeSphericalMapping = "Spherical Mapping" SideDataTypeSkipSamples = "Skip Samples" SideDataTypeMasteringDisplayMetadata = "Mastering display metadata" SideDataTypeContentLightLevel = "Content light level metadata" )
All names and structures of side data types got from https://github.com/FFmpeg/FFmpeg/blob/4ab1184fae88bd47b9d195ac8224853c6f4e94cf/libavcodec/avpacket.c#L268 https://github.com/FFmpeg/FFmpeg/blob/master/fftools/ffprobe.c#L2291
Variables ¶
var ( ErrSideDataNotFound = errors.New("side data not found") ErrSideDataUnexpectedType = errors.New("unexpected data type") )
var ErrTagNotFound = errors.New("tag not found")
ErrTagNotFound is a sentinel error used when a queried tag does not exist
Functions ¶
func SetFFProbeBinPath ¶
func SetFFProbeBinPath(newBinPath string)
SetFFProbeBinPath sets the global path to find and execute the ffprobe program
Types ¶
type Chapter ¶ added in v2.2.0
type Chapter struct { ID int `json:"id"` TimeBase string `json:"time_base"` StartTimeSeconds float64 `json:"start_time,string"` EndTimeSeconds float64 `json:"end_time,string"` TagList Tags `json:"tags"` }
Chapters is a json data structure to represent chapters.
func (*Chapter) EndTime ¶ added in v2.2.0
EndTime returns the end timestamp of the chapter as a time.Duration
type Format ¶
type Format struct { Filename string `json:"filename"` NBStreams int `json:"nb_streams"` NBPrograms int `json:"nb_programs"` FormatName string `json:"format_name"` FormatLongName string `json:"format_long_name"` StartTimeSeconds float64 `json:"start_time,string"` DurationSeconds float64 `json:"duration,string"` Size string `json:"size"` BitRate string `json:"bit_rate"` ProbeScore int `json:"probe_score"` TagList Tags `json:"tags"` Tags *FormatTags `json:"-"` // Deprecated: Use TagList instead }
Format is a json data structure to represent formats
type FormatTags ¶
type FormatTags struct { MajorBrand string `json:"major_brand"` MinorVersion string `json:"minor_version"` CompatibleBrands string `json:"compatible_brands"` CreationTime string `json:"creation_time"` }
FormatTags is a json data structure to represent format tags Deprecated, use the Tags of TagList instead
type ProbeData ¶
type ProbeData struct { Streams []*Stream `json:"streams"` Format *Format `json:"format"` Chapters []*Chapter `json:"chapters"` }
ProbeData is the root json data structure returned by an ffprobe.
func ProbeReader ¶
func ProbeReader(ctx context.Context, reader io.Reader, extraFFProbeOptions ...string) (data *ProbeData, err error)
ProbeReader is used to probe a media file using an io.Reader. The reader is piped to the stdin of the ffprobe command and the data is returned. This function takes a context to allow killing the ffprobe process if it takes too long or in case of shutdown. Any additional ffprobe parameter can be supplied as well using extraFFProbeOptions.
func ProbeURL ¶
func ProbeURL(ctx context.Context, fileURL string, extraFFProbeOptions ...string) (data *ProbeData, err error)
ProbeURL is used to probe the given media file using ffprobe. The URL can be a local path, a HTTP URL or any other protocol supported by ffprobe, see here for a full list: https://ffmpeg.org/ffmpeg-protocols.html This function takes a context to allow killing the ffprobe process if it takes too long or in case of shutdown. Any additional ffprobe parameter can be supplied as well using extraFFProbeOptions.
func (*ProbeData) FirstAttachmentStream ¶ added in v2.0.3
FirstAttachmentStream returns the first attachment stream found
func (*ProbeData) FirstAudioStream ¶
FirstAudioStream returns the first audio stream found
func (*ProbeData) FirstDataStream ¶ added in v2.0.3
FirstDataStream returns the first data stream found
func (*ProbeData) FirstSubtitleStream ¶
FirstSubtitleStream returns the first subtitle stream found
func (*ProbeData) FirstVideoStream ¶
FirstVideoStream returns the first video stream found
func (*ProbeData) StreamType ¶
func (p *ProbeData) StreamType(streamType StreamType) (streams []Stream)
StreamType returns all streams which are of the given type
type SideData ¶ added in v2.2.0
type SideData struct { SideDataBase Data interface{} `json:"-"` }
SideData represents a side data packet.
func (*SideData) MarshalJSON ¶ added in v2.2.0
func (*SideData) UnmarshalJSON ¶ added in v2.2.0
type SideDataBase ¶ added in v2.2.0
type SideDataBase struct {
Type string `json:"side_data_type"`
}
type SideDataContentLightLevel ¶ added in v2.2.0
type SideDataContentLightLevel struct { SideDataBase MaxContent int `json:"max_content,omitempty"` MaxAverage int `json:"max_average,omitempty"` }
SideDataContentLightLevel represents the content light level side data.
type SideDataDisplayMatrix ¶ added in v2.2.0
type SideDataDisplayMatrix struct { SideDataBase Data string `json:"displaymatrix"` Rotation int `json:"rotation"` }
SideDataDisplayMatrix represents the display matrix side data.
type SideDataList ¶ added in v2.2.0
type SideDataList []SideData
SideDataList represents a list of side data packets.
func (SideDataList) FindSideData ¶ added in v2.2.0
func (s SideDataList) FindSideData(sideDataType string) (interface{}, error)
FindSideData searches for SideData by its type in the SideDataList. If SideData of the specified type is found, it is returned, otherwise, an error is returned indicating that the SideData of the specified type was not found.
func (SideDataList) FindUnknownSideData ¶ added in v2.2.0
func (s SideDataList) FindUnknownSideData(sideDataType string) (*SideDataUnknown, error)
FindUnknownSideData searches for SideData of type SideDataUnknown in the SideDataList. If such SideData is found, it is returned, otherwise, an error is returned indicating that the SideData of type SideDataUnknown was not found or the found SideData was of an unexpected type.
func (SideDataList) GetContentLightLevel ¶ added in v2.2.0
func (s SideDataList) GetContentLightLevel() (*SideDataContentLightLevel, error)
GetContentLightLevel retrieves the ContentLightLevel from the SideData. If the ContentLightLevel is not found or the SideData is of the wrong type, an error is returned.
func (SideDataList) GetDisplayMatrix ¶ added in v2.2.0
func (s SideDataList) GetDisplayMatrix() (*SideDataDisplayMatrix, error)
GetDisplayMatrix retrieves the DisplayMatrix from the SideData. If the DisplayMatrix is not found or the SideData is of the wrong type, an error is returned.
func (SideDataList) GetMasteringDisplayMetadata ¶ added in v2.2.0
func (s SideDataList) GetMasteringDisplayMetadata() (*SideDataMasteringDisplayMetadata, error)
GetMasteringDisplayMetadata retrieves the MasteringDisplayMetadata from the SideData. If the MasteringDisplayMetadata is not found or the SideData is of the wrong type, an error is returned.
func (SideDataList) GetSkipSamples ¶ added in v2.2.0
func (s SideDataList) GetSkipSamples() (*SideDataSkipSamples, error)
GetSkipSamples retrieves the SkipSamples data from the SideData. If the SkipSamples data is not found or the SideData is of the wrong type, an error is returned.
func (SideDataList) GetSphericalMapping ¶ added in v2.2.0
func (s SideDataList) GetSphericalMapping() (*SideDataSphericalMapping, error)
GetSphericalMapping retrieves the SphericalMapping data from the SideData. If the SphericalMapping data is not found or the SideData is of the wrong type, an error is returned.
func (SideDataList) GetStereo3D ¶ added in v2.2.0
func (s SideDataList) GetStereo3D() (*SideDataStereo3D, error)
GetStereo3D retrieves the Stereo3D data from the SideData. If the Stereo3D data is not found or the SideData is of the wrong type, an error is returned.
func (*SideDataList) UnmarshalJSON ¶ added in v2.2.0
func (s *SideDataList) UnmarshalJSON(b []byte) error
UnmarshalJSON for SideDataList
type SideDataMasteringDisplayMetadata ¶ added in v2.2.0
type SideDataMasteringDisplayMetadata struct { SideDataBase RedX int `json:"red_x,omitempty"` RedY int `json:"red_y,omitempty"` GreenX int `json:"green_x,omitempty"` GreenY int `json:"green_y,omitempty"` BlueX int `json:"blue_x,omitempty"` BlueY int `json:"blue_y,omitempty"` WhitePointX int `json:"white_point_x,omitempty"` WhitePointY int `json:"white_point_y,omitempty"` MinLuminance int `json:"min_luminance,omitempty"` MaxLuminance int `json:"max_luminance,omitempty"` }
SideDataMasteringDisplayMetadata represents the mastering display metadata side data.
type SideDataSkipSamples ¶ added in v2.2.0
type SideDataSkipSamples struct { SideDataBase SkipSamples int `json:"skip_samples"` DiscardPadding int `json:"discard_padding"` SkipReason int `json:"skip_reason"` DiscardReason int `json:"discard_reason"` }
SideDataSkipSamples represents the skip samples side data.
type SideDataSphericalMapping ¶ added in v2.2.0
type SideDataSphericalMapping struct { SideDataBase Projection string `json:"projection"` Padding int `json:"padding,omitempty"` BoundLeft int `json:"bound_left,omitempty"` BoundTop int `json:"bound_top,omitempty"` BoundRight int `json:"bound_right,omitempty"` BoundBottom int `json:"bound_bottom,omitempty"` Yaw int `json:"yaw,omitempty"` Pitch int `json:"pitch,omitempty"` Roll int `json:"roll,omitempty"` }
SideDataSphericalMapping represents the spherical mapping side data.
type SideDataStereo3D ¶ added in v2.2.0
type SideDataStereo3D struct { SideDataBase Type string `json:"type"` Inverted bool `json:"inverted"` }
SideDataStereo3D represents the stereo 3D side data.
type SideDataUnknown ¶ added in v2.2.0
type SideDataUnknown Tags
SideDataUnknown represents an unknown side data.
type Stream ¶
type Stream struct { Index int `json:"index"` ID string `json:"id"` CodecName string `json:"codec_name"` CodecLongName string `json:"codec_long_name"` CodecType string `json:"codec_type"` CodecTimeBase string `json:"codec_time_base"` CodecTagString string `json:"codec_tag_string"` CodecTag string `json:"codec_tag"` RFrameRate string `json:"r_frame_rate"` AvgFrameRate string `json:"avg_frame_rate"` TimeBase string `json:"time_base"` StartPts int `json:"start_pts"` StartTime string `json:"start_time"` DurationTs uint64 `json:"duration_ts"` Duration string `json:"duration"` BitRate string `json:"bit_rate"` BitsPerRawSample string `json:"bits_per_raw_sample"` NbFrames string `json:"nb_frames"` Disposition StreamDisposition `json:"disposition,omitempty"` TagList Tags `json:"tags"` Tags StreamTags `json:"-"` // Deprecated: Use TagList instead FieldOrder string `json:"field_order,omitempty"` Profile string `json:"profile,omitempty"` Width int `json:"width"` Height int `json:"height"` HasBFrames int `json:"has_b_frames,omitempty"` SampleAspectRatio string `json:"sample_aspect_ratio,omitempty"` DisplayAspectRatio string `json:"display_aspect_ratio,omitempty"` PixFmt string `json:"pix_fmt,omitempty"` Level int `json:"level,omitempty"` ColorRange string `json:"color_range,omitempty"` ColorSpace string `json:"color_space,omitempty"` SampleFmt string `json:"sample_fmt,omitempty"` SampleRate string `json:"sample_rate,omitempty"` Channels int `json:"channels,omitempty"` ChannelLayout string `json:"channel_layout,omitempty"` BitsPerSample int `json:"bits_per_sample,omitempty"` SideDataList SideDataList `json:"side_data_list,omitempty"` }
Stream is a json data structure to represent streams. A stream can be a video, audio, subtitle, etc type of stream.
type StreamDisposition ¶
type StreamDisposition struct { Default int `json:"default"` Dub int `json:"dub"` Original int `json:"original"` Comment int `json:"comment"` Lyrics int `json:"lyrics"` Karaoke int `json:"karaoke"` Forced int `json:"forced"` HearingImpaired int `json:"hearing_impaired"` VisualImpaired int `json:"visual_impaired"` CleanEffects int `json:"clean_effects"` AttachedPic int `json:"attached_pic"` }
StreamDisposition is a json data structure to represent stream dispositions
type StreamTags ¶
type StreamTags struct { Rotate int `json:"rotate,string,omitempty"` CreationTime string `json:"creation_time,omitempty"` Language string `json:"language,omitempty"` Title string `json:"title,omitempty"` Encoder string `json:"encoder,omitempty"` Location string `json:"location,omitempty"` }
StreamTags is a json data structure to represent stream tags Deprecated, use the Tags of TagList instead
type StreamType ¶
type StreamType string
StreamType represents a media stream type like video, audio, subtitles, etc
const ( // StreamAny means any type of stream StreamAny StreamType = "" // StreamVideo is a video stream StreamVideo StreamType = "video" // StreamAudio is an audio stream StreamAudio StreamType = "audio" // StreamSubtitle is a subtitle stream StreamSubtitle StreamType = "subtitle" // StreamData is a data stream StreamData StreamType = "data" // StreamAttachment is an attachment stream StreamAttachment StreamType = "attachment" )
type Tags ¶ added in v2.1.0
type Tags map[string]interface{}
Tags is the map of tag names to values
func (Tags) GetFloat ¶ added in v2.1.0
GetFloat returns a tag value as float64 and an error if one occurred. ErrTagNotFound will be returned if the key can't be found.