Skip to content

Commit 091d9e3

Browse files
committed
Use low-power VAAPI H264 encoding
1 parent 65e8127 commit 091d9e3

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

internal/transcode/ffmpeg_args_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,29 @@ func TestBuildFFmpegArgsDoesNotForceVAAPIH264Profile(t *testing.T) {
228228
}
229229
}
230230

231+
func TestBuildFFmpegArgsUsesVAAPILowPowerEncoding(t *testing.T) {
232+
session := &Session{
233+
ID: "item123",
234+
Dir: t.TempDir(),
235+
}
236+
request := Request{InputURL: "http://upstream/stream"}
237+
238+
for _, pipeline := range []string{"vaapi-full", "vaapi-encode"} {
239+
t.Run(pipeline, func(t *testing.T) {
240+
args := buildFFmpegArgs(session, request, FFmpegOptions{
241+
HardwareDecode: "vaapi",
242+
HardwareDevice: "/dev/dri/renderD128",
243+
HardwarePipeline: pipeline,
244+
})
245+
246+
lowPowerIndex := slices.Index(args, "-low_power")
247+
if lowPowerIndex < 0 || args[lowPowerIndex+1] != "1" {
248+
t.Fatalf("VAAPI pipeline should request low-power encoding: %v", args)
249+
}
250+
})
251+
}
252+
}
253+
231254
func TestBuildFFmpegArgsCapsVideoOutputTo1080p(t *testing.T) {
232255
session := &Session{
233256
ID: "item123",

internal/transcode/manager.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,7 @@ func appendVideoTranscodeArgs(args []string, options FFmpegOptions) []string {
12491249
case "vaapi-full":
12501250
return append(args,
12511251
"-c:v", "h264_vaapi",
1252+
"-low_power", "1",
12521253
"-g", strconv.Itoa(lowLatencyGOP),
12531254
"-keyint_min", strconv.Itoa(lowLatencyGOP),
12541255
"-bf", "0",
@@ -1258,6 +1259,7 @@ func appendVideoTranscodeArgs(args []string, options FFmpegOptions) []string {
12581259
return append(args,
12591260
"-vf", softwareScaleFilter(maxTranscodeWidth, maxTranscodeHeight)+",format=nv12,hwupload",
12601261
"-c:v", "h264_vaapi",
1262+
"-low_power", "1",
12611263
"-level", "4.1",
12621264
"-g", strconv.Itoa(lowLatencyGOP),
12631265
"-keyint_min", strconv.Itoa(lowLatencyGOP),

0 commit comments

Comments
 (0)