[Libav-user] Hardware accelerated video decoding
edimar.rangel at gmail.com
Wed Mar 22 14:40:51 EET 2023
I'm facing a high memory usage consumption on video decoding, seems to be
some memory leak, but I did not manage to find it.
Processor:11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz 2.69 GHz, 6
cores, 12 threads
GPU: NVIDIA GeForce RTX 3050 Laptop GPU, 4gb GDDR6 6001.0 MHz
I've tried with CUDA, D3D11VA and DXVA2, until now DXVA2 presents the best
These are the steps:
1. Initialize TAVHWDeviceType by av_hwdevice_find_type_by_name('dxva2')
2. Initialize PAVCodec by avcodec_find_decoder(), it's TAVCodecId
parameter can assume one of these values [Mpeg4, H264, HEVC, MJPEG]
3. Initialize PAVCodecHWConfig by:
while True do
vHWConfig := avcodec_get_hw_config(fCodec, vCount);
if not Assigned(vHWConfig) then
if ((vHWConfig.methods and AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) <>
0) and (vHWConfig.device_type = vType) then
fHWPixelFormat := vHWConfig.pix_fmt;
4. Use av_hwdevice_ctx_create to set
in PAVCodecContext.hw_device_ctx variable
5. When decoding I'm using avcodec_send_packet and avcodec_receive_frame
6. Using av_hwframe_transfer_data to copy from GPU memory to CPU memory
7. Finally I'm using sws_getContext and sw_scale to convert the image
8. After decoding these variables are been cleaned:
I'm using Delphi 10.3 and FastMM4 doesn't report any memory leak, but all
the RAM available it's being used.
Is there any known issue that can be causing this?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libav-user