astiffprobe

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: MIT Imports: 11 Imported by: 2 modules, 2 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

Use your FFProbe binary to gather quality information about your video files

Usage

WARNING: the code below doesn't handle errors for readibility purposes. However you SHOULD!

// Build astiffprobe
var f = astiffprobe.New(astiffprobe.Configuration{BinaryPath: <your binary path>})

// Retrieve format
var fmt astiffprobe.Format
fmt, _ = f.Format(context.Background(), <your input path>)

// Retrieve streams
var streams []astiffprobe.Stream
streams, _ = f.Streams(context.Background(), <your input path>)

// Retrieve frames
var frames []astiffprobe.Frame
frames, _ = f.Frames(context.Background(), <your input path>, <your stream index>)

// Retrieve packets
var packets []astiffprobe.Packet
packets, _ = f.Packets(context.Background(), <your input path>, <your stream index>)

// Retrieve packets ordered by PTS
packets, _ = f.PacketsOrdered(context.Background(), <your input path>, <your stream index>)

Documentation

Index

Constants

View Source
const (
	ChannelLayout51     = "5.1"
	ChannelLayout51Side = "5.1(side)"
	ChannelLayoutMono   = "mono"
	ChannelLayoutStereo = "stereo"
)

Channel layouts

View Source
const (
	CodecNameAC3         = "ac3"
	CodecNameDVBSub      = "dvbsub"
	CodecNameDVBTeletext = "dvb_teletext"
	CodecNameH264        = "h264"
)

Codec names

View Source
const (
	CodecTypeAudio    = "audio"
	CodecTypeSubtitle = "subtitle"
	CodecTypeVideo    = "video"
)

Codec types

View Source
const (
	ProfileBaseline = "baseline"
	ProfileHight    = "high"
	ProfileMain     = "main"
)

Profiles

View Source
const (
	PixelFormatYuv420p = "yuv420p"
)

Pixel formats

Variables

View Source
var (
	BinaryPath = flag.String("ffprobe-binary-path", "", "the FFProbe binary path")
)

Flags

Functions

This section is empty.

Types

type Bool

type Bool bool

Bool represents a boolean in an int format

func (*Bool) UnmarshalJSON

func (bl *Bool) UnmarshalJSON(b []byte) (err error)

UnmarshalText implements the JSONUnmarshaler interface We need to use UnmarshalJSON instead of UnmarshalText otherwise it fails

type Configuration

type Configuration struct {
	BinaryPath string `toml:"binary_path"`
}

Configuration represents the ffmpeg configuration

func FlagConfig

func FlagConfig() Configuration

FlagConfig generates a Configuration based on flags

type Disposition

type Disposition struct {
	AttachedPic     Bool `json:"attached_pic"`
	CleanEffects    Bool `json:"clean_effects"`
	Comment         Bool `json:"comment"`
	Default         Bool `json:"default"`
	Dub             Bool `json:"dub"`
	Forced          Bool `json:"forced"`
	HearingImpaired Bool `json:"hearing_impaired"`
	Karaoke         Bool `json:"karaoke"`
	Lyrics          Bool `json:"lyrics"`
	Original        Bool `json:"original"`
	TimedThumbnails Bool `json:"timed_thumbnails"`
	VisualImpaired  Bool `json:"visual_impaired"`
}

Disposition represents a stream disposition

type Duration

type Duration struct {
	time.Duration
}

Duration represents a duration in a string format "1.203" such as the duration is 1.203s

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(b []byte) (err error)

UnmarshalText implements the TextUnmarshaler interface

type Executer

type Executer interface {
	// contains filtered or unexported methods
}

Executer represents an executer

type FFProbe

type FFProbe struct {
	// contains filtered or unexported fields
}

FFProbe represents an entity capable of running an FFProbe binary

func New

func New(c Configuration) *FFProbe

New creates a new FFProbe

func (*FFProbe) Format

func (f *FFProbe) Format(ctx context.Context, src string) (ft Format, err error)

Format returns the format of a video

func (*FFProbe) Frames

func (f *FFProbe) Frames(ctx context.Context, src string, streamIndex int) (fs []Frame, err error)

Frames returns the frames of a stream

func (*FFProbe) Packets

func (f *FFProbe) Packets(ctx context.Context, src string, streamIndex int) (ps []Packet, err error)

Packets returns the unordered packets of a stream

func (*FFProbe) PacketsOrdered

func (f *FFProbe) PacketsOrdered(ctx context.Context, src string, streamIndex int) (ps []Packet, err error)

PacketsOrdered returns the ordered packets of a stream

func (*FFProbe) Streams

func (f *FFProbe) Streams(ctx context.Context, src string) (ss []Stream, err error)

Streams returns the streams of a video

type Format

type Format struct {
	Bitrate          int64    `json:"bit_rate,string"`
	Duration         Duration `json:"duration"`
	Filename         string   `json:"filename"`
	FormatName       string   `json:"format_name"`
	FormatNameLong   string   `json:"format_long_name"`
	NumberOfPrograms int      `json:"nb_programs"`
	NumberOfStreams  int      `json:"nb_streams"`
	ProbeScore       int      `json:"probe_score"`
	Size             int64    `json:"size,string"`
	StartTime        Duration `json:"start_time"`
}

Format represents a format

type Frame

type Frame struct {
	// frame timestamp estimated using various heuristics
	BestEffortTimestamp     int      `json:"best_effort_timestamp"`
	BestEffortTimestampTime Duration `json:"best_effort_timestamp_time"`
	// picture number in bitstream order
	CodedPictureNumber   int    `json:"coded_picture_number"`
	DisplayPictureNumber int    `json:"display_picture_number"`
	Height               int    `json:"height"`
	InterlacedFrame      Bool   `json:"interlaced_frame"`
	KeyFrame             Bool   `json:"key_frame"`
	MediaType            string `json:"media_type"`
	PictType             string `json:"pict_type"`
	PixFmt               string `json:"pix_fmt"`
	// duration of the corresponding packet, expressed in AVStream->time_base units, 0 if unknown
	PktDuration     int      `json:"pkt_duration"`
	PktDurationTime Duration `json:"pkt_duration_time"`
	// DTS copied from the AVPacket that triggered returning this frame
	PktDts     int      `json:"pkt_dts"`
	PktDtsTime Duration `json:"pkt_dts_time"`
	// reordered pos from the last AVPacket that has been input into the decoder
	PktPos int `json:"pkt_pos,string"`
	// PTS copied from the AVPacket that was decoded to produce this frame
	PktPts     int      `json:"pkt_pts"`
	PktPtsTime Duration `json:"pkt_pts_time"`
	// size of the corresponding packet containing the compressed frame
	PktSize           int      `json:"pkt_size,string"`
	RepeatPict        Bool     `json:"repeat_pict"`
	SampleAspectRatio Rational `json:"sample_aspect_ratio"`
	StreamIndex       int      `json:"stream_index"`
	ToFieldFirst      Bool     `json:"top_field_first"`
	Width             int      `json:"width"`
}

Frame represents a frame

type Hexadecimal

type Hexadecimal string

Hexadecimal represents an int in hexadecimal format

func (*Hexadecimal) UnmarshalText

func (h *Hexadecimal) UnmarshalText(b []byte) (err error)

Hexadecimal implements the TextUnmarshaler interface

type Output

type Output struct {
	Format  Format   `json:"format"`
	Frames  []Frame  `json:"frames"`
	Packets []Packet `json:"packets"`
	Streams []Stream `json:"streams"`
}

Output represents the object FFProbe outputs https://ffmpeg.org/doxygen/2.7/structAVFrame.html

type Packet

type Packet struct {
	CodecType    string   `json:"codec_type"`
	Dts          int      `json:"dts"`
	DtsTime      Duration `json:"dts_time"`
	Duration     int      `json:"duration"`
	DurationTime Duration `json:"duration_time"`
	Flags        string   `json:"flags"`
	Position     int      `json:"position,string"`
	Pts          int      `json:"pts"`
	PtsTime      Duration `json:"pts_time"`
	Size         int      `json:"size,string"`
	StreamIndex  int      `json:"stream_index"`
}

Packet represents a packet

type Rational added in v0.3.0

type Rational struct {
	astikit.Rational
}

Rational represents a rational either in "25/1" or "16:9" format

func (*Rational) UnmarshalText added in v0.3.0

func (r *Rational) UnmarshalText(b []byte) (err error)

UnmarshalText implements the TextUnmarshaler interface

type Stream

type Stream struct {
	AvgFramerate       Rational          `json:"avg_frame_rate"`
	Bitrate            int64             `json:"bit_rate,string"`
	BitsPerRawSample   int64             `json:"bits_per_raw_sample,string"`
	ChannelLayout      string            `json:"channel_layout"`
	Channels           int               `json:"channels"`
	ChromaLocation     string            `json:"chroma_location"`
	CodecLongName      string            `json:"codec_long_name"`
	CodecName          string            `json:"codec_name"`
	CodecTag           string            `json:"codec_tag"`
	CodecTagString     string            `json:"codec_tag_string"`
	CodecTimeBase      string            `json:"codec_time_base"`
	CodecType          string            `json:"codec_type"`
	CodedHeight        int               `json:"coded_height"`
	CodedWidth         int               `json:"coded_width"`
	ColorPrimaries     string            `json:"color_primaries"`
	ColorRange         string            `json:"color_range"`
	ColorSpace         string            `json:"color_space"`
	ColorTransfer      string            `json:"color_transfer"`
	DisplayAspectRatio Rational          `json:"display_aspect_ratio"`
	Disposition        Disposition       `json:"disposition"`
	Duration           Duration          `json:"duration"`
	DurationTs         int64             `json:"duration_ts"`
	HasBFrames         int               `json:"has_b_frames"`
	Height             int               `json:"height"`
	ID                 Hexadecimal       `json:"id"`
	Index              int               `json:"index"`
	IsAVC              bool              `json:"is_avc,string"`
	Level              int               `json:"level"`
	NalLengthSize      int               `json:"nal_length_size,string"`
	NbFrames           int64             `json:"nb_frames,string"`
	PixFmt             string            `json:"pix_fmt"`
	Profile            string            `json:"profile"`
	Refs               int64             `json:"refs"`
	RFrameRate         Rational          `json:"r_frame_rate"`
	SampleAspectRatio  Rational          `json:"sample_aspect_ratio"`
	SampleFmt          string            `json:"sample_fmt"`
	SampleRate         int               `json:"sample_rate,string"`
	StartPts           int64             `json:"start_pts"`
	StartTime          Duration          `json:"start_time"`
	Tags               map[string]string `json:"tags"`
	TimeBase           Rational          `json:"time_base"`
	Width              int               `json:"width"`
}

Stream represents a stream

Jump to

Keyboard shortcuts

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