ffmpeg

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	QualityPresetsList = []string{"144p", "240p", "360p", "480p", "720p", "720p+60fps", "1080p", "1080p+60fps", "4k", "4k+60fps"}
	QualityPresetsMap  = map[string]OutputQuality{
		"144p": {
			Width:            256,
			Height:           144,
			VideoBitRateKilo: 90,
			AudioBitRateKilo: 32,
			QualityLevel:     24,
			FrameRate:        30,
		},
		"240p": {
			Width:            426,
			Height:           240,
			VideoBitRateKilo: 300,
			AudioBitRateKilo: 64,
			QualityLevel:     28,
			FrameRate:        30,
		},
		"360p": {
			Width:            640,
			Height:           360,
			VideoBitRateKilo: 700,
			AudioBitRateKilo: 96,
			QualityLevel:     24,
			FrameRate:        30,
		},
		"480p": {
			Width:            850,
			Height:           480,
			VideoBitRateKilo: 1400,
			AudioBitRateKilo: 128,
			QualityLevel:     24,
			FrameRate:        30,
		},
		"720p": {
			Width:            1280,
			Height:           720,
			VideoBitRateKilo: 2850,
			AudioBitRateKilo: 128,
			QualityLevel:     24,
			FrameRate:        30,
		},
		"720p+60fps": {
			Width:            1280,
			Height:           720,
			VideoBitRateKilo: 3950,
			AudioBitRateKilo: 128,
			QualityLevel:     20,
			FrameRate:        60,
		},
		"1080p": {
			Width:            1920,
			Height:           1080,
			VideoBitRateKilo: 4900,
			AudioBitRateKilo: 192,
			QualityLevel:     20,
			FrameRate:        30,
		},
		"1080p+60fps": {
			Width:            1920,
			Height:           1080,
			VideoBitRateKilo: 660,
			AudioBitRateKilo: 192,
			QualityLevel:     20,
			FrameRate:        60,
		},
		"4k": {
			Width:            3840,
			Height:           2160,
			VideoBitRateKilo: 14000,
			AudioBitRateKilo: 192,
			QualityLevel:     18,
			FrameRate:        30,
		},
		"4k+60fps": {
			Width:            3840,
			Height:           2160,
			VideoBitRateKilo: 25000,
			AudioBitRateKilo: 192,
			QualityLevel:     18,
			FrameRate:        60,
		},
	}
)

package wide var(s)

View Source
var VideoCodecs = map[string]string{
	"h264": "libx264",
	"h265": "libx265",
}

VideoCodecs currently supported video codecs

Functions

func GenerateHLSPlaylist added in v0.1.0

func GenerateHLSPlaylist(input *HLSBuilderInput) (string, error)

GenerateHLSPlaylist generate a HLS playlist from a video input

func Transform

func Transform(input *TransformInput) error

Transform applies the specified transformations on the video file

Types

type HLSBuilderInput added in v0.1.0

type HLSBuilderInput struct {
	InputFilename          string
	OutputDirectory        string
	SegmentDurationSeconds int64
	Quality                map[string]OutputQuality
	QualityPresets         []string
}

HLSBuilderInput represents the input for the HLS builder

type InspectInput

type InspectInput struct {
	Filename            string
	ExtractThumbnail    bool
	ThumbnailTimeOffset string
	ThumbnailWidth      int64
	ThumbnailHeight     int64
}

InspectInput the input used to extract the media information

type InspectOutput

type InspectOutput struct {
	Duration float64 `json:"duration"`
	Size     struct {
		Bytes float64 `json:"bytes"`
		Human string  `json:"human"`
	} `json:"size"`
	BitRate   int64         `json:"bit_rate"`
	Thumbnail string        `json:"thumbnail,omitempty"`
	Streams   []*StreamMeta `json:"streams"`
}

InspectOutput represents a media file info

func Inspect

func Inspect(input *InspectInput) (*InspectOutput, error)

Inspect returns a media file information

func (*InspectOutput) String

func (info *InspectOutput) String() string

type OutputQuality added in v0.1.0

type OutputQuality struct {
	Width            int64
	Height           int64
	VideoBitRateKilo int64
	AudioBitRateKilo int64
	QualityLevel     int64
	FrameRate        int64
}

OutputQuality represents the quality configs

type StreamMeta

type StreamMeta struct {
	Index       int64     `json:"index"`
	Type        string    `json:"type"`
	Codec       string    `json:"codec"`
	Width       int64     `json:"width,omitempty"`
	Height      int64     `json:"height,omitempty"`
	AspectRatio string    `json:"aspect_ratio,omitempty"`
	StartTime   float64   `json:"start_time"`
	Duration    float64   `json:"duration"`
	BitRate     int64     `json:"bit_rate"`
	FramesCount int64     `json:"frames_count,omitempty"`
	CreatedAt   time.Time `json:"created_at,omitempty"`
}

StreamMeta represents a stream in a media file

type TransformInput

type TransformInput struct {
	OutputQuality
	VideoCodec     string
	FrameRate      int64
	InputFilename  string
	OutputFilename string
}

TransformInput represents the input used to transform (compress, resize) a video

Jump to

Keyboard shortcuts

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