Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
parent
0814d26536
commit
f0e25cb1e9
4 changed files with 6 additions and 3 deletions
|
@ -17,6 +17,8 @@ func (o Options) VideoFilter(format PixelFormat) string {
|
|||
// scale specifies the FFmpeg downscale filter, see http://trac.ffmpeg.org/wiki/Scaling.
|
||||
if format == "" {
|
||||
return fmt.Sprintf("scale='if(gte(iw,ih), min(%d, iw), -2):if(gte(iw,ih), -2, min(%d, ih))'", o.Size, o.Size)
|
||||
} else if format == FormatQSV {
|
||||
return fmt.Sprintf("vpp_qsv=framerate=30,scale_qsv=w='if(gte(iw,ih), min(%d, iw), -1)':h='if(gte(iw,ih), -1, min(%d, ih))'", o.Size, o.Size)
|
||||
} else {
|
||||
return fmt.Sprintf("scale='if(gte(iw,ih), min(%d, iw), -2):if(gte(iw,ih), -2, min(%d, ih))',format=%s", o.Size, o.Size, format)
|
||||
}
|
||||
|
|
|
@ -53,10 +53,11 @@ func AvcConvertCommand(fileName, avcName string, opt Options) (result *exec.Cmd,
|
|||
result = exec.Command(
|
||||
ffmpeg,
|
||||
"-hwaccel", "qsv",
|
||||
"-hwaccel_output_format", "qsv",
|
||||
"-qsv_device", "/dev/dri/renderD128",
|
||||
"-i", fileName,
|
||||
"-c:a", "aac",
|
||||
// "-vf", opt.VideoFilter(FormatRGB32), // TODO: Add filter for downscaling of videos with Intel QSV.
|
||||
"-vf", opt.VideoFilter(FormatQSV),
|
||||
"-c:v", opt.Encoder.String(),
|
||||
"-map", opt.MapVideo,
|
||||
"-map", opt.MapAudio,
|
||||
|
|
|
@ -79,7 +79,7 @@ func TestAvcConvertCommand(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, "/usr/bin/ffmpeg -hwaccel qsv -qsv_device /dev/dri/renderD128 -i VID123.mov -c:a aac -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 vpp_qsv=framerate=30,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())
|
||||
})
|
||||
t.Run("h264_videotoolbox", func(t *testing.T) {
|
||||
Options := Options{
|
||||
|
|
|
@ -11,6 +11,6 @@ func (f PixelFormat) String() string {
|
|||
// Standard pixel formats.
|
||||
const (
|
||||
FormatYUV420P PixelFormat = "yuv420p"
|
||||
FormatRGB32 PixelFormat = "rgb32"
|
||||
FormatNV12 PixelFormat = "nv12,hwupload"
|
||||
FormatQSV PixelFormat = "qsv"
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue