Added VAAPI encoder support

This commit is contained in:
blue-kaleidoscope 2022-09-16 14:14:49 +02:00 committed by Michael Mayer
parent 3718fca957
commit c2e1989dad
2 changed files with 21 additions and 3 deletions

View file

@ -85,12 +85,13 @@ services:
## Run/install on first startup (options: update gpu tensorflow davfs clitools clean):
# PHOTOPRISM_INIT: "gpu tensorflow"
## Hardware Video Transcoding (optional):
# PHOTOPRISM_FFMPEG_ENCODER: "nvidia" # FFmpeg encoder ("software", "intel", "nvidia", "apple", "raspberry")
# PHOTOPRISM_FFMPEG_ENCODER: "intel" # FFmpeg encoder ("software", "intel", "nvidia", "apple", "raspberry")
# PHOTOPRISM_FFMPEG_ENCODER: "nvidia" # FFmpeg encoder ("software", "intel", "nvidia", "apple", "raspberry", "vaapi") Intel: "intel" for Broadwell or later and "vaapi" for Haswell or earlier
# PHOTOPRISM_FFMPEG_ENCODER: "intel" # FFmpeg encoder ("software", "intel", "nvidia", "apple", "raspberry", "vaapi") Intel: "intel" for Broadwell or later and "vaapi" for Haswell or earlier`
# PHOTOPRISM_FFMPEG_BITRATE: "32" # FFmpeg encoding bitrate limit in Mbit/s (default: 50)
# LIBVA_DRIVER_NAME: "i965" # For Intel architectures Haswell and older which do not support QSV yet but use VAAPI instead
## Share hardware devices with FFmpeg and TensorFlow (optional):
# devices:
# - "/dev/dri:/dev/dri" # Intel QSV
# - "/dev/dri:/dev/dri" # Intel QSV (Broadwell and later) or VAAPI (Haswell and earlier)
# - "/dev/nvidia0:/dev/nvidia0" # Nvidia CUDA
# - "/dev/nvidiactl:/dev/nvidiactl"
# - "/dev/nvidia-modeset:/dev/nvidia-modeset"

View file

@ -78,6 +78,23 @@ func AvcConvertCommand(fileName, avcName, ffmpegBin, bitrate string, encoder Avc
avcName,
)
case VAAPIEncoder:
format := "format=nv12,hwupload"
result = exec.Command(
ffmpegBin,
"-hwaccel", "vaapi",
"-i", fileName,
"-c:a", "aac",
"-vf", format,
"-c:v", string(encoder),
"-vsync", "vfr",
"-r", "30",
"-b:v", bitrate,
"-f", "mp4",
"-y",
avcName,
)
case NvidiaEncoder:
// ffmpeg -hide_banner -h encoder=h264_nvenc
result = exec.Command(