Videos: Increase transcoding bitrate limit default to 60 Mbps #1307

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-04-24 11:59:29 +02:00
parent 9e39b2f81d
commit f73b703123
26 changed files with 72 additions and 61 deletions

View File

@@ -67,7 +67,7 @@ services:
# PHOTOPRISM_INIT: "tensorflow-amd64-avx2"
## Hardware video transcoding config (optional):
# PHOTOPRISM_FFMPEG_BUFFERS: "64" # FFmpeg capture buffers (default: 32)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # FFmpeg encoding bitrate limit in Mbit/s (default: 50)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # FFmpeg encoding bitrate limit in Mbps (default: 60)
# PHOTOPRISM_FFMPEG_ENCODER: "h264_v4l2m2m" # Use Video4Linux for AVC transcoding (default: libx264)
# PHOTOPRISM_FFMPEG_ENCODER: "h264_qsv" # Use Intel Quick Sync Video for AVC transcoding (default: libx264)
# PHOTOPRISM_INIT: "intel-graphics tensorflow-amd64-avx2" # Enable TensorFlow AVX2 & Intel Graphics support

View File

@@ -113,7 +113,7 @@ services:
## Intel Quick Sync Video (QSV) (https://docs.photoprism.app/getting-started/advanced/transcoding/#intel-quick-sync):
PHOTOPRISM_FFMPEG_ENCODER: "intel" # H.264/AVC encoder (software, intel, nvidia, apple, raspberry, or vaapi)
PHOTOPRISM_FFMPEG_SIZE: "1920" # video size limit in pixels (720-7680) (default: 3840)
PHOTOPRISM_FFMPEG_BITRATE: "50" # video bitrate limit in Mbit/s (default: 50)
# PHOTOPRISM_FFMPEG_BITRATE: "60" # video bitrate limit in Mbps (default: 60)
## Run/install on first startup (options: update https gpu ffmpeg tensorflow davfs clitools clean):
PHOTOPRISM_INIT: "https intel tensorflow"
## Share hardware devices with FFmpeg for hardware video transcoding:

View File

@@ -117,7 +117,7 @@ services:
NVIDIA_DRIVER_CAPABILITIES: "all"
PHOTOPRISM_FFMPEG_ENCODER: "nvidia" # H.264/AVC encoder (software, intel, nvidia, apple, raspberry, or vaapi)
PHOTOPRISM_FFMPEG_SIZE: "1920" # video size limit in pixels (720-7680) (default: 3840)
PHOTOPRISM_FFMPEG_BITRATE: "50" # video bitrate limit in Mbit/s (default: 50)
# PHOTOPRISM_FFMPEG_BITRATE: "60" # video bitrate limit in Mbps (default: 60)
## Run/install on first startup (options: update https gpu ffmpeg tensorflow davfs clitools clean):
PHOTOPRISM_INIT: "https tensorflow"
## Share hardware devices with FFmpeg and TensorFlow (optional):

View File

@@ -121,9 +121,9 @@ services:
TF_CPP_MIN_LOG_LEVEL: 1 # show TensorFlow log messages for development
## Video Transcoding (https://docs.photoprism.app/getting-started/advanced/transcoding/):
# PHOTOPRISM_FFMPEG_ENCODER: "software" # H.264/AVC encoder (software, intel, nvidia, apple, raspberry, or vaapi)
# PHOTOPRISM_FFMPEG_SIZE: "1920" # video size limit in pixels (720-7680) (default: 3840)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video 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
PHOTOPRISM_FFMPEG_SIZE: "1920" # video size limit in pixels (720-7680) (default: 3840)
# PHOTOPRISM_FFMPEG_BITRATE: "60" # video bitrate limit in Mbps (default: 60)
## Run/install on first startup (options: update https gpu ffmpeg tensorflow davfs clitools clean):
PHOTOPRISM_INIT: "https"
## Share hardware devices with FFmpeg and TensorFlow (optional):

View File

