diff --git a/internal/commands/config.go b/internal/commands/config.go index c6eebe123..6fa4b92b5 100644 --- a/internal/commands/config.go +++ b/internal/commands/config.go @@ -112,6 +112,7 @@ func configAction(ctx *cli.Context) error { fmt.Printf("%-25s %s\n", "sips-bin", conf.SipsBin()) fmt.Printf("%-25s %s\n", "heifconvert-bin", conf.HeifConvertBin()) fmt.Printf("%-25s %s\n", "ffmpeg-bin", conf.FFmpegBin()) + fmt.Printf("%-25s %s\n", "ffmpeg-codec", conf.FFmpegCodec()) fmt.Printf("%-25s %s\n", "exiftool-bin", conf.ExifToolBin()) // Thumbs, resampling and download security token. diff --git a/internal/config/flags.go b/internal/config/flags.go index 2d2d7fb5b..500f57bd8 100644 --- a/internal/config/flags.go +++ b/internal/config/flags.go @@ -315,6 +315,12 @@ var GlobalFlags = []cli.Flag{ Value: "ffmpeg", EnvVar: "PHOTOPRISM_FFMPEG_BIN", }, + cli.StringFlag{ + Name: "ffmpeg-codec", + Usage: "FFmpeg AVC1 codec `NAME`", + Value: "libx264", + EnvVar: "PHOTOPRISM_FFMPEG_CODEC", + }, cli.StringFlag{ Name: "exiftool-bin", Usage: "ExifTool `COMMAND` for enhanced metadata extraction", diff --git a/internal/config/fs.go b/internal/config/fs.go index 2a50e185f..c78ba1b67 100644 --- a/internal/config/fs.go +++ b/internal/config/fs.go @@ -255,6 +255,15 @@ func (c *Config) FFmpegBin() string { return findExecutable(c.options.FFmpegBin, "ffmpeg") } +// FFmpegCodec returns the ffmpeg codec name. +func (c *Config) FFmpegCodec() string { + if c.options.FFmpegCodec == "" { + return "libx264" + } + + return c.options.FFmpegCodec +} + // TempPath returns a temporary directory name for uploads and downloads. func (c *Config) TempPath() string { if c.options.TempPath == "" { diff --git a/internal/config/options.go b/internal/config/options.go index 54d8bbf55..672398829 100644 --- a/internal/config/options.go +++ b/internal/config/options.go @@ -91,6 +91,7 @@ type Options struct { DarktablePresets bool `yaml:"DarktablePresets" json:"DarktablePresets" flag:"darktable-presets"` HeifConvertBin string `yaml:"HeifConvertBin" json:"-" flag:"heifconvert-bin"` FFmpegBin string `yaml:"FFmpegBin" json:"-" flag:"ffmpeg-bin"` + FFmpegCodec string `yaml:"FFmpegCodec" json:"-" flag:"ffmpeg-codec"` ExifToolBin string `yaml:"ExifToolBin" json:"-" flag:"exiftool-bin"` DetachServer bool `yaml:"DetachServer" json:"-" flag:"detach-server"` DownloadToken string `yaml:"DownloadToken" json:"-" flag:"download-token"` diff --git a/internal/photoprism/convert.go b/internal/photoprism/convert.go index 8f196056a..b8d4f247f 100644 --- a/internal/photoprism/convert.go +++ b/internal/photoprism/convert.go @@ -310,7 +310,7 @@ func (c *Convert) AvcConvertCommand(f *MediaFile, avcName string) (result *exec. result = exec.Command( c.conf.FFmpegBin(), "-i", f.FileName(), - "-c:v", "libx264", + "-c:v", c.conf.FFmpegCodec(), "-f", "mp4", avcName, )