Hardware acceleration with VAAPI not working for H.264 decoding #2329
-
I am trying to use hardware acceleration with VAAPI for decoding H.264 videos using JavaCV on Linux for weeks now. However, it does not seem to work, while the same setup works perfectly with the FFmpeg command line. Environment:
Steps to Reproduce:
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(videoPath);
grabber.setOption("hwaccel", "vaapi");
grabber.setOption("hwaccel_device", "/dev/dri/renderD128");
grabber.setOption("hwaccel_output_format", "vaapi");
grabber.setVideoCodec(avcodec.AV_CODEC_ID_H264);
grabber.start();
(I have tried simple setup as well, and numerous other, but neither of them worked) grabber.setOption("hwaccel", "auto"); Expected Behavior: The video should be decoded using VAAPI hardware acceleration. Actual Behavior: The decoding falls back to software decoding. Additional Information: The command gradle dependencies
Thank you for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 9 replies
-
Please try again with the snapshots: http://bytedeco.org/builds/ |
Beta Was this translation helpful? Give feedback.
-
Thank you for your prompt answer! I've tested with the latest 1.5.12-SNAPSHOT, but the problem still persists. Edit: Hardware acceleration seems to working with nvidia GPU by the way (on a different hw ofc). |
Beta Was this translation helpful? Give feedback.
-
Hi Guys! Thanks for this useful help! We also need hardware acceleration ... :( @saudet: Can you help us what we need to modify or implement for this? It is not clear to me what @silenium-dev's last sentence means. "You'd need to create a hw device context and pass it to the decoder, like in the [ffmpeg hw_decode.c example]" Thx! |
Beta Was this translation helpful? Give feedback.
-
Thank you for the useful example! I tried to implement it, but during the run I get the following error. Log: [AVHWDeviceContext @ 0x7fe9842fa240] libva: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so has no function __vaDriverInit_1_0 Code: AVBufferRef hw_device_ctx = new AVBufferRef(); VA-API version: vainfo: VA-API version: 1.17 (libva 2.12.0) |
Beta Was this translation helpful? Give feedback.
-
I've worked magic with libraries and now I have hardware acceleration. :) But now another bug has appeared ... Error: [swscaler @ 0x7fb8579fe840] vaapi is not supported as input pixel format |
Beta Was this translation helpful? Give feedback.
I've looked into
FFmpegFrameGrabber
, it doesn't support any hardware accelerated decoding. The options that are configurable viasetOption
are only passed toAVFormatContext
, which is the demuxer, and not the same ones that you could pass to theffmpeg
CLI.There is a
setVideoOption
, which is passed to theAVCodecContext
, but this is not enough to configure hardware acceleration.You'd need to create a hw device context and pass it to the decoder, like in the ffmpeg
hw_decode.c
example, but this is currently not implemented inFFmpegFrameGrabber