ffmpeg

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidBitRate = errors.New("invalid bitrate")
View Source
var ErrInvalidBitsPerSample = errors.New("bits per sample must be 8 or 10")
View Source
var ErrInvalidCodec = errors.New("only hevc supported")
View Source
var ErrMissingFilename = errors.New("missing filename")

Functions

This section is empty.

Types

type Format

type Format struct {
	Tags struct {
		Title            string `json:"title"`
		COMMENT          string `json:"COMMENT"`
		MAJORBRAND       string `json:"MAJOR_BRAND"`
		MINORVERSION     string `json:"MINOR_VERSION"`
		COMPATIBLEBRANDS string `json:"COMPATIBLE_BRANDS"`
		ENCODER          string `json:"ENCODER"`
	} `json:"tags"`
	Filename       string `json:"filename"`
	FormatName     string `json:"format_name"`
	FormatLongName string `json:"format_long_name"`
	StartTime      string `json:"start_time"`
	Duration       string `json:"duration"`
	Size           string `json:"size"`
	BitRate        string `json:"bit_rate"`
	NbStreams      int    `json:"nb_streams"`
	NbPrograms     int    `json:"nb_programs"`
	ProbeScore     int    `json:"probe_score"`
}

type Processor

type Processor struct {
	Logger *slog.Logger
}

Processor implements video scanning (ffprobe) and converting (ffmpeg). Implemented as a struct so that it can be mocked at the calling side.

func (Processor) Convert

func (p Processor) Convert(ctx context.Context, request Request) error

func (Processor) Probe

func (p Processor) Probe(ctx context.Context, path string) (VideoStats, error)

type Progress

type Progress struct {
	Converted time.Duration
	Speed     float64
}

type Request

type Request struct {
	Source        string
	Target        string
	VideoCodec    string
	BitsPerSample int
	BitRate       int
	ProgressCB    func(Progress)
}

func (Request) IsValid

func (r Request) IsValid() error

type Stream

type Stream struct {
	Disposition 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"`
		TimedThumbnails int `json:"timed_thumbnails"`
		Captions        int `json:"captions"`
		Descriptions    int `json:"descriptions"`
		Metadata        int `json:"metadata"`
		Dependent       int `json:"dependent"`
		StillImage      int `json:"still_image"`
	} `json:"disposition"`
	Tags struct {
		HANDLERNAME string `json:"HANDLER_NAME"`
		VENDORID    string `json:"VENDOR_ID"`
		ENCODER     string `json:"ENCODER,omitempty"`
		DURATION    string `json:"DURATION"`
		Language    string `json:"language,omitempty"`
	} `json:"tags"`
	CodecTagString     string `json:"codec_tag_string"`
	CodecName          string `json:"codec_name"`
	CodecType          string `json:"codec_type"`
	RFrameRate         string `json:"r_frame_rate"`
	CodecTag           string `json:"codec_tag"`
	ChannelLayout      string `json:"channel_layout,omitempty"`
	SampleRate         string `json:"sample_rate,omitempty"`
	SampleFmt          string `json:"sample_fmt,omitempty"`
	CodecLongName      string `json:"codec_long_name"`
	Profile            string `json:"profile"`
	StartTime          string `json:"start_time"`
	TimeBase           string `json:"time_base"`
	SampleAspectRatio  string `json:"sample_aspect_ratio,omitempty"`
	DisplayAspectRatio string `json:"display_aspect_ratio,omitempty"`
	PixFmt             string `json:"pix_fmt,omitempty"`
	AvgFrameRate       string `json:"avg_frame_rate"`
	ColorRange         string `json:"color_range,omitempty"`
	ChromaLocation     string `json:"chroma_location,omitempty"`
	FieldOrder         string `json:"field_order,omitempty"`
	CodedWidth         int    `json:"coded_width,omitempty"`
	Refs               int    `json:"refs,omitempty"`
	Level              int    `json:"level,omitempty"`
	HasBFrames         int    `json:"has_b_frames,omitempty"`
	StartPts           int    `json:"start_pts"`
	FilmGrain          int    `json:"film_grain,omitempty"`
	ExtradataSize      int    `json:"extradata_size"`
	ClosedCaptions     int    `json:"closed_captions,omitempty"`
	CodedHeight        int    `json:"coded_height,omitempty"`
	Index              int    `json:"index"`
	Height             int    `json:"height,omitempty"`
	Channels           int    `json:"channels,omitempty"`
	Width              int    `json:"width,omitempty"`
	BitsPerSample      int    `json:"bits_per_sample,omitempty"`
	InitialPadding     int    `json:"initial_padding,omitempty"`
}

type VideoStats

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

func (VideoStats) BitRate

func (p VideoStats) BitRate() int

func (VideoStats) BitsPerSample

func (p VideoStats) BitsPerSample() int

func (VideoStats) Duration

func (p VideoStats) Duration() time.Duration

func (VideoStats) Height

func (p VideoStats) Height() int

func (VideoStats) LogValue

func (p VideoStats) LogValue() slog.Value

func (VideoStats) VideoCodec

func (p VideoStats) VideoCodec() string

func (VideoStats) Width added in v0.2.0

func (p VideoStats) Width() any

Jump to

Keyboard shortcuts

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