[Libav-user] Hardware accelerated video decoding
Edimar Rangel
edimar.rangel at gmail.com
Wed Mar 22 14:40:51 EET 2023
Hi
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
OS:
I've tried with CUDA, D3D11VA and DXVA2, until now DXVA2 presents the best
results.
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
begin
vHWConfig := avcodec_get_hw_config(fCodec, vCount);
Inc(vCount);
if not Assigned(vHWConfig) then
Break;
if ((vHWConfig.methods and AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) <>
0) and (vHWConfig.device_type = vType) then
fHWPixelFormat := vHWConfig.pix_fmt;
end;
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
functions
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:
av_frame_free(@vSWFrame);
av_buffer_unref(@vBuffer);
av_freep(@vBuffer);
av_packet_unref(@vPacket);
av_packet_free(@vPacket);
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...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20230322/669105d6/attachment.htm>
More information about the Libav-user
mailing list