mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Improve hwaccel error logic
This commit is contained in:
parent
de3013eebf
commit
2cacd94f41
@ -1,12 +1,32 @@
|
|||||||
package src
|
package src
|
||||||
|
|
||||||
import "log"
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
func DetectHardwareAccel() HwAccelT {
|
func DetectHardwareAccel() HwAccelT {
|
||||||
name := GetEnvOr("GOTRANSCODER_HWACCEL", "disabled")
|
name := GetEnvOr("GOTRANSCODER_HWACCEL", "disabled")
|
||||||
log.Printf("Using hardware acceleration: %s", name)
|
log.Printf("Using hardware acceleration: %s", name)
|
||||||
|
|
||||||
switch name {
|
switch name {
|
||||||
|
case "default":
|
||||||
|
return HwAccelT{
|
||||||
|
Name: "disabled",
|
||||||
|
DecodeFlags: []string{},
|
||||||
|
EncodeFlags: []string{
|
||||||
|
"-c:v", "libx264",
|
||||||
|
// superfast or ultrafast would produce a file extremly big so we prever veryfast or faster.
|
||||||
|
"-preset", "faster",
|
||||||
|
// sc_threshold is a scene detection mechanisum used to create a keyframe when the scene changes
|
||||||
|
// this is on by default and inserts keyframes where we don't want to (it also breaks force_key_frames)
|
||||||
|
// we disable it to prevents whole scenes from behing removed due to the -f segment failing to find the corresonding keyframe
|
||||||
|
"-sc_threshold", "0",
|
||||||
|
},
|
||||||
|
// we could put :force_original_aspect_ratio=decrease:force_divisible_by=2 here but we already calculate a correct width and
|
||||||
|
// aspect ratio in our code so there is no need.
|
||||||
|
ScaleFilter: "scale=%d:%d",
|
||||||
|
}
|
||||||
case "nvidia":
|
case "nvidia":
|
||||||
return HwAccelT{
|
return HwAccelT{
|
||||||
Name: "nvidia",
|
Name: "nvidia",
|
||||||
@ -28,21 +48,8 @@ func DetectHardwareAccel() HwAccelT {
|
|||||||
ScaleFilter: "scale_cuda=%d:%d",
|
ScaleFilter: "scale_cuda=%d:%d",
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return HwAccelT{
|
log.Printf("No hardware accelerator named: %s", name)
|
||||||
Name: "disabled",
|
os.Exit(2)
|
||||||
DecodeFlags: []string{},
|
panic("unreachable")
|
||||||
EncodeFlags: []string{
|
|
||||||
"-c:v", "libx264",
|
|
||||||
// superfast or ultrafast would produce a file extremly big so we prever veryfast or faster.
|
|
||||||
"-preset", "faster",
|
|
||||||
// sc_threshold is a scene detection mechanisum used to create a keyframe when the scene changes
|
|
||||||
// this is on by default and inserts keyframes where we don't want to (it also breaks force_key_frames)
|
|
||||||
// we disable it to prevents whole scenes from behing removed due to the -f segment failing to find the corresonding keyframe
|
|
||||||
"-sc_threshold", "0",
|
|
||||||
},
|
|
||||||
// we could put :force_original_aspect_ratio=decrease:force_divisible_by=2 here but we already calculate a correct width and
|
|
||||||
// aspect ratio in our code so there is no need.
|
|
||||||
ScaleFilter: "scale=%d:%d",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user