The decoding time of a single frame is too long. #8

Closed
opened 2025-12-23 10:30:13 +01:00 by backuprepo · 6 comments
Owner

Originally created by @MapleAura on GitHub (Jan 20, 2024).

When I calculated the time to decode, I found out the average time is almost 84ms.

Open the log and find such a problem “Decoder buffer is full”. This happens regardless of whether I export to NV12 format or drm_prime.

image

This is the test code:
image

Originally created by @MapleAura on GitHub (Jan 20, 2024). When I calculated the time to decode, I found out the average time is almost 84ms. Open the log and find such a problem “Decoder buffer is full”. This happens regardless of whether I export to NV12 format or drm_prime. ![image](https://github.com/nyanmisaka/ffmpeg-rockchip/assets/149750728/ef2a0043-0271-4308-8e20-4de786a32e05) This is the test code: ![image](https://github.com/nyanmisaka/ffmpeg-rockchip/assets/149750728/f9fd4ef4-cb66-4527-87f9-4a0172e13260)
Author
Owner

@nyanmisaka commented on GitHub (Jan 20, 2024):

Bear in mind that memcpy and Resize time should not be counted in HW decoding time.

In particular, av_hwframe_transfer_data() already includes memcpy for AV_PIX_FMT_DRM_PRIME => AV_PIX_FMT_NV12 conversion.

Therefore your code contains redundant memcpy.

@nyanmisaka commented on GitHub (Jan 20, 2024): Bear in mind that `memcpy` and `Resize` time should not be counted in HW decoding time. In particular, `av_hwframe_transfer_data()` already includes `memcpy` for AV_PIX_FMT_DRM_PRIME => AV_PIX_FMT_NV12 conversion. Therefore your code contains redundant `memcpy`.
Author
Owner

@daoan1412 commented on GitHub (Jan 20, 2024):

I have a similar problem, even without using memcpy and Resize.

@daoan1412 commented on GitHub (Jan 20, 2024): I have a similar problem, even without using memcpy and Resize.
Author
Owner

@MapleAura commented on GitHub (Jan 21, 2024):

I've counted the cost on several interfaces. ‘av_read_frame’ cost almost 20ms per frame. I send data three times just receive decoded data once sussessfully. The log message indicates that the queue is full. In other words, the result can only be returned once if the data is read three times and it takes almost 60 ms. According to the information I have observed from the log, it seems that the decoding time is larger than reading time. But from the experiments done by others, if I do not carry out the copy operation (just export drm_prime), the decoding time is only a few ms.
image

@MapleAura commented on GitHub (Jan 21, 2024): I've counted the cost on several interfaces. ‘av_read_frame’ cost almost 20ms per frame. I send data three times just receive decoded data once sussessfully. The log message indicates that the queue is full. In other words, the result can only be returned once if the data is read three times and it takes almost 60 ms. According to the information I have observed from the log, it seems that the decoding time is larger than reading time. But from the experiments done by others, if I do not carry out the copy operation (just export drm_prime), the decoding time is only a few ms. ![image](https://github.com/nyanmisaka/ffmpeg-rockchip/assets/149750728/8c3230c0-9842-4457-bdf2-95ec687228b2)
Author
Owner

@nyanmisaka commented on GitHub (Jan 21, 2024):

@MapleAura

I did find an issue regarding the high latency. Please try this patch and see if it helps.

@nyanmisaka commented on GitHub (Jan 21, 2024): @MapleAura I did find an issue regarding the high latency. Please try [this patch](https://github.com/nyanmisaka/ffmpeg-rockchip/commit/ddf7cf1d77aa9bbadb30e62b0d824cddaf55cb07) and see if it helps.
Author
Owner

@MapleAura commented on GitHub (Jan 22, 2024):

That's great. It works. :)

@MapleAura commented on GitHub (Jan 22, 2024): That's great. It works. :)
Author
Owner

@nyanmisaka commented on GitHub (Jan 23, 2024):

Closed by e753665

@nyanmisaka commented on GitHub (Jan 23, 2024): Closed by e753665
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: starred/ffmpeg-rockchip#8
No description provided.