Skip to content

Commit

Permalink
Use scale_cuda in Windows (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
leszko authored Oct 2, 2023
1 parent 4fe16b9 commit 663c622
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions ffmpeg/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -461,18 +462,18 @@ func configEncoder(inOpts *TranscodeOptionsIn, outOpts TranscodeOptions) (string
if outDev != "" {
upload = upload + "=device=" + outDev
}
return encoder, upload + ",scale_npp", "super", nil
return encoder, upload + "," + hwScale(), hwScaleAlgo(), nil
}
case Nvidia:
switch outOpts.Accel {
case Software:
return encoder, "scale_npp", "super", nil
return encoder, hwScale(), hwScaleAlgo(), nil
case Nvidia:
// If we encode on a different device from decode then need to transfer
if outDev != "" && outDev != inDev {
return "", "", "", ErrTranscoderDev // XXX not allowed
}
return encoder, "scale_npp", "super", nil
return encoder, hwScale(), hwScaleAlgo(), nil
}
case Netint:
switch outOpts.Accel {
Expand Down Expand Up @@ -1134,6 +1135,24 @@ func ffmpegStrEscape(origStr string) string {
return outStr
}

func hwScale() string {
if runtime.GOOS == "windows" {
// we don't build windows binaries with CUDA SDK, so need to use scale_cuda instead of scale_npp
return "scale_cuda"
} else {
return "scale_npp"
}
}

func hwScaleAlgo() string {
if runtime.GOOS == "windows" {
// we don't build windows binaries with CUDA SDK, so need to use the default scale algorithm
return ""
} else {
return "super"
}
}

func FfmpegSetLogLevel(level int) {
C.av_log_set_level(C.int(level))
}
Expand Down

0 comments on commit 663c622

Please sign in to comment.