Documentation ¶
Overview ¶
Package ffmpeg provides FFmpeg video transcoding related types and functions.
Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved.
This program is free software: you can redistribute it and/or modify it under Version 3 of the GNU Affero General Public License (the "AGPL"): <https://docs.photoprism.app/license/agpl> This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. The AGPL is supplemented by our Trademark and Brand Guidelines, which describe how our Brand Assets may be used: <https://www.photoprism.app/trademark>
Feel free to send an email to hello@photoprism.app if you have questions, want to support our work, or just want to say hello.
Additional information can be found in our Developer Guide: <https://docs.photoprism.app/developer-guide/>
Index ¶
Constants ¶
const ( DefaultBin = "ffmpeg" MapVideoDefault = "0:v:0" MapAudioDefault = "0:a:0?" )
Variables ¶
var AvcEncoders = map[string]AvcEncoder{ "": SoftwareEncoder, "default": SoftwareEncoder, "software": SoftwareEncoder, string(SoftwareEncoder): SoftwareEncoder, "intel": IntelEncoder, "qsv": IntelEncoder, string(IntelEncoder): IntelEncoder, "apple": AppleEncoder, "osx": AppleEncoder, "mac": AppleEncoder, "macos": AppleEncoder, "darwin": AppleEncoder, string(AppleEncoder): AppleEncoder, "vaapi": VAAPIEncoder, "libva": VAAPIEncoder, string(VAAPIEncoder): VAAPIEncoder, "nvidia": NvidiaEncoder, "nvenc": NvidiaEncoder, "cuda": NvidiaEncoder, string(NvidiaEncoder): NvidiaEncoder, "v4l2": Video4LinuxEncoder, "v4l": Video4LinuxEncoder, "video4linux": Video4LinuxEncoder, "rp4": Video4LinuxEncoder, "raspberry": Video4LinuxEncoder, "raspberrypi": Video4LinuxEncoder, string(Video4LinuxEncoder): Video4LinuxEncoder, }
AvcEncoders is the list of supported H.264 encoders with aliases.
Functions ¶
func AvcConvertCommand ¶
func AvcConvertCommand(fileName, avcName string, opt Options) (result *exec.Cmd, useMutex bool, err error)
AvcConvertCommand returns the command for converting video files to MPEG-4 AVC.
func PreviewTimeOffset ¶
PreviewTimeOffset returns an appropriate time offset depending on the duration for extracting a preview image.
Types ¶
type AvcEncoder ¶
type AvcEncoder string
AvcEncoder represents a supported FFmpeg AVC encoder name.
const ( SoftwareEncoder AvcEncoder = "libx264" // SoftwareEncoder see https://trac.ffmpeg.org/wiki/HWAccelIntro. IntelEncoder AvcEncoder = "h264_qsv" // IntelEncoder is the Intel Quick Sync H.264 encoder. AppleEncoder AvcEncoder = "h264_videotoolbox" // AppleEncoder is the Apple Video Toolbox H.264 encoder. VAAPIEncoder AvcEncoder = "h264_vaapi" // VAAPIEncoder is the Video Acceleration API H.264 encoder. NvidiaEncoder AvcEncoder = "h264_nvenc" // NvidiaEncoder is the NVIDIA H.264 encoder. Video4LinuxEncoder AvcEncoder = "h264_v4l2m2m" // Video4LinuxEncoder is the Video4Linux H.264 encoder. )
Supported FFmpeg AVC encoders.
func FindEncoder ¶
func FindEncoder(s string) AvcEncoder
FindEncoder finds an FFmpeg encoder by name.
func (AvcEncoder) String ¶
func (name AvcEncoder) String() string
String returns the FFmpeg AVC encoder name as string.
type Options ¶
type Options struct { Bin string Encoder AvcEncoder Size int Bitrate string MapVideo string MapAudio string }
Options represents transcoding options.
func (Options) VideoFilter ¶
func (o Options) VideoFilter(format PixelFormat) string
VideoFilter returns the FFmpeg video filter string based on the size limit in pixels and the pixel format.
type PixelFormat ¶
type PixelFormat string
PixelFormat represents a standard pixel format.
const ( FormatYUV420P PixelFormat = "yuv420p" FormatNV12 PixelFormat = "nv12,hwupload" FormatQSV PixelFormat = "qsv" )
Standard pixel formats.
func (PixelFormat) String ¶
func (f PixelFormat) String() string
String returns the pixel format as string.