Videos: Add ffmpeg-codec config parameter #703

This commit is contained in:
Michael Mayer 2021-02-11 20:22:00 +01:00
parent 07ed8ed914
commit 45272cd2f5
5 changed files with 18 additions and 1 deletions

View file

@ -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.

View file

@ -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",

View file

@ -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 == "" {

View file

@ -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"`

View file

@ -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,
)