Video: Fix bitrate flag value in convert_test.go #4030 #4052

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2024-02-07 18:17:41 +01:00
parent cb232be687
commit 2e644809f4
2 changed files with 16 additions and 16 deletions

View file

@ -11,7 +11,7 @@ func TestOptions_VideoFilter(t *testing.T) {
Bin: "", Bin: "",
Encoder: "intel", Encoder: "intel",
Size: 1500, Size: 1500,
Bitrate: "50", Bitrate: "50M",
MapVideo: "", MapVideo: "",
MapAudio: "", MapAudio: "",
} }

View file

@ -12,7 +12,7 @@ func TestAvcConvertCommand(t *testing.T) {
Bin: "", Bin: "",
Encoder: "intel", Encoder: "intel",
Size: 1500, Size: 1500,
Bitrate: "50", Bitrate: "50M",
MapVideo: MapVideoDefault, MapVideo: MapVideoDefault,
MapAudio: MapAudioDefault, MapAudio: MapAudioDefault,
} }
@ -25,7 +25,7 @@ func TestAvcConvertCommand(t *testing.T) {
Bin: "", Bin: "",
Encoder: "intel", Encoder: "intel",
Size: 1500, Size: 1500,
Bitrate: "50", Bitrate: "50M",
MapVideo: MapVideoDefault, MapVideo: MapVideoDefault,
MapAudio: MapAudioDefault, MapAudio: MapAudioDefault,
} }
@ -38,7 +38,7 @@ func TestAvcConvertCommand(t *testing.T) {
Bin: "", Bin: "",
Encoder: "intel", Encoder: "intel",
Size: 1500, Size: 1500,
Bitrate: "50", Bitrate: "50M",
MapVideo: MapVideoDefault, MapVideo: MapVideoDefault,
MapAudio: MapAudioDefault, MapAudio: MapAudioDefault,
} }
@ -54,7 +54,7 @@ func TestAvcConvertCommand(t *testing.T) {
Bin: "", Bin: "",
Encoder: "libx264", Encoder: "libx264",
Size: 1500, Size: 1500,
Bitrate: "50", Bitrate: "50M",
MapVideo: MapVideoDefault, MapVideo: MapVideoDefault,
MapAudio: MapAudioDefault, MapAudio: MapAudioDefault,
} }
@ -63,14 +63,14 @@ func TestAvcConvertCommand(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
assert.Equal(t, "/usr/bin/ffmpeg -i VID123.mov -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 50 -f mp4 -movflags +faststart -y VID123.mov.avc", r.String()) assert.Equal(t, "/usr/bin/ffmpeg -i VID123.mov -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 +faststart -y VID123.mov.avc", r.String())
}) })
t.Run("h264_qsv", func(t *testing.T) { t.Run("h264_qsv", func(t *testing.T) {
Options := Options{ Options := Options{
Bin: "", Bin: "",
Encoder: "h264_qsv", Encoder: "h264_qsv",
Size: 1500, Size: 1500,
Bitrate: "50", Bitrate: "50M",
MapVideo: MapVideoDefault, MapVideo: MapVideoDefault,
MapAudio: MapAudioDefault, MapAudio: MapAudioDefault,
} }
@ -79,14 +79,14 @@ func TestAvcConvertCommand(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
assert.Equal(t, "/usr/bin/ffmpeg -hwaccel qsv -hwaccel_output_format qsv -qsv_device /dev/dri/renderD128 -i VID123.mov -c:a aac -vf scale_qsv=w='if(gte(iw,ih), min(1500, iw), -1)':h='if(gte(iw,ih), -1, min(1500, ih))' -c:v h264_qsv -map 0:v:0 -map 0:a:0? -r 30 -b:v 50 -bitrate 50 -f mp4 -movflags +faststart -y VID123.mov.avc", r.String()) assert.Equal(t, "/usr/bin/ffmpeg -hwaccel qsv -hwaccel_output_format qsv -qsv_device /dev/dri/renderD128 -i VID123.mov -c:a aac -vf scale_qsv=w='if(gte(iw,ih), min(1500, iw), -1)':h='if(gte(iw,ih), -1, min(1500, ih))' -c:v h264_qsv -map 0:v:0 -map 0:a:0? -r 30 -b:v 50M -bitrate 50M -f mp4 -movflags +faststart -y VID123.mov.avc", r.String())
}) })
t.Run("h264_videotoolbox", func(t *testing.T) { t.Run("h264_videotoolbox", func(t *testing.T) {
Options := Options{ Options := Options{
Bin: "", Bin: "",
Encoder: "h264_videotoolbox", Encoder: "h264_videotoolbox",
Size: 1500, Size: 1500,
Bitrate: "50", Bitrate: "50M",
MapVideo: MapVideoDefault, MapVideo: MapVideoDefault,
MapAudio: MapAudioDefault, MapAudio: MapAudioDefault,
} }
@ -95,14 +95,14 @@ func TestAvcConvertCommand(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
assert.Equal(t, "/usr/bin/ffmpeg -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 50 -f mp4 -movflags +faststart -y VID123.mov.avc", r.String()) assert.Equal(t, "/usr/bin/ffmpeg -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 +faststart -y VID123.mov.avc", r.String())
}) })
t.Run("h264_vaapi", func(t *testing.T) { t.Run("h264_vaapi", func(t *testing.T) {
Options := Options{ Options := Options{
Bin: "", Bin: "",
Encoder: "h264_vaapi", Encoder: "h264_vaapi",
Size: 1500, Size: 1500,
Bitrate: "50", Bitrate: "50M",
MapVideo: MapVideoDefault, MapVideo: MapVideoDefault,
MapAudio: MapAudioDefault, MapAudio: MapAudioDefault,
} }
@ -111,14 +111,14 @@ func TestAvcConvertCommand(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
assert.Equal(t, "/usr/bin/ffmpeg -hwaccel vaapi -i VID123.mov -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 50 -f mp4 -movflags +faststart -y VID123.mov.avc", r.String()) assert.Equal(t, "/usr/bin/ffmpeg -hwaccel vaapi -i VID123.mov -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 +faststart -y VID123.mov.avc", r.String())
}) })
t.Run("h264_nvenc", func(t *testing.T) { t.Run("h264_nvenc", func(t *testing.T) {
Options := Options{ Options := Options{
Bin: "", Bin: "",
Encoder: "h264_nvenc", Encoder: "h264_nvenc",
Size: 1500, Size: 1500,
Bitrate: "50", Bitrate: "50M",
MapVideo: MapVideoDefault, MapVideo: MapVideoDefault,
MapAudio: MapAudioDefault, MapAudio: MapAudioDefault,
} }
@ -127,14 +127,14 @@ func TestAvcConvertCommand(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
assert.Equal(t, "/usr/bin/ffmpeg -hwaccel auto -i VID123.mov -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 50 -profile:v 1 -level:v auto -coder:v 1 -f mp4 -movflags +faststart -y VID123.mov.avc", r.String()) assert.Equal(t, "/usr/bin/ffmpeg -hwaccel auto -i VID123.mov -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 +faststart -y VID123.mov.avc", r.String())
}) })
t.Run("h264_v4l2m2m", func(t *testing.T) { t.Run("h264_v4l2m2m", func(t *testing.T) {
Options := Options{ Options := Options{
Bin: "", Bin: "",
Encoder: "h264_v4l2m2m", Encoder: "h264_v4l2m2m",
Size: 1500, Size: 1500,
Bitrate: "50", Bitrate: "50M",
MapVideo: MapVideoDefault, MapVideo: MapVideoDefault,
MapAudio: MapAudioDefault, MapAudio: MapAudioDefault,
} }
@ -143,6 +143,6 @@ func TestAvcConvertCommand(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
assert.Equal(t, "/usr/bin/ffmpeg -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 50 -f mp4 -movflags +faststart -y VID123.mov.avc", r.String()) assert.Equal(t, "/usr/bin/ffmpeg -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 +faststart -y VID123.mov.avc", r.String())
}) })
} }