ffmpeg

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2020 License: AGPL-3.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FrameRegex = regexp.MustCompile(`frame=\s*([0-9]+)`)
View Source
var TimeRegex = regexp.MustCompile(`time=\s*(\d+):(\d+):(\d+.\d+)`)
View Source
var ValidCodecs = []string{"h264", "h265", "vp8", "vp9"}

Functions

func Download

func Download(configDirectory string) error

func GetFrameFromRegex

func GetFrameFromRegex(str string) int

func GetPaths

func GetPaths(configDirectory string) (string, string)

func GetTimeFromRegex

func GetTimeFromRegex(str string) float64

func IsValidCodec

func IsValidCodec(codecName string) bool

func KillRunningEncoders

func KillRunningEncoders(path string)

Types

type Encoder

type Encoder struct {
	Path string
}

func NewEncoder

func NewEncoder(ffmpegPath string) Encoder

func (*Encoder) SceneMarkerImage

func (e *Encoder) SceneMarkerImage(probeResult VideoFile, options SceneMarkerOptions) error

func (*Encoder) SceneMarkerVideo

func (e *Encoder) SceneMarkerVideo(probeResult VideoFile, options SceneMarkerOptions) error

func (*Encoder) ScenePreviewVideoChunk

func (e *Encoder) ScenePreviewVideoChunk(probeResult VideoFile, options ScenePreviewChunkOptions)

func (*Encoder) ScenePreviewVideoChunkCombine

func (e *Encoder) ScenePreviewVideoChunkCombine(probeResult VideoFile, concatFilePath string, outputPath string)

func (*Encoder) ScenePreviewVideoToImage

func (e *Encoder) ScenePreviewVideoToImage(probeResult VideoFile, width int, videoPreviewPath string, outputPath string) error

func (*Encoder) Screenshot

func (e *Encoder) Screenshot(probeResult VideoFile, options ScreenshotOptions)

func (*Encoder) StreamTranscode

func (e *Encoder) StreamTranscode(probeResult VideoFile, startTime string, maxTranscodeSize models.StreamingResolutionEnum) (io.ReadCloser, *os.Process, error)

func (*Encoder) Transcode

func (e *Encoder) Transcode(probeResult VideoFile, options TranscodeOptions)

type FFProbeJSON

type FFProbeJSON struct {
	Format struct {
		BitRate        string `json:"bit_rate"`
		Duration       string `json:"duration"`
		Filename       string `json:"filename"`
		FormatLongName string `json:"format_long_name"`
		FormatName     string `json:"format_name"`
		NbPrograms     int    `json:"nb_programs"`
		NbStreams      int    `json:"nb_streams"`
		ProbeScore     int    `json:"probe_score"`
		Size           string `json:"size"`
		StartTime      string `json:"start_time"`
		Tags           struct {
			CompatibleBrands string          `json:"compatible_brands"`
			CreationTime     models.JSONTime `json:"creation_time"`
			Encoder          string          `json:"encoder"`
			MajorBrand       string          `json:"major_brand"`
			MinorVersion     string          `json:"minor_version"`
			Title            string          `json:"title"`
			Comment          string          `json:"comment"`
		} `json:"tags"`
	} `json:"format"`
	Streams []FFProbeStream `json:"streams"`
	Error   struct {
		Code   int    `json:"code"`
		String string `json:"string"`
	} `json:"error"`
}

type FFProbeStream

type FFProbeStream struct {
	AvgFrameRate       string `json:"avg_frame_rate"`
	BitRate            string `json:"bit_rate"`
	BitsPerRawSample   string `json:"bits_per_raw_sample,omitempty"`
	ChromaLocation     string `json:"chroma_location,omitempty"`
	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,omitempty"`
	CodedWidth         int    `json:"coded_width,omitempty"`
	DisplayAspectRatio string `json:"display_aspect_ratio,omitempty"`
	Disposition        struct {
		AttachedPic     int `json:"attached_pic"`
		CleanEffects    int `json:"clean_effects"`
		Comment         int `json:"comment"`
		Default         int `json:"default"`
		Dub             int `json:"dub"`
		Forced          int `json:"forced"`
		HearingImpaired int `json:"hearing_impaired"`
		Karaoke         int `json:"karaoke"`
		Lyrics          int `json:"lyrics"`
		Original        int `json:"original"`
		TimedThumbnails int `json:"timed_thumbnails"`
		VisualImpaired  int `json:"visual_impaired"`
	} `json:"disposition"`
	Duration          string `json:"duration"`
	DurationTs        int    `json:"duration_ts"`
	HasBFrames        int    `json:"has_b_frames,omitempty"`
	Height            int    `json:"height,omitempty"`
	Index             int    `json:"index"`
	IsAvc             string `json:"is_avc,omitempty"`
	Level             int    `json:"level,omitempty"`
	NalLengthSize     string `json:"nal_length_size,omitempty"`
	NbFrames          string `json:"nb_frames"`
	PixFmt            string `json:"pix_fmt,omitempty"`
	Profile           string `json:"profile"`
	RFrameRate        string `json:"r_frame_rate"`
	Refs              int    `json:"refs,omitempty"`
	SampleAspectRatio string `json:"sample_aspect_ratio,omitempty"`
	StartPts          int    `json:"start_pts"`
	StartTime         string `json:"start_time"`
	Tags              struct {
		CreationTime models.JSONTime `json:"creation_time"`
		HandlerName  string          `json:"handler_name"`
		Language     string          `json:"language"`
		Rotate       string          `json:"rotate"`
	} `json:"tags"`
	TimeBase      string `json:"time_base"`
	Width         int    `json:"width,omitempty"`
	BitsPerSample int    `json:"bits_per_sample,omitempty"`
	ChannelLayout string `json:"channel_layout,omitempty"`
	Channels      int    `json:"channels,omitempty"`
	MaxBitRate    string `json:"max_bit_rate,omitempty"`
	SampleFmt     string `json:"sample_fmt,omitempty"`
	SampleRate    string `json:"sample_rate,omitempty"`
}

type SceneMarkerOptions

type SceneMarkerOptions struct {
	ScenePath  string
	Seconds    int
	Width      int
	OutputPath string
}

type ScenePreviewChunkOptions

type ScenePreviewChunkOptions struct {
	Time       int
	Width      int
	OutputPath string
}

type ScreenshotOptions

type ScreenshotOptions struct {
	OutputPath string
	Quality    int
	Time       float64
	Width      int
	Verbosity  string
}

type TranscodeOptions

type TranscodeOptions struct {
	OutputPath       string
	MaxTranscodeSize models.StreamingResolutionEnum
}

type VideoFile

type VideoFile struct {
	JSON        FFProbeJSON
	AudioStream *FFProbeStream
	VideoStream *FFProbeStream

	Path         string
	Title        string
	Comment      string
	Container    string
	Duration     float64
	StartTime    float64
	Bitrate      int64
	Size         int64
	CreationTime time.Time

	VideoCodec   string
	VideoBitrate int64
	Width        int
	Height       int
	FrameRate    float64
	Rotation     int64

	AudioCodec string
}

func NewVideoFile

func NewVideoFile(ffprobePath string, videoPath string) (*VideoFile, error)

Execute exec command and bind result to struct.

func (*VideoFile) GetAudioStream

func (v *VideoFile) GetAudioStream() *FFProbeStream

func (*VideoFile) GetVideoStream

func (v *VideoFile) GetVideoStream() *FFProbeStream

func (*VideoFile) SetTitleFromPath

func (v *VideoFile) SetTitleFromPath()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