ffmpeg

package
v1.12.8 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CommonCmd = ` -i "%s" -y `
View Source
const ConcatCmd = ` -f concat -safe 0  -i "%s" -c copy -y "%s"`
View Source
const GetFrameCmd = CommonCmd + `-vf "select=eq(pict_type\,%s)" -fps_mode vfr -qscale:v 2 -f image2 %s/%%03d.jpg`
View Source
const H264ToH265ByIntelGPUCmd = `ffmpeg -hwaccel_output_format qsv -c:v h264_qsv -i %s -c:v hevc_qsv -preset veryslow -g 60 -gpu_copy 1 -c:a copy "%s"`
View Source
const ImgToHeicCmd = CommonCmd + `-crf 20 -c:v libx265 -preset veryslow %s.mp4`
View Source
const ImgToHeicCmd2 = CommonCmd + `-hide_banner -r 1 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2,zscale=m=170m:r=pc" -pix_fmt yuv420p -frames 1 -c:v libx265 -preset veryslow -crf 20 -x265-params range=full:colorprim=smpte170m "%s.hevc"`
View Source
const ImgToHeicCmd3 = CommonCmd + `-hide_banner -r 1 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2,zscale=m=170m:r=pc" -pix_fmt yuv420p -frames 1 -c:v libx265 -preset veryslow -crf 20 -x265-params range=full:colorprim=smpte170m:aq-strength=1.2 -deblock -2:-2 "%s.hevc"
`
View Source
const ImgToJxlCmd = CommonCmd + `-c:v libjxl "%s.jxl"`
View Source
const ImgToTAvifCmd = CommonCmd + `-c:v libaom-av1 -crf %d -cpu-used %d -row-mt 1 "%s.avif"`
View Source
const ImgToWebpCmd = CommonCmd + `-c:v libwebp -quality %d "%s.webp"`
View Source
const ImgToWebpLosslessCmd = CommonCmd + `-c:v libwebp -lossless 1 -quality 100 -compression_level 6 "%s.webp"`

webp 无损模式

View Source
const ResizeCmd = CommonCmd + `-vf "scale=iw*.5:ih*.5" %s`
View Source
const ToAv1Libaomav1Cmd = CommonCmd + `-c:v libaom-av1 -crf %d -cpu-used %d -row-mt 1 -y "%s"`

libaom-av1

View Source
const ToH264Cmd = CommonCmd + `-c:v libx264 -profile high -preset %s -crf %d -y "%s"`

libx264

View Source
const ToH265Cmd = CommonCmd + `-c:v libx265 -preset %s -crf %d -y "%s"`

libx265

View Source
const TransferFormatCmd = CommonCmd + ` -c copy -y "%s"`
View Source
const TransferFormatGPUCmd = ` -hwaccel qsv -i "%s" -c copy -y "%s"`

Variables

This section is empty.

Functions

func Concat

func Concat(dir, dst string) error

func ConcatByFile

func ConcatByFile(filePath, dst string) error

func GetFrame

func GetFrame(src string, f Frame) error

func H264ToH265ByIntelGPU

func H264ToH265ByIntelGPU(filePath, dst string) error

func ImgToAvif

func ImgToAvif(filePath, dst string, crf, cpuUsed int) error

crf推荐18-28

func ImgToHeic

func ImgToHeic(filePath, dst string) error

func ImgToJxl

func ImgToJxl(filePath, dst string) error

不可用,没有注明色彩空间的原因。需要显式写明 像素编码格式、色彩空间、转换色彩空间、目标色彩空间、色彩范围

distance Set the target Butteraugli distance. This is a quality setting: lower distance yields higher quality, with distance=1.0 roughly comparable to libjpeg Quality 90 for photographic content. Setting distance=0.0 yields true lossless encoding. Valid values range between 0.0 and 15.0, and sane values rarely exceed 5.0. Setting distance=0.1 usually attains transparency for most input. The default is 1.0.

effort Set the encoding effort used. Higher effort values produce more consistent quality and usually produces a better quality/bpp curve, at the cost of more CPU time required. Valid values range from 1 to 9, and the default is 7.

modular Force the encoder to use Modular mode instead of choosing automatically. The default is to use VarDCT for lossy encoding and Modular for lossless. VarDCT is generally superior to Modular for lossy encoding but does not support lossless encoding.

func ImgToWebp

func ImgToWebp(filePath, dst string, quality int) error
JPEG 采用的色彩格式是 YUVJ420P,对应的色彩区间是 0-255,而 WebP 采用的色彩格式是 YUV420P,对应的色彩区间是 16-235,也就是说如果单纯的转码,会丢失 0-15,236-255 的色彩,也就是出现了色差, 颜色空间转移:RGB < - > YUV,这会产生一些舍入误差 多次压缩后webp会出现明显色差,真的会偏绿

图片带选项转webp格式,选项目前支持质量(0-100),ffmpeg默认75 quality推荐75

func ImgToWebpLossless

func ImgToWebpLossless(filePath, dst string) error

图片转webp格式

func SetExecPath

func SetExecPath(path string)

func ToAV1ByLibaomav1

func ToAV1ByLibaomav1(filePath, dst string, crf, cpuUsed int) error

cpu-used Set the quality/encoding speed tradeoff. Valid range is from 0 to 8, higher numbers indicating greater speed and lower quality. The default value is 1, which will be slow and high quality. row-mt 是否多线程 0否,1是 tiles 图块数,配合row-mt, axb 猜测是一帧,分成几成几的图片,如2x2就是2行2列4张图分别编码,默认为输入视频大小所需的最小图块数(对于最大 4K 和 4K 的大小,这是 1x1(即单个图块)。 很慢,cpu-used调高质量差,推荐3 crf推荐18-28

func ToH264ByXlib264

func ToH264ByXlib264(filePath, dst string, crf int, perset PerSet) error

crf推荐18

func ToH265ByXlib265

func ToH265ByXlib265(filePath, dst string, crf int, perset PerSet) error

crf推荐23

func TransferFormat

func TransferFormat(filePath, dst string) error

func TransferFormatGPU

func TransferFormatGPU(filePath, dst string) error

Types

type Frame

type Frame int
const (
	I Frame = iota
	P
	B
)

func (Frame) String

func (f Frame) String() string

type PerSet

type PerSet string
const (
	Ultrafast PerSet = "ultrafast"
	SuperFast PerSet = "superfast"
	VeryFast  PerSet = "veryfast"
	Faster    PerSet = "faster"
	Fast      PerSet = "fast"
	Medium    PerSet = "medium"
	Slow      PerSet = "slow"
	Slower    PerSet = "slower"
	VerySlow  PerSet = "veryslow"
	Placebo   PerSet = "placebo"
)

Jump to

Keyboard shortcuts

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