photoprism/internal/config/ffmpeg_test.go

45 lines
1.2 KiB
Go
Raw Normal View History

2021-02-18 14:39:08 +01:00
package config
import (
"testing"
"github.com/photoprism/photoprism/internal/ffmpeg"
2021-02-18 14:39:08 +01:00
"github.com/stretchr/testify/assert"
)
func TestConfig_FFmpegEncoder(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, ffmpeg.SoftwareEncoder, c.FFmpegEncoder())
c.options.FFmpegEncoder = "nvidia"
assert.Equal(t, ffmpeg.NvidiaEncoder, c.FFmpegEncoder())
c.options.FFmpegEncoder = "intel"
assert.Equal(t, ffmpeg.IntelEncoder, c.FFmpegEncoder())
c.options.FFmpegEncoder = "xxx"
assert.Equal(t, ffmpeg.SoftwareEncoder, c.FFmpegEncoder())
c.options.FFmpegEncoder = ""
assert.Equal(t, ffmpeg.SoftwareEncoder, c.FFmpegEncoder())
2021-02-18 14:39:08 +01:00
}
2021-08-24 19:09:09 +02:00
func TestConfig_FFmpegEnabled(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, true, c.FFmpegEnabled())
c.options.DisableFFmpeg = true
assert.Equal(t, false, c.FFmpegEnabled())
}
2021-02-18 14:39:08 +01:00
func TestConfig_FFmpegBitrate(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, 50, c.FFmpegBitrate())
c.options.FFmpegBitrate = 1000
assert.Equal(t, 960, c.FFmpegBitrate())
c.options.FFmpegBitrate = -5
assert.Equal(t, 50, c.FFmpegBitrate())
c.options.FFmpegBitrate = 800
assert.Equal(t, 800, c.FFmpegBitrate())
}