@@ -133,8 +133,9 @@ func GetVideo(router *gin.RouterGroup) {
// Verify video format support and compatibility.
supported := video.Compatible(videoContentType, format.ContentType)
// Check video bitrate against the configured limit.
transcode := !supported || conf.FFmpegEnabled() && conf.FFmpegBitrateExceeded(videoBitrate)
// Check video bitrate against the configured limit
bitrateExceeded := conf.FFmpegEnabled() && conf.FFmpegBitrateExceeded(videoBitrate)
transcode := !supported || bitrateExceeded
if mediaFile, mediaErr := photoprism.NewMediaFile(videoFileName); mediaErr != nil {
// Set missing flag so that the file doesn't show up in search results anymore.
@@ -145,12 +146,21 @@ func GetVideo(router *gin.RouterGroup) {
AbortVideo(c)
return
} else if transcode {
if supported && bitrateExceeded {
log.Debugf(
"video: %s has content type %s and cannot be streamed directly, average bitrate %.1f MBit/s",
"video: %s has an average bitrate of %.1f Mbps, which exceeds the %d Mbps limit",
clean.Log(f.FileName),
videoBitrate,
conf.FFmpegBitrate(),
)
} else {
log.Debugf(
"video: %s has content type %s and cannot be streamed directly (average bitrate %.1f Mbps)",
clean.Log(f.FileName),
clean.Log(videoContentType),
videoBitrate,
)
}
conv := get.Convert()
@@ -173,7 +183,7 @@ func GetVideo(router *gin.RouterGroup) {
}
log.Debugf(
"video: %s has content type %s, average bitrate %.1f MBit/s",
"video: %s has content type %s (average bitrate %.1f Mbps)",
clean.Log(f.FileName),
clean.Log(contentType),
videoBitrate,

View File

@@ -33,11 +33,11 @@ func (c *Config) FFmpegSize() int {
return thumb.VideoSize(c.options.FFmpegSize).Width
}
// FFmpegBitrate returns the ffmpeg bitrate limit in MBit/s.
// FFmpegBitrate returns the ffmpeg bitrate limit in Mbps.
func (c *Config) FFmpegBitrate() int {
switch {
case c.options.FFmpegBitrate <= 0:
return 50
return 60
case c.options.FFmpegBitrate >= 960:
return 960
default:
@@ -45,14 +45,14 @@ func (c *Config) FFmpegBitrate() int {
}
}
// FFmpegBitrateExceeded tests if the ffmpeg bitrate limit is exceeded.
func (c *Config) FFmpegBitrateExceeded(mbit float64) bool {
if mbit <= 0 {
// FFmpegBitrateExceeded tests if the ffmpeg bitrate limit in Mbps is exceeded.
func (c *Config) FFmpegBitrateExceeded(bitrate float64) bool {
if bitrate <= 0 {
return false
} else if max := c.FFmpegBitrate(); max <= 0 {
} else if limit := c.FFmpegBitrate(); limit <= 0 {
return false
} else {
return mbit > float64(max)
return bitrate > float64(limit)
}
}

View File

@@ -32,13 +32,13 @@ func TestConfig_FFmpegEnabled(t *testing.T) {
func TestConfig_FFmpegBitrate(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, 50, c.FFmpegBitrate())
assert.Equal(t, 60, c.FFmpegBitrate())
c.options.FFmpegBitrate = 1000
assert.Equal(t, 960, c.FFmpegBitrate())
c.options.FFmpegBitrate = -5
assert.Equal(t, 50, c.FFmpegBitrate())
assert.Equal(t, 60, c.FFmpegBitrate())
c.options.FFmpegBitrate = 800
assert.Equal(t, 800, c.FFmpegBitrate())

View File

@@ -808,8 +808,8 @@ var Flags = CliFlags{
Flag: &cli.IntFlag{
Name: "ffmpeg-bitrate",
Aliases: []string{"vb"},
Usage: "maximum video `BITRATE` in Mbit/s",
Value: 50,
Usage: "maximum video `BITRATE` in Mbps",
Value: 60,
EnvVars: EnvVars("FFMPEG_BITRATE"),
}}, {
Flag: &cli.StringFlag{

View File

@@ -718,7 +718,7 @@ func (m *File) SetDuration(d time.Duration) {
}
}
// Bitrate returns the average bitrate in MBit/s if the file has a duration.
// Bitrate returns the average bitrate in Mbps if the file has a duration.
func (m *File) Bitrate() float64 {
// Return 0 if file size or video duration are unknown.
if m.FileSize <= 0 || m.FileDuration <= 0 {

View File

@@ -35,7 +35,7 @@ func NewVideoOptions(ffmpegBin string, encoder Encoder, sizeLimit int, bitrateLi
}
if bitrateLimit == "" {
bitrateLimit = "50M"
bitrateLimit = "60M"
}
if mapVideo == "" {

View File

@@ -13,7 +13,7 @@ func TestNewOptions(t *testing.T) {
assert.Equal(t, FFmpegBin, opt.Bin)
assert.Equal(t, DefaultAvcEncoder(), opt.Encoder)
assert.Equal(t, 1920, opt.SizeLimit)
assert.Equal(t, "50M", opt.BitrateLimit)
assert.Equal(t, "60M", opt.BitrateLimit)
assert.Equal(t, "0:v:0", opt.MapVideo)
assert.Equal(t, "0:a:0?", opt.MapAudio)
assert.Equal(t, MapVideo, opt.MapVideo)
@@ -27,7 +27,7 @@ func TestOptions_VideoFilter(t *testing.T) {
Bin: "",
Encoder: "intel",
SizeLimit: 1500,
BitrateLimit: "50M",
BitrateLimit: "60M",
MapVideo: "",
MapAudio: "",
MovFlags: "",

View File

@@ -15,19 +15,19 @@ func TestTranscodeCmd(t *testing.T) {
ffmpegBin := "/usr/bin/ffmpeg"
t.Run("NoSource", func(t *testing.T) {
opt := encode.NewVideoOptions("", encode.IntelAvc, 1500, "50M", "", "")
opt := encode.NewVideoOptions("", encode.IntelAvc, 1500, "60M", "", "")
_, _, err := TranscodeCmd("", "", opt)
assert.Equal(t, "empty source filename", err.Error())
})
t.Run("NoDestination", func(t *testing.T) {
opt := encode.NewVideoOptions("", encode.IntelAvc, 1500, "50M", "", "")
opt := encode.NewVideoOptions("", encode.IntelAvc, 1500, "60M", "", "")
_, _, err := TranscodeCmd("VID123.mov", "", opt)
assert.Equal(t, "empty destination filename", err.Error())
})
t.Run("Animation", func(t *testing.T) {
opt := encode.NewVideoOptions("", encode.IntelAvc, 1500, "50M", "", "")
opt := encode.NewVideoOptions("", encode.IntelAvc, 1500, "60M", "", "")
r, _, err := TranscodeCmd("VID123.gif", "VID123.gif.avc", opt)
if err != nil {
@@ -37,7 +37,7 @@ func TestTranscodeCmd(t *testing.T) {
assert.Contains(t, r.String(), "bin/ffmpeg -y -strict -2 -i VID123.gif -pix_fmt yuv420p -vf scale='trunc(iw/2)*2:trunc(ih/2)*2' -f mp4 -movflags +faststart VID123.gif.avc")
})
t.Run("VP9toAVC", func(t *testing.T) {
opt := encode.NewVideoOptions(ffmpegBin, encode.SoftwareAvc, 1500, "50M", "", "")
opt := encode.NewVideoOptions(ffmpegBin, encode.SoftwareAvc, 1500, "60M", "", "")
srcName := fs.Abs("./testdata/25fps.vp9")
destName := fs.Abs("./testdata/25fps.avc")
@@ -52,13 +52,13 @@ func TestTranscodeCmd(t *testing.T) {
cmdStr = strings.Replace(cmdStr, srcName, "SRC", 1)
cmdStr = strings.Replace(cmdStr, destName, "DEST", 1)
assert.Equal(t, "/usr/bin/ffmpeg -y -strict -2 -i SRC -c:v libx264 -map 0:v:0 -map 0:a:0? -c:a aac -vf scale='if(gte(iw,ih), min(1500, iw), -2):if(gte(iw,ih), -2, min(1500, ih))',format=yuv420p -max_muxing_queue_size 1024 -crf 23 -r 30 -b:v 50M -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart DEST", cmdStr)
assert.Equal(t, "/usr/bin/ffmpeg -y -strict -2 -i SRC -c:v libx264 -map 0:v:0 -map 0:a:0? -c:a aac -vf scale='if(gte(iw,ih), min(1500, iw), -2):if(gte(iw,ih), -2, min(1500, ih))',format=yuv420p -max_muxing_queue_size 1024 -crf 23 -r 30 -b:v 60M -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart DEST", cmdStr)
// Run generated command to test software transcoding.
RunCommandTest(t, opt.Encoder, srcName, destName, cmd, true)
})
t.Run("Vaapi", func(t *testing.T) {
opt := encode.NewVideoOptions(ffmpegBin, encode.VaapiAvc, 1500, "50M", "", "")
opt := encode.NewVideoOptions(ffmpegBin, encode.VaapiAvc, 1500, "60M", "", "")
srcName := fs.Abs("./testdata/25fps.vp9")
destName := fs.Abs("./testdata/25fps.vaapi.avc")
@@ -73,7 +73,7 @@ func TestTranscodeCmd(t *testing.T) {
cmdStr = strings.Replace(cmdStr, srcName, "SRC", 1)
cmdStr = strings.Replace(cmdStr, destName, "DEST", 1)
assert.Equal(t, "/usr/bin/ffmpeg -y -strict -2 -hwaccel vaapi -i SRC -c:a aac -vf scale='if(gte(iw,ih), min(1500, iw), -2):if(gte(iw,ih), -2, min(1500, ih))',format=nv12,hwupload -c:v h264_vaapi -map 0:v:0 -map 0:a:0? -r 30 -b:v 50M -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart DEST", cmdStr)
assert.Equal(t, "/usr/bin/ffmpeg -y -strict -2 -hwaccel vaapi -i SRC -c:a aac -vf scale='if(gte(iw,ih), min(1500, iw), -2):if(gte(iw,ih), -2, min(1500, ih))',format=nv12,hwupload -c:v h264_vaapi -map 0:v:0 -map 0:a:0? -r 30 -b:v 60M -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart DEST", cmdStr)
// This transcoding test requires a supported hardware device that is properly configured:
if os.Getenv("PHOTOPRISM_FFMPEG_ENCODER") == "vaapi" {
@@ -81,7 +81,7 @@ func TestTranscodeCmd(t *testing.T) {
}
})
t.Run("IntelHvc", func(t *testing.T) {
opt := encode.NewVideoOptions(ffmpegBin, encode.IntelAvc, 1500, "50M", "", "")
opt := encode.NewVideoOptions(ffmpegBin, encode.IntelAvc, 1500, "60M", "", "")
// QuickTime MOV container with HVC1 (HEVC) codec.
srcName := fs.Abs("./testdata/30fps.mov")
@@ -97,7 +97,7 @@ func TestTranscodeCmd(t *testing.T) {
cmdStr = strings.Replace(cmdStr, srcName, "SRC", 1)
cmdStr = strings.Replace(cmdStr, destName, "DEST", 1)
assert.Equal(t, "/usr/bin/ffmpeg -y -strict -2 -hwaccel qsv -hwaccel_output_format qsv -i SRC -c:a aac -vf scale_qsv=w='if(gte(iw,ih), min(1500, iw), -1)':h='if(gte(iw,ih), -1, min(1500, ih))':format=nv12 -c:v h264_qsv -map 0:v:0 -map 0:a:0? -r 30 -b:v 50M -bitrate 50M -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart DEST", cmdStr)
assert.Equal(t, "/usr/bin/ffmpeg -y -strict -2 -hwaccel qsv -hwaccel_output_format qsv -i SRC -c:a aac -vf scale_qsv=w='if(gte(iw,ih), min(1500, iw), -1)':h='if(gte(iw,ih), -1, min(1500, ih))':format=nv12 -c:v h264_qsv -map 0:v:0 -map 0:a:0? -r 30 -b:v 60M -bitrate 60M -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart DEST", cmdStr)
// This transcoding test requires a supported hardware device that is properly configured:
if os.Getenv("PHOTOPRISM_FFMPEG_ENCODER") == "intel" {
@@ -105,7 +105,7 @@ func TestTranscodeCmd(t *testing.T) {
}
})
t.Run("IntelVp9", func(t *testing.T) {
opt := encode.NewVideoOptions(ffmpegBin, encode.IntelAvc, 1500, "50M", "", "")
opt := encode.NewVideoOptions(ffmpegBin, encode.IntelAvc, 1500, "60M", "", "")
srcName := fs.Abs("./testdata/25fps.vp9")
destName := fs.Abs("./testdata/25fps.intel.avc")
@@ -120,7 +120,7 @@ func TestTranscodeCmd(t *testing.T) {
cmdStr = strings.Replace(cmdStr, srcName, "SRC", 1)
cmdStr = strings.Replace(cmdStr, destName, "DEST", 1)
assert.Equal(t, "/usr/bin/ffmpeg -y -strict -2 -hwaccel qsv -hwaccel_output_format qsv -i SRC -c:a aac -vf scale_qsv=w='if(gte(iw,ih), min(1500, iw), -1)':h='if(gte(iw,ih), -1, min(1500, ih))':format=nv12 -c:v h264_qsv -map 0:v:0 -map 0:a:0? -r 30 -b:v 50M -bitrate 50M -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart DEST", cmdStr)
assert.Equal(t, "/usr/bin/ffmpeg -y -strict -2 -hwaccel qsv -hwaccel_output_format qsv -i SRC -c:a aac -vf scale_qsv=w='if(gte(iw,ih), min(1500, iw), -1)':h='if(gte(iw,ih), -1, min(1500, ih))':format=nv12 -c:v h264_qsv -map 0:v:0 -map 0:a:0? -r 30 -b:v 60M -bitrate 60M -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart DEST", cmdStr)
// This transcoding test requires a supported hardware device that is properly configured:
if os.Getenv("PHOTOPRISM_FFMPEG_ENCODER") == "intel" {
@@ -128,7 +128,7 @@ func TestTranscodeCmd(t *testing.T) {
}
})
t.Run("NvidiaHvc", func(t *testing.T) {
opt := encode.NewVideoOptions(ffmpegBin, encode.NvidiaAvc, 1500, "50M", "", "")
opt := encode.NewVideoOptions(ffmpegBin, encode.NvidiaAvc, 1500, "60M", "", "")
// QuickTime MOV container with HVC1 (HEVC) codec.
srcName := fs.Abs("./testdata/30fps.mov")
@@ -144,7 +144,7 @@ func TestTranscodeCmd(t *testing.T) {
cmdStr = strings.Replace(cmdStr, srcName, "SRC", 1)
cmdStr = strings.Replace(cmdStr, destName, "DEST", 1)
assert.Equal(t, "/usr/bin/ffmpeg -y -strict -2 -hwaccel auto -i SRC -pix_fmt yuv420p -c:v h264_nvenc -map 0:v:0 -map 0:a:0? -c:a aac -preset 15 -pixel_format yuv420p -gpu any -vf scale='if(gte(iw,ih), min(1500, iw), -2):if(gte(iw,ih), -2, min(1500, ih))',format=yuv420p -rc:v constqp -cq 0 -tune 2 -r 30 -b:v 50M -profile:v 1 -level:v auto -coder:v 1 -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart DEST", cmdStr)
assert.Equal(t, "/usr/bin/ffmpeg -y -strict -2 -hwaccel auto -i SRC -pix_fmt yuv420p -c:v h264_nvenc -map 0:v:0 -map 0:a:0? -c:a aac -preset 15 -pixel_format yuv420p -gpu any -vf scale='if(gte(iw,ih), min(1500, iw), -2):if(gte(iw,ih), -2, min(1500, ih))',format=yuv420p -rc:v constqp -cq 0 -tune 2 -r 30 -b:v 60M -profile:v 1 -level:v auto -coder:v 1 -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart DEST", cmdStr)
// This transcoding test requires a supported hardware device that is properly configured:
if os.Getenv("PHOTOPRISM_FFMPEG_ENCODER") == "nvidia" {
@@ -152,7 +152,7 @@ func TestTranscodeCmd(t *testing.T) {
}
})
t.Run("NvidiaVp9", func(t *testing.T) {
opt := encode.NewVideoOptions(ffmpegBin, encode.NvidiaAvc, 1500, "50M", "", "")
opt := encode.NewVideoOptions(ffmpegBin, encode.NvidiaAvc, 1500, "60M", "", "")
srcName := fs.Abs("./testdata/25fps.vp9")
destName := fs.Abs("./testdata/25fps.nvidia.avc")
@@ -167,7 +167,7 @@ func TestTranscodeCmd(t *testing.T) {
cmdStr = strings.Replace(cmdStr, srcName, "SRC", 1)
cmdStr = strings.Replace(cmdStr, destName, "DEST", 1)
assert.Equal(t, "/usr/bin/ffmpeg -y -strict -2 -hwaccel auto -i SRC -pix_fmt yuv420p -c:v h264_nvenc -map 0:v:0 -map 0:a:0? -c:a aac -preset 15 -pixel_format yuv420p -gpu any -vf scale='if(gte(iw,ih), min(1500, iw), -2):if(gte(iw,ih), -2, min(1500, ih))',format=yuv420p -rc:v constqp -cq 0 -tune 2 -r 30 -b:v 50M -profile:v 1 -level:v auto -coder:v 1 -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart DEST", cmdStr)
assert.Equal(t, "/usr/bin/ffmpeg -y -strict -2 -hwaccel auto -i SRC -pix_fmt yuv420p -c:v h264_nvenc -map 0:v:0 -map 0:a:0? -c:a aac -preset 15 -pixel_format yuv420p -gpu any -vf scale='if(gte(iw,ih), min(1500, iw), -2):if(gte(iw,ih), -2, min(1500, ih))',format=yuv420p -rc:v constqp -cq 0 -tune 2 -r 30 -b:v 60M -profile:v 1 -level:v auto -coder:v 1 -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart DEST", cmdStr)
// This transcoding test requires a supported hardware device that is properly configured:
if os.Getenv("PHOTOPRISM_FFMPEG_ENCODER") == "nvidia" {
@@ -175,23 +175,23 @@ func TestTranscodeCmd(t *testing.T) {
}
})
t.Run("Apple", func(t *testing.T) {
opt := encode.NewVideoOptions("", encode.AppleAvc, 1500, "50M", "", "")
opt := encode.NewVideoOptions("", encode.AppleAvc, 1500, "60M", "", "")
r, _, err := TranscodeCmd("VID123.mov", "VID123.mov.avc", opt)
if err != nil {
t.Fatal(err)
}
assert.Contains(t, r.String(), "bin/ffmpeg -y -strict -2 -i VID123.mov -c:v h264_videotoolbox -map 0:v:0 -map 0:a:0? -c:a aac -vf scale='if(gte(iw,ih), min(1500, iw), -2):if(gte(iw,ih), -2, min(1500, ih))',format=yuv420p -profile high -level 51 -r 30 -b:v 50M -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart VID123.mov.avc")
assert.Contains(t, r.String(), "bin/ffmpeg -y -strict -2 -i VID123.mov -c:v h264_videotoolbox -map 0:v:0 -map 0:a:0? -c:a aac -vf scale='if(gte(iw,ih), min(1500, iw), -2):if(gte(iw,ih), -2, min(1500, ih))',format=yuv420p -profile high -level 51 -r 30 -b:v 60M -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart VID123.mov.avc")
})
t.Run("Video4Linux", func(t *testing.T) {
opt := encode.NewVideoOptions("", encode.V4LAvc, 1500, "50M", "", "")
opt := encode.NewVideoOptions("", encode.V4LAvc, 1500, "60M", "", "")
r, _, err := TranscodeCmd("VID123.mov", "VID123.mov.avc", opt)
if err != nil {
t.Fatal(err)
}
assert.Contains(t, r.String(), "bin/ffmpeg -y -strict -2 -i VID123.mov -c:v h264_v4l2m2m -map 0:v:0 -map 0:a:0? -c:a aac -vf scale='if(gte(iw,ih), min(1500, iw), -2):if(gte(iw,ih), -2, min(1500, ih))',format=yuv420p -num_output_buffers 72 -num_capture_buffers 64 -max_muxing_queue_size 1024 -crf 23 -r 30 -b:v 50M -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart VID123.mov.avc")
assert.Contains(t, r.String(), "bin/ffmpeg -y -strict -2 -i VID123.mov -c:v h264_v4l2m2m -map 0:v:0 -map 0:a:0? -c:a aac -vf scale='if(gte(iw,ih), min(1500, iw), -2):if(gte(iw,ih), -2, min(1500, ih))',format=yuv420p -num_output_buffers 72 -num_capture_buffers 64 -max_muxing_queue_size 1024 -crf 23 -r 30 -b:v 60M -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof+faststart VID123.mov.avc")
})
}

View File

@@ -133,7 +133,7 @@ func TestConvert_AvcBitrate(t *testing.T) {
mf.width = 4096
mf.height = 2160
assert.Equal(t, "50M", convert.AvcBitrate(mf))
assert.Equal(t, "60M", convert.AvcBitrate(mf))
})
}

View File

@@ -112,6 +112,7 @@ func TestContentType(t *testing.T) {
func TestCompatible(t *testing.T) {
t.Run("True", func(t *testing.T) {
assert.True(t, Compatible(header.ContentTypeWebm, "video/webm"))
assert.True(t, Compatible(header.ContentTypeAv1, "video/av1"))
assert.True(t, Compatible(header.ContentTypeAv1, "Video/Av1"))
assert.True(t, Compatible(header.ContentTypeJpeg, header.ContentTypeJpeg))

View File

@@ -54,7 +54,7 @@ func (info Info) VideoSize() int64 {
return info.FileSize - info.VideoOffset
}
// VideoBitrate returns the bitrate of the embedded video in MBit/s.
// VideoBitrate returns the bitrate of the embedded video in Mbps.
func (info Info) VideoBitrate() float64 {
videoSize := info.VideoSize()

View File

@@ -98,7 +98,7 @@ services:
## Video Transcoding (https://docs.photoprism.app/getting-started/advanced/transcoding/):
# PHOTOPRISM_FFMPEG_ENCODER: "software" # H.264/AVC encoder (software, intel, nvidia, apple, raspberry, or vaapi)
# PHOTOPRISM_FFMPEG_SIZE: "1920" # video size limit in pixels (720-7680) (default: 3840)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbit/s (default: 50)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbps (default: 60)
## Optional commands to run during the first start, see https://github.com/photoprism/photoprism/blob/develop/scripts/dist/Makefile:
# PHOTOPRISM_INIT: "update clean"
## Run as a non-root user after initialization (supported: 0, 33, 50-99, 500-600, and 900-1200):

View File

@@ -92,7 +92,7 @@ services:
## Video Transcoding (https://docs.photoprism.app/getting-started/advanced/transcoding/):
# PHOTOPRISM_FFMPEG_ENCODER: "software" # H.264/AVC encoder (software, intel, nvidia, apple, raspberry, or vaapi)
# PHOTOPRISM_FFMPEG_SIZE: "1920" # video size limit in pixels (720-7680) (default: 3840)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbit/s (default: 50)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbps (default: 60)
## Optional commands to run during the first start, see https://github.com/photoprism/photoprism/blob/develop/scripts/dist/Makefile:
# PHOTOPRISM_INIT: "update clean"
## Run as a non-root user after initialization (supported: 0, 33, 50-99, 500-600, and 900-1200):

View File

@@ -164,7 +164,7 @@ services:
## Video Transcoding (https://docs.photoprism.app/getting-started/advanced/transcoding/):
# PHOTOPRISM_FFMPEG_ENCODER: "software" # H.264/AVC encoder (software, intel, nvidia, apple, raspberry, or vaapi)
# PHOTOPRISM_FFMPEG_SIZE: "1920" # video size limit in pixels (720-7680) (default: 3840)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbit/s (default: 50)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbps (default: 60)
## Optional commands to run during the first start, see https://github.com/photoprism/photoprism/blob/develop/scripts/dist/Makefile:
PHOTOPRISM_INIT: "update tensorflow clean"
working_dir: "/photoprism" # do not change or remove

View File

@@ -88,7 +88,7 @@ services:
## Video Transcoding (https://docs.photoprism.app/getting-started/advanced/transcoding/):
# PHOTOPRISM_FFMPEG_ENCODER: "software" # H.264/AVC encoder (software, intel, nvidia, apple, raspberry, or vaapi)
# PHOTOPRISM_FFMPEG_SIZE: "1920" # video size limit in pixels (720-7680) (default: 3840)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbit/s (default: 50)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbps (default: 60)
## Optional commands to run during the first start, see https://github.com/photoprism/photoprism/blob/develop/scripts/dist/Makefile:
# PHOTOPRISM_INIT: "https gpu tensorflow"
## Run as a non-root user after initialization (supported: 0, 33, 50-99, 500-600, and 900-1200):

View File

@@ -82,7 +82,7 @@ services:
## Video Transcoding (https://docs.photoprism.app/getting-started/advanced/transcoding/):
# PHOTOPRISM_FFMPEG_ENCODER: "software" # H.264/AVC encoder (software, intel, nvidia, apple, raspberry, or vaapi)
# PHOTOPRISM_FFMPEG_SIZE: "1920" # video size limit in pixels (720-7680) (default: 3840)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbit/s (default: 50)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbps (default: 60)
## Optional commands to run during the first start, see https://github.com/photoprism/photoprism/blob/develop/scripts/dist/Makefile:
# PHOTOPRISM_INIT: "https gpu tensorflow"
## Storage Folders: "~" is a shortcut for your home directory, "." for the current directory

View File

@@ -92,7 +92,7 @@ services:
## Hardware Video Transcoding (https://docs.photoprism.app/getting-started/advanced/transcoding/):
PHOTOPRISM_FFMPEG_ENCODER: "nvidia" # H.264/AVC encoder (software, intel, nvidia, apple, raspberry, or vaapi)
# PHOTOPRISM_FFMPEG_SIZE: "1920" # video size limit in pixels (720-7680) (default: 3840)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbit/s (default: 50)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbps (default: 60)
NVIDIA_VISIBLE_DEVICES: "all"
NVIDIA_DRIVER_CAPABILITIES: "compute,video,utility"
## Optional commands to run during the first start, see https://github.com/photoprism/photoprism/blob/develop/scripts/dist/Makefile:

View File

@@ -68,7 +68,7 @@ PHOTOPRISM_SITE_AUTHOR=
## Video Transcoding (https://docs.photoprism.app/getting-started/advanced/transcoding/):
# PHOTOPRISM_FFMPEG_ENCODER=software # H.264/AVC encoder (software, intel, nvidia, apple, raspberry, or vaapi)
# PHOTOPRISM_FFMPEG_SIZE=1920 # video size limit in pixels (720-7680) (default: 3840)
# PHOTOPRISM_FFMPEG_BITRATE=32 # video bitrate limit in Mbit/s (default: 50)
# PHOTOPRISM_FFMPEG_BITRATE=32 # video bitrate limit in Mbps (default: 60)
## Run/install on first startup (options: update https gpu ffmpeg tensorflow davfs clitools clean):
# PHOTOPRISM_INIT=https gpu tensorflow
## Run as a non-root user after initialization (supported: 0, 33, 50-99, 500-600, and 900-1200):

View File

@@ -86,7 +86,7 @@ services:
## Video Transcoding (https://docs.photoprism.app/getting-started/advanced/transcoding/):
# PHOTOPRISM_FFMPEG_ENCODER: "software" # H.264/AVC encoder (software, intel, nvidia, apple, raspberry, or vaapi)
# PHOTOPRISM_FFMPEG_SIZE: "1920" # video size limit in pixels (720-7680) (default: 3840)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbit/s (default: 50)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbps (default: 60)
## Optional commands to run during the first start, see https://github.com/photoprism/photoprism/blob/develop/scripts/dist/Makefile:
# PHOTOPRISM_INIT: "https gpu tensorflow"
## Run as a non-root user after initialization (supported: 0, 33, 50-99, 500-600, and 900-1200):

View File

@@ -79,7 +79,7 @@ services:
## Video Transcoding (https://docs.photoprism.app/getting-started/advanced/transcoding/):
# PHOTOPRISM_FFMPEG_ENCODER: "software" # H.264/AVC encoder (software, intel, nvidia, apple, raspberry, or vaapi)
# PHOTOPRISM_FFMPEG_SIZE: "1920" # video size limit in pixels (720-7680) (default: 3840)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbit/s (default: 50)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbps (default: 60)
## Optional commands to run during the first start, see https://github.com/photoprism/photoprism/blob/develop/scripts/dist/Makefile:
# PHOTOPRISM_INIT: "https gpu tensorflow"
## Run as a non-root user after initialization (supported: 0, 33, 50-99, 500-600, and 900-1200):

View File

@@ -89,7 +89,7 @@ services:
## Video Transcoding (https://docs.photoprism.app/getting-started/advanced/transcoding/):
# PHOTOPRISM_FFMPEG_ENCODER: "software" # H.264/AVC encoder (software, intel, nvidia, apple, raspberry, or vaapi)
# PHOTOPRISM_FFMPEG_SIZE: "1920" # video size limit in pixels (720-7680) (default: 3840)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbit/s (default: 50)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbps (default: 60)
working_dir: "/photoprism" # do not change or remove
## Storage Folders: use "/" not "\" as separator, "~" is a shortcut for C:/user/{username}, "." for the current directory
volumes:

View File

@@ -97,7 +97,7 @@ services:
## Video Transcoding (https://docs.photoprism.app/getting-started/advanced/transcoding/):
# PHOTOPRISM_FFMPEG_ENCODER: "software" # H.264/AVC encoder (software, intel, nvidia, apple, raspberry, or vaapi)
# PHOTOPRISM_FFMPEG_SIZE: "1920" # video size limit in pixels (720-7680) (default: 3840)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbit/s (default: 50)
# PHOTOPRISM_FFMPEG_BITRATE: "32" # video bitrate limit in Mbps (default: 60)
## Optional commands to run during the first start, see https://github.com/photoprism/photoprism/blob/develop/scripts/dist/Makefile:
# PHOTOPRISM_INIT: "https gpu tensorflow"
## Run as a non-root user after initialization (supported: 0, 33, 50-99, 500-600, and 900-1200):