Slow rendering when streaming a video using image object

Hello,

I am new to the LVGL library and forum, so please bear with me in case of incomplete details in my question.

Basically, I am trying to stream a video on the display with a raspberry pi 4, but with the current approach/configuration I am able to render only ~5-6 FPS, which adds lagging as time increases.
Here is the setup and implementation:

  • I am using RPi 4, 4 GB variant and using Frame buffer for rending on the HDMI display.
  • I have created two threads, 1st for receiving the RTSP frame and pushing it into the queue.
  • The second thread has the below tasks in the main loop
    1. It polls the queue, copies the frame, and updates the image source
    2. calls lv_timer_handler
    3. sleep for 1 millisecond

Problem and Observations so far:

  • lv_timer_handler() takes around 200-400 msec random delay in each iteration after updating the image source. Due to this thread 2 is not able to read at the required FPS.
  • Polling, copying, and updating lv_img_set_src is taking around 4 msec (based on the lv_log time difference) in thread 2. After this event lv_timer_handler takes a lot of time to render the new image on the screen.
  • I have removed the polling call and tested thread two without updating any image, in that case, lv_timer_handler() is taking 20-25 msec.
  • Checked the flush_cb time as well, it is taking 3-4 msec

Firstly, is it an expected delay in lv_timer_handler?
Has anyone faced similar latency in rending, if not please suggest how to reduce the delay.
Has anyone already tried video streaming?

Thanks in advance,

Best regards,
Fakhkrudin

Hi,

This random delay sounds very strange and it’s certainly not the expected behavior.

Can you use ffmpeg? If so LVGL has a FFmpeg support — LVGL documentation. Could you it try out?

Hi @kisvegabor,

Thanks for the reply, ill check out the FFmpeg feature and see if that also helps.

I figured out the mistake I had made in my code by referring to this post. I created a new image object on each RTSP frame received instead of just calling the lv_obj_invalidate after updating the source. Now I can see better rendering with some delay around 500-600ms.

Do you suggest FFmpeg will give better results?

Thanks again,
Fakhruddin

It’s great!

FFmpeg already works and integrated, so there shouldn’t be issues similar to what you have just fixed.

1 Like