-
Notifications
You must be signed in to change notification settings - Fork 427
-
I am working with ffmpeg and hardware acceleration. Using ffmpeg in cli with option hwaccel or c:v can force hardware decoding.
However in PyAV, if I pass the same hwaccel or c:v parameters, such as
av.open(path, options={"hwaccel":"cuda"} ) or av.open(path, options={"c:v":"h264_cuvid"}
it does not seem to use the GPU though I am not completely sure (one cpu reaching 100% in htop).
It also does not throw any exception even if I set hwaccel to gibberish.
Is there a way to force PyAV to use hardware acceleration or at least force it to throw exception when it does not support it?
My pyav version is 10.0.0.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments
-
You can use nvidia-smi (run this from a command prompt non Windows) to see if the NVIDIA GPU is being utilized.
Beta Was this translation helpful? Give feedback.
All reactions
-
I just learned this. Not sure if this is the best way. But WFM!
from av import ( open as avopen, datasets, ) from av.codec.hwaccel import ( HWAccel, ) cuda = HWAccel(device_type='cuda') fate_vid = 'pexels/time-lapse-video-of-night-sky-857195.mp4' input_container = avopen(file=datasets.curated(fate_vid), hwaccel=cuda) # this assumes the first video stream exists vid = input_container.streams.video[0] if not vid.codec_context.is_hwaccel: raise RuntimeError('HWAccel not enabled') for i, frame in enumerate(input_container.decode(vid)): print(frame)
Beta Was this translation helpful? Give feedback.