mirror of
https://github.com/photoprism/photoprism.git
synced 2025-09-26 21:01:58 +08:00
FFmpeg: Refactor internal/ffmpeg/transcode_cmd.go #4604
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -21,15 +21,15 @@ func TranscodeCmd(srcName, destName string, opt encode.Options) (cmd *exec.Cmd,
|
||||
return nil, false, fmt.Errorf("empty destination filename")
|
||||
}
|
||||
|
||||
// Don't transcode more than one video at the same time.
|
||||
// Prevents multiple videos from being transcoded at the same time.
|
||||
useMutex = true
|
||||
|
||||
// Use default FFmpeg command name.
|
||||
// Use the default binary name if no name is specified.
|
||||
if opt.Bin == "" {
|
||||
opt.Bin = DefaultBin
|
||||
}
|
||||
|
||||
// Don't use hardware transcoding for animated images.
|
||||
// Always use software encoder for transcoding animated pictures into videos.
|
||||
if fs.TypeAnimated[fs.FileType(srcName)] != "" {
|
||||
cmd = exec.Command(
|
||||
opt.Bin,
|
||||
@@ -46,27 +46,23 @@ func TranscodeCmd(srcName, destName string, opt encode.Options) (cmd *exec.Cmd,
|
||||
return cmd, useMutex, nil
|
||||
}
|
||||
|
||||
// Display encoder info.
|
||||
// Log encoder name if it is not the default.
|
||||
if opt.Encoder != encode.SoftwareAvc {
|
||||
log.Infof("convert: ffmpeg encoder %s selected", opt.Encoder.String())
|
||||
}
|
||||
|
||||
// Transcode video with selected encoder.
|
||||
switch opt.Encoder {
|
||||
case encode.IntelAvc:
|
||||
cmd = intel.TranscodeToAvcCmd(srcName, destName, opt)
|
||||
|
||||
case encode.AppleAvc:
|
||||
cmd = apple.TranscodeToAvcCmd(srcName, destName, opt)
|
||||
|
||||
case encode.VaapiAvc:
|
||||
cmd = vaapi.TranscodeToAvcCmd(srcName, destName, opt)
|
||||
|
||||
case encode.NvidiaAvc:
|
||||
cmd = nvidia.TranscodeToAvcCmd(srcName, destName, opt)
|
||||
|
||||
case encode.V4LAvc:
|
||||
cmd = v4l.TranscodeToAvcCmd(srcName, destName, opt)
|
||||
|
||||
default:
|
||||
cmd = encode.TranscodeToAvcCmd(srcName, destName, opt)
|
||||
}
|
||||
|
Reference in New Issue
Block a user