package ffmpeg
import "go.mau.fi/util/ffmpeg"
Index ¶
- func ConvertBytes(ctx context.Context, data []byte, outputExtension string, inputArgs []string, outputArgs []string, inputMime string) ([]byte, error)
- func ConvertPath(ctx context.Context, inputFile string, outputExtension string, inputArgs []string, outputArgs []string, removeInput bool) (string, error)
- func ConvertPathWithDestination(ctx context.Context, inputFile string, outputFile string, inputArgs []string, outputArgs []string, removeInput bool) error
- func ProbeSupported() bool
- func SetPath(path string)
- func SetProbePath(path string)
- func Supported() bool
- type Disposition
- type Format
- type ProbeResult
- type Stream
Functions ¶
func ConvertBytes ¶
func ConvertBytes(ctx context.Context, data []byte, outputExtension string, inputArgs []string, outputArgs []string, inputMime string) ([]byte, error)
ConvertBytes converts media data using ffmpeg.
Args: * data: The media data to convert * outputExtension: The extension that the output file should be. * inputArgs: Arguments to tell ffmpeg how to parse the input file. * outputArgs: Arguments to tell ffmpeg how to convert the file to reach the wanted output. * inputMime: The mimetype of the input data.
Returns: the converted data
func ConvertPath ¶
func ConvertPath(ctx context.Context, inputFile string, outputExtension string, inputArgs []string, outputArgs []string, removeInput bool) (string, error)
ConvertPath converts a media file on the disk using ffmpeg and auto-generates the output file name.
Args: * inputFile: The full path to the file. * outputExtension: The extension that the output file should be. * inputArgs: Arguments to tell ffmpeg how to parse the input file. * outputArgs: Arguments to tell ffmpeg how to convert the file to reach the wanted output. * removeInput: Whether the input file should be removed after converting.
Returns: the path to the converted file.
func ConvertPathWithDestination ¶
func ConvertPathWithDestination(ctx context.Context, inputFile string, outputFile string, inputArgs []string, outputArgs []string, removeInput bool) error
ConvertPathWithDestination converts a media file on the disk using ffmpeg and saves the result to the provided file name.
Args: * inputFile: The full path to the file. * outputFile: The full path to the output file. Must include the appropriate extension so ffmpeg knows what to convert to. * inputArgs: Arguments to tell ffmpeg how to parse the input file. * outputArgs: Arguments to tell ffmpeg how to convert the file to reach the wanted output. * removeInput: Whether the input file should be removed after converting.
func ProbeSupported ¶
func ProbeSupported() bool
func SetPath ¶
func SetPath(path string)
SetPath overrides the path to the ffmpeg binary.
func SetProbePath ¶
func SetProbePath(path string)
SetPath overrides the path to the ffprobe binary.
func Supported ¶
func Supported() bool
Supported returns whether ffmpeg is available on the system.
ffmpeg is considered to be available if a binary called ffmpeg is found in $PATH, or if SetPath has been called explicitly with a non-empty path.
Types ¶
type Disposition ¶
type 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"`
NonDiegetic int `json:"non_diegetic"`
Captions int `json:"captions"`
Descriptions int `json:"descriptions"`
Metadata int `json:"metadata"`
Dependent int `json:"dependent"`
StillImage int `json:"still_image"`
}
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"`
StartTime float64 `json:"start_time,string"`
Duration float64 `json:"duration,string"`
Size int `json:"size,string"`
BitRate int `json:"bit_rate,string"`
ProbeScore int `json:"probe_score"`
Tags map[string]string `json:"tags"`
}
type ProbeResult ¶
func Probe ¶
func Probe(ctx context.Context, path string) (*ProbeResult, error)
type Stream ¶
type Stream struct {
Index int `json:"index"`
CodecName string `json:"codec_name"`
CodecLongName string `json:"codec_long_name"`
Profile string `json:"profile"`
CodecType string `json:"codec_type"`
CodecTagString string `json:"codec_tag_string"`
CodecTag string `json:"codec_tag"`
Width int `json:"width"`
Height int `json:"height"`
CodedWidth int `json:"coded_width"`
CodedHeight int `json:"coded_height"`
ClosedCaptions int `json:"closed_captions"`
FilmGrain int `json:"film_grain"`
HasBFrames int `json:"has_b_frames"`
PixFmt string `json:"pix_fmt"`
Level int `json:"level"`
ColorRange string `json:"color_range"`
ColorSpace string `json:"color_space"`
ColorTransfer string `json:"color_transfer"`
ColorPrimaries string `json:"color_primaries"`
ChromaLocation string `json:"chroma_location"`
FieldOrder string `json:"field_order"`
Refs int `json:"refs"`
IsAvc string `json:"is_avc"`
NalLengthSize string `json:"nal_length_size"`
ID string `json:"id"`
RFrameRate string `json:"r_frame_rate"`
AvgFrameRate string `json:"avg_frame_rate"`
TimeBase string `json:"time_base"`
StartPts int `json:"start_pts"`
StartTime float64 `json:"start_time,string"`
DurationTS int `json:"duration_ts"`
Duration float64 `json:"duration,string"`
BitRate int `json:"bit_rate,string"`
BitsPerRawSample int `json:"bits_per_raw_sample,string"`
NumberOfFrames int `json:"nb_frames,string"`
ExtradataSize int `json:"extradata_size"`
Disposition Disposition `json:"disposition"`
Tags map[string]string `json:"tags"`
SampleFormat string `json:"sample_fmt"`
SampleRate int `json:"sample_rate,string"`
Channels int `json:"channels"`
ChannelLayout string `json:"channel_layout"`
BitsPerSample int `json:"bits_per_sample"`
InitialPadding int `json:"initial_padding"`
}
Source Files ¶
convert.go probe.go
- Version
- v0.8.6 (latest)
- Published
- Mar 16, 2025
- Platform
- linux/amd64
- Imports
- 11 packages
- Last checked
- 1 year ago –
Tools for package owners.