Video: Add config option for FFmpeg num_capture_buffers #703

This commit is contained in:
Michael Mayer 2021-02-16 08:57:21 +01:00
parent 0990e54a66
commit 58005012b1
4 changed files with 23 additions and 3 deletions

View file

@ -321,6 +321,12 @@ var GlobalFlags = []cli.Flag{
Value: "libx264",
EnvVar: "PHOTOPRISM_FFMPEG_CODEC",
},
cli.IntFlag{
Name: "ffmpeg-buffers",
Usage: "FFmpeg capture buffers",
Value: 32,
EnvVar: "PHOTOPRISM_FFMPEG_BUFFERS",
},
cli.StringFlag{
Name: "exiftool-bin",
Usage: "ExifTool `COMMAND` for enhanced metadata extraction",

View file

@ -264,6 +264,19 @@ func (c *Config) FFmpegCodec() string {
return c.options.FFmpegCodec
}
// FFmpegBuffers returns the number of ffmpeg capture buffers.
func (c *Config) FFmpegBuffers() int {
if c.options.FFmpegBuffers <= 8 {
return 8
}
if c.options.FFmpegBuffers >= 2048 {
return 2048
}
return c.options.FFmpegBuffers
}
// TempPath returns a temporary directory name for uploads and downloads.
func (c *Config) TempPath() string {
if c.options.TempPath == "" {

View file

@ -91,7 +91,8 @@ 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"`
FFmpegCodec string `yaml:"FFmpegCodec" json:"FFmpegCodec" flag:"ffmpeg-codec"`
FFmpegBuffers int `yaml:"FFmpegBuffers" json:"FFmpegBuffers" flag:"ffmpeg-buffers"`
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

@ -339,8 +339,8 @@ func (c *Convert) AvcConvertCommand(f *MediaFile, avcName, codecName string) (re
"-c:v", codecName,
"-c:a", "copy",
"-vf", format,
"-num_output_buffers", "32",
"-num_capture_buffers", "32",
"-num_output_buffers", strconv.Itoa(c.conf.FFmpegBuffers()+8),
"-num_capture_buffers", strconv.Itoa(c.conf.FFmpegBuffers()),
"-crf", "23",
"-b:v", c.AvcBitrate(f),
"-f", "mp4",