[Libav-user] Hardware accelerated video decoding

Edimar Rangel edimar.rangel at gmail.com
Thu Mar 23 14:51:22 EET 2023


Could you, please, provide me any information about codec configuration? Is
there any site, doc, anything?

Em qua., 22 de mar. de 2023 às 10:09, mr N <mohamednmn28105 at gmail.com>
escreveu:

> There is no one-size-fits-all solution to your issue of high memory usage
> during video decoding. The cause could be a combination of factors,
> including hardware limitations, software optimizations, codec
> configuration, and external factors. It is best to approach this issue
> systematically, analyzing each potential cause and optimizing your code
> accordingly.
>
> On Wed, Mar 22, 2023 at 1:43 PM Edimar Rangel <edimar.rangel at gmail.com>
> wrote:
>
>> 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?
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/libav-user
>>
>> To unsubscribe, visit link above, or email
>> libav-user-request at ffmpeg.org with subject "unsubscribe".
>>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20230323/f15c8d5d/attachment.htm>


More information about the Libav-user mailing list