VideoReader does not use GPU hardware acceleration for reading frames on windows 11
10 views (last 30 days)
Show older comments
I’m trying to use MATLAB’s VideoReader with hardware acceleration enabled on my Windows 11 laptop . Hardware decoding seems to works in FFmpeg, but MATLAB always decodes on CPU. I am lost on how to force Matlab to use the GPU at this point.
What I’ve tried:
- Forced MATLAB to use NVIDIA GPU in windows graphic settings.
- Installed HEVC Video Extensions rebooted.
- Verified NVDEC via FFmpeg (hevc_cuvid) on the same file.
- Re‑encoded a test clip to H.264 8‑bit 4:2:0 and retried in MATLAB → still CPU.
- Ensured UseHardwareAcceleration is set to on before constructing VideoReader.
Quick test
I tried running a script reading the entire video file, and it takes the same time with both settings of UseHardwareAcceleration
matlab.video.read.UseHardwareAcceleration('on');
vr = VideoReader("HERO13.mp4");
tic
while hasFrame(vr)
readFrame(vr);
end
disp(toc)
matlab.video.read.UseHardwareAcceleration('off');
vr = VideoReader("HERO13.mp4");
tic
while hasFrame(vr)
readFrame(vr);
end
disp(toc)
In parallel, I checked the utilization of the decoder in poweshell through
nvidia-smi --query-gpu=driver_version,utilization.decoder --format=csv -l 1
Running FFmpeg with NVDEC, however, shows decoder activity:
ffmpeg -hide_banner -vsync 0 -hwaccel cuda -c:v hevc_cuvid -i HERO13-1.mp4 -f null -
The decoder utilization always stays at 0% in MATLAB, while it goes to 76% when decoding the video through ffmpeg, I think this means that NVDEC is working correctly and streaming data.
System details
- MATLAB: R2025a
- OS: Windows 11
- GPU/Driver: RTX 3060 Laptop GPU, driver 576.80, CUDA 12.9
runninf gpuDevice I get:
CUDADevice with properties:
Name: 'NVIDIA GeForce RTX 3060 Laptop GPU'
Index: 1 (of 1)
ComputeCapability: '8.6'
DriverModel: 'WDDM'
TotalMemory: 6441926656 (6.44 GB)
AvailableMemory: 5370806272 (5.37 GB)
DeviceAvailable: true
DeviceSelected: true
Video details:
The video is a 240fps GoPro HERO13 HEVC, 8‑bit, 4:2:0 file
This is the FFprobe output for the file:
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000019d3a590180] Using non-standard frame rate 240000/1001
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'HERO13-1.mp4':
Metadata:
major_brand : mp41
minor_version : 538120216
compatible_brands: mp41
creation_time : 2025-04-17T11:00:25.000000Z
location :
location-eng :
firmware : H24.01.02.02.70
Duration: 01:04:36.17, start: 0.000000, bitrate: 119241 kb/s
Stream #0:0[0x1](eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 2704x1520 [SAR 1520:1521 DAR 16:9], 118885 kb/s, 239.76 fps, 239.76 tbr, 240k tbn (default)
Metadata:
creation_time : 2025-04-17T11:00:25.000000Z
handler_name : GoPro H.265
vendor_id : [0][0][0][0]
encoder : GoPro H.265 encoder
timecode : 12:59:38:235
Stream #0:1[0x2]: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
Metadata:
creation_time : 2025-04-17T11:00:25.000000Z
handler_name : GoPro AAC
vendor_id : [0][0][0][0]
timecode : 12:59:38:235
Stream #0:2[0x3](eng): Data: none (tmcd / 0x64636D74) (default)
Metadata:
creation_time : 2025-04-17T11:00:25.000000Z
handler_name : GoPro TCD
timecode : 12:59:38:235
Stream #0:3[0x4](eng): Data: bin_data (gpmd / 0x646D7067), 102 kb/s (default)
Metadata:
creation_time : 2025-04-17T11:00:25.000000Z
handler_name : GoPro MET
Unsupported codec with id 0 for input stream 2
Unsupported codec with id 98314 for input stream 3
codec_name=hevc
profile=Main
pix_fmt=yuvj420p
codec_name=aac
profile=LC
codec_name=unknown
profile=unknown
codec_name=bin_data
profile=unknown
0 Comments
Answers (1)
saish
on 19 Aug 2025
Hey Deligios,
On Windows, “VideoReader” depends on Microsoft Media Foundation (MF). When you turn “UseHardwareAcceleration('on')”, MATLAB simply commands MF “hardware is allowed”; MF then decides whether to use the GPU via D3D11/DXVA or fall back to software. It is not possible to force MATLAB’s “VideoReader” to use NVIDIA NVDEC on Windows. For more details, kindly refer to the following documentation -
Also, nvidia-smi’s “decoder utilization” shows NVDEC activity only (FFmpeg with hevc_cuvid), not MF/DXVA. So it can sit at 0% in MATLAB even if MF is using a hardware decoder. If you want to check MF/DXVA, you can do it by going to Task Manager → GPU → Video Decode instead.
Even when MF takes a hardware path, “VideoReader” gives you CPU image frames (e.g., uint8 RGB). The GPU to CPU copy and YUV to RGB conversion can dominate runtime at high frame rates, so your loop time with acceleration “on” can be similar to “off”.
0 Comments
See Also
Categories
Find more on Get Started with GPU Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!