Skip to content

Commit

Permalink
Merge pull request #10999 from thecodingwizard:nathan/ffmpeg-dec
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 683280522
  • Loading branch information
gvisor-bot committed Oct 7, 2024
2 parents 0fae509 + 229d01f commit cbbd0b4
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions test/gpu/ffmpeg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"gvisor.dev/gvisor/pkg/test/dockerutil"
)

// TestFffmpegGPU runs ffmpeg in a GPU container using NVENC.
func TestFffmpegGPU(t *testing.T) {
// TestFffmpegEncodeGPU runs ffmpeg in a GPU container using NVENC.
func TestFffmpegEncodeGPU(t *testing.T) {
ctx := context.Background()
isGVisor, err := dockerutil.IsGVisorRuntime(ctx, t)
if err != nil {
Expand All @@ -46,3 +46,31 @@ func TestFffmpegGPU(t *testing.T) {
t.Errorf("failed to run container: %v; output:\n%s", err, output)
}
}

// TestFffmpegDecodeGPU runs ffmpeg in a GPU container using NVDEC.
func TestFffmpegDecodeGPU(t *testing.T) {
ctx := context.Background()
isGVisor, err := dockerutil.IsGVisorRuntime(ctx, t)
if err != nil {
t.Fatalf("Failed to determine if runtime is gVisor: %v", err)
}
if isGVisor {
t.Skip("This test is currently broken in gVisor")
}
container := dockerutil.MakeContainer(ctx, t)
defer container.CleanUp(ctx)
opts, err := dockerutil.GPURunOpts(dockerutil.SniffGPUOpts{
Capabilities: "NVIDIA_DRIVER_CAPABILITIES=video",
AllowIncompatibleIoctl: true,
})
if err != nil {
t.Fatalf("Failed to get GPU run options: %v", err)
}
opts.Image = "benchmarks/ffmpeg"
// h264_cuvid refers to NVDEC. See Section 4.2 in
// https://docs.nvidia.com/video-technologies/video-codec-sdk/pdf/Using_FFmpeg_with_NVIDIA_GPU_Hardware_Acceleration.pdf
cmd := strings.Split("ffmpeg -y -vsync 0 -c:v h264_cuvid -i video.mp4 output.yuv", " ")
if output, err := container.Run(ctx, opts, cmd...); err != nil {
t.Errorf("failed to run container: %v; output:\n%s", err, output)
}
}

0 comments on commit cbbd0b4

Please sign in to comment.