tgvideo

package
v0.0.0-...-c47d08d Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(opts ...*Opt) tg.VideoModifier

Convert is a general purpose VideoModifier, converts a video to h264, could decrease its dimensions. REQUIRES `ffmpeg` on the system, which could be passed via Opt.Convert.

func ConvertByCopy

func ConvertByCopy(opts ...*Opt) tg.VideoModifier

ConvertByCopy allows to upload .webm, .m4v and other video formats without re-encoding. REQUIRES `ffmpeg` on the system.

func ConvertIfNeeded

func ConvertIfNeeded(opts ...*Opt) tg.VideoModifier

ConvertIfNeeded ensures a video is converted to a type supported by Telegram. REQUIRES `ffmpeg` on the system, which could be passed via Opt.Convert.

func EmbedMetadata

func EmbedMetadata[T any](meta T, opts ...*Opt) tg.VideoModifier

EmbedMetadata into a file before sending. REQUIRES `ffmpeg` on the system, which could be passed via Opt.Convert

func EnsureMeta

func EnsureMeta(opts ...*Opt) tg.VideoModifier

EnsureMeta ensures, Telegram would process a file correctly. REQUIRES `ffprobe` on the system, which could be passed via Opt.Convert

func ExtractMetadata

func ExtractMetadata[T any](filename string, opts ...*Opt) (T, error)

ExtractMetadata gets you metadata at format/tags/comment. It's sort of convenient, taking in mind you can't have custom metadata keys with .mp4

func ExtractMetadataAll

func ExtractMetadataAll[T any](filename string, opts ...*Opt) (*T, error)

ExtractMetadataAll gets you all metadata you would need. If you need EVERY single key-value, use ExtractMetadataAll[map[string]any](...).

func Mute

func Mute(opts ...*Opt) tg.VideoModifier

Mute a video by creating a local muted copy. REQUIRES `ffmpeg` on the system. Could be passed via Opt.Convert.

func OnError

func OnError(mod tg.VideoModifier, fn func(temporaries []string, err error) error) tg.VideoModifier

OnError allows set action on error for the wrapped tg.VideoModifier. If wrapper returns nil, the error is muted.

func ThumbnailAt

func ThumbnailAt(position interface{}, opts ...*Opt) tg.VideoModifier

ThumbnailAt creates a thumbnail from the video frame. Position could be chosen as:

  1. float64 -- from [0, 1], relative position in Video
  2. string -- position in ffmpeg format, i.e. "00:05:12.99"

REQUIRES `ffmpeg`, `ffprobe` on the system, could be passed via Opt.

func ThumbnailFrom

func ThumbnailFrom(filename string, opts ...*Opt) tg.VideoModifier

ThumbnailFrom converts a picture to a 320x320 frame, suitable from Telegram video thumbnail. REQUIRES `convert` on the system, could be passed via Opt.Convert.

Types

type Opt

type Opt struct {
	Width   int
	Height  int
	Preset  string
	Ffmpeg  string
	Ffprobe string
	Convert string
	TempDir string
}

Opt for modifiers. Not all of them are used every time.

func (*Opt) Defaults

func (opts *Opt) Defaults() *Opt

Jump to

Keyboard shortcuts

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