ffprobe

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2019 License: MIT Imports: 6 Imported by: 27 modules, 26 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Go ffprobe

Small library for executing an ffprobe process on a given file and getting a easy to use struct representing the returned ffprobe data.

Documentation

Take a look at the autogenerated documentation:

https://godoc.org/github.com/vansante/go-ffprobe

TODO

  • Some tests would be nice

Documentation

Index

Constants

View Source
const (
	// STREAM_ANY deprecated, use StreamAny
	STREAM_ANY = StreamAny
	// STREAM_VIDEO deprecated, use StreamVideo
	STREAM_VIDEO = StreamVideo
	// STREAM_AUDIO deprecated, use StreamAudio
	STREAM_AUDIO = StreamAudio
	// STREAM_SUBTITLE deprecated, use StreamSubtitle
	STREAM_SUBTITLE = StreamSubtitle
)

TODO: FIXME: We should remove the ALL_CAPS variants some time in the future (golint hates them)

Variables

View Source
var (
	// ErrBinNotFound is returned when the ffprobe binary was not found
	ErrBinNotFound = errors.New("ffprobe bin not found")
	// ErrTimeout is returned when the ffprobe process did not succeed within the given time
	ErrTimeout = errors.New("process timeout exceeded")
)

Functions

func SetFFProbeBinPath

func SetFFProbeBinPath(newBinPath string)

SetFFProbeBinPath sets the global path to find and execute the ffprobe program

Types

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"`
	Tags             *FormatTags `json:"tags"`
}

Format is a json data structure to represent formats

func (*Format) Duration

func (f *Format) Duration() (duration time.Duration)

Duration returns the duration of the media file as a time.Duration

func (*Format) StartTime

func (f *Format) StartTime() (duration time.Duration)

StartTime returns the start time of the media file as a time.Duration

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

type ProbeData

type ProbeData struct {
	Streams []*Stream `json:"streams"`
	Format  *Format   `json:"format"`
}

ProbeData is the root json data structure returned by an ffprobe.

func GetProbeData

func GetProbeData(filePath string, timeout time.Duration) (data *ProbeData, err error)

GetProbeData is used for probing the given media file using ffprobe with a set timeout. The timeout can be provided to kill the process if it takes too long to determine the files information. Note: It is probably better to use Context with GetProbeDataContext() these days as it is more flexible.

func GetProbeDataContext

func GetProbeDataContext(ctx context.Context, filePath string) (data *ProbeData, err error)

GetProbeDataContext is the main command used for probing the given media file using ffprobe. It takes a context to allow killing the ffprobe process if it takes too long or in case of shutdown.

func (*ProbeData) GetFirstAudioStream

func (p *ProbeData) GetFirstAudioStream() (str *Stream)

GetFirstAudioStream returns the first audio stream found

func (*ProbeData) GetFirstSubtitleStream

func (p *ProbeData) GetFirstSubtitleStream() (str *Stream)

GetFirstSubtitleStream returns the first subtitle stream found

func (*ProbeData) GetFirstVideoStream

func (p *ProbeData) GetFirstVideoStream() (str *Stream)

GetFirstVideoStream returns the first video stream found

func (*ProbeData) GetStreams

func (p *ProbeData) GetStreams(streamType StreamType) (streams []Stream)

GetStreams returns all streams which are of the given type

type Stream

type Stream struct {
	Index              int               `json:"index"`
	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"`
	Tags               StreamTags        `json:"tags,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"`
}

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"`
	Encoder      string `json:"encoder,omitempty"`
	Location     string `json:"location,omitempty"`
}

StreamTags is a json data structure to represent stream tags

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"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址