Documentation ¶
Index ¶
- Constants
- func Concat(dir, dst string) error
- func ConcatByFile(filePath, dst string) error
- func GetFrame(src string, f Frame) error
- func H264ToH265ByIntelGPU(filePath, dst string) error
- func ImgToAvif(filePath, dst string, crf, cpuUsed int) error
- func ImgToHeic(filePath, dst string) error
- func ImgToJxl(filePath, dst string) error
- func ImgToWebp(filePath, dst string, quality int) error
- func ImgToWebpLossless(filePath, dst string) error
- func SetExecPath(path string)
- func ToAV1ByLibaomav1(filePath, dst string, crf, cpuUsed int) error
- func ToH264ByXlib264(filePath, dst string, crf int, perset PerSet) error
- func ToH265ByXlib265(filePath, dst string, crf int, perset PerSet) error
- func TransferFormat(filePath, dst string) error
- func TransferFormatGPU(filePath, dst string) error
- type Config
- type Frame
- type PerSet
Constants ¶
const CommonCmd = ` -i "%s" -y `
const ConcatCmd = ` -f concat -safe 0 -i "%s" -c copy -y "%s"`
const GetFrameCmd = CommonCmd + `-vf "select=eq(pict_type\,%s)" -fps_mode vfr -qscale:v 2 -f image2 %s/%%03d.jpg`
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"`
const ImgToHeicCmd = CommonCmd + `-crf 20 -c:v libx265 -preset veryslow %s.mp4`
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"`
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"
`
const ImgToJxlCmd = CommonCmd + `-c:v libjxl "%s.jxl"`
const ImgToTAvifCmd = CommonCmd + `-c:v libaom-av1 -crf %d -cpu-used %d -row-mt 1 "%s.avif"`
const ImgToWebpCmd = CommonCmd + `-c:v libwebp -quality %d "%s.webp"`
const ImgToWebpLosslessCmd = CommonCmd + `-c:v libwebp -lossless 1 -quality 100 -compression_level 6 "%s.webp"`
webp 无损模式
const ResizeCmd = CommonCmd + `-vf "scale=iw*.5:ih*.5" %s`
const ToAv1Libaomav1Cmd = CommonCmd + `-c:v libaom-av1 -crf %d -cpu-used %d -row-mt 1 -y "%s"`
libaom-av1
const ToH264Cmd = CommonCmd + `-c:v libx264 -profile high -preset %s -crf %d -y "%s"`
libx264
const ToH265Cmd = CommonCmd + `-c:v libx265 -preset %s -crf %d -y "%s"`
libx265
const TransferFormatCmd = CommonCmd + ` -c copy -y "%s"`
const TransferFormatGPUCmd = ` -hwaccel qsv -i "%s" -c copy -y "%s"`
Variables ¶
This section is empty.
Functions ¶
func ConcatByFile ¶
func H264ToH265ByIntelGPU ¶
func ImgToJxl ¶
不可用,没有注明色彩空间的原因。需要显式写明 像素编码格式、色彩空间、转换色彩空间、目标色彩空间、色彩范围
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 ¶
JPEG 采用的色彩格式是 YUVJ420P,对应的色彩区间是 0-255,而 WebP 采用的色彩格式是 YUV420P,对应的色彩区间是 16-235,也就是说如果单纯的转码,会丢失 0-15,236-255 的色彩,也就是出现了色差, 颜色空间转移:RGB < - > YUV,这会产生一些舍入误差 多次压缩后webp会出现明显色差,真的会偏绿
图片带选项转webp格式,选项目前支持质量(0-100),ffmpeg默认75 quality推荐75
func SetExecPath ¶
func SetExecPath(path string)
func ToAV1ByLibaomav1 ¶
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 ¶
crf推荐18
func ToH265ByXlib265 ¶
crf推荐23