Repository navigation
Description
Problem to solve
LVGL has no way to play real video on small MCUs without a lot of RAM or a
lossy codec. lv_gif is limited to 256 colours and decodes slowly, and MJPEG
needs a JPEG decoder plus a frame's worth of working memory and loses quality,
which shows on UI animations, screen recordings and pixel art.
RV565 is an open (MIT) video format made for this case: frames are stored in
the display's own pixel format (RGB565, RGB565-swapped, gray8 and others), so
decoding is an inflate and nothing else, and playback is lossless. Format
version 7 adds partial deltas: each frame records which bands of lines
changed, so a player only redraws and flushes those rows.
Discussed on the forum first:
https://forum.lvgl.io/t/interest-in-a-lossless-low-ram-video-widget-for-mcus-rv565-like-lv-gif/24490
(@halyssonJr suggested opening an issue here; cc @kisvegabor @AndreCostaaa)
Success criteria
- An
lv_rv565widget with the same shape aslv_gif:create,set_src(anlv_image_dsc_tin flash or anlv_fspath),pause,resume,
restart,set_loop_count, andLV_EVENT_READYat the end of a pass. - Enabled with
LV_USE_RV565; costs nothing when off. - RGB565 and RGB565-swapped clips draw with no conversion; gray8 maps to
LV_COLOR_FORMAT_L8. Other formats are refused with a clear error. - Partial deltas invalidate only the changed rows, so LVGL redraws and flushes just those.
- RAM: one frame buffer, a 4-byte index entry per frame, and a scratch buffer only for clips with zlib deltas. No 32 KB inflate window.
- Every frame on screen matches an independent decode of the clip, pixel for pixel.
Solution outline
A working version exists as a standalone port, so the shape can be judged against real code: elixpo/rv565#50 (ports/lvgl/, about 470 lines plus a header, an example, docs and tests).
- The widget is an
lv_imagesubclass whose image descriptor points at one decoded frame. A timer at the clip's frame rate decodes the next frame into it in place, then drops the image cache entry (the same approach aslv_gif). - For partial deltas it asks the decoder which bands changed and invalidates only those rows, when the image is drawn 1:1; otherwise the whole widget.
- Catch-up after a slow frame is bounded (4 frames per timer call), so the clip slows down instead of stalling the UI.
- The decoder is the RV565 reference C library (MIT, no malloc, about 1,100 lines plus miniz's
tinfl), already in the Arduino Library Manager, the ESP Component Registry and PlatformIO.
Questions for the maintainers before a pull request:
- In-tree under
src/libs/rv565/(next to the GIF and JPEG decoders), or a
separate library repository? - Is there an inflate implementation in LVGL to reuse, or is bundling
tinfl
(MIT) acceptable? - File sources are currently read into RAM whole. Should a streaming reader
overlv_fs(one record at a time, for SD cards) be part of the first
version, or a follow-up?
Rabbit holes
- Scaled, rotated or offset images: partial invalidation only works 1:1, so those cases invalidate the whole widget. Not trying to be clever there.
- Pixel formats beyond RGB565/RGB565-swapped/gray8 (rgb888, rgb666, rgb444, gray4, mono): refused for now rather than converted.
- LVGL 9.2/9.3 have no
RGB565_SWAPPED; the port byte-swaps only the rows a delta touches. Worth deciding whether to support versions before 9.4 at all. - Streaming from
lv_fswithout loading the whole clip (question 3). - Audio and seeking UI: out of scope.
Testing
Done in the port (host, no hardware): a script builds LVGL v9.2.2 and v9.4.0 with a generated lv_conf.h and runs the widget on a headless RGB565 display with a fake tick.
- 19 conformance clips (every rgb565le, rgb565be and gray8 clip in the RV565 test set): each frame on screen equals an independent decode, pixel pixel, covering keyframes, XOR deltas, repeats, partial and shifted deltas, stored and zlib codecs.
- 9 clips with partial deltas: each frame flushes only its changed rows (plus LVGL's one-pixel margin), and repeats flush nothing.
- 34 clips in unsupported formats are refused with the right error.
- Playback controls (loop count, pause, resume, restart, catch-up limit) and
lv_fsloading, including missing and invalid files. - The example compiles with
-Wall -Wextra -Werroron both versions.
In LVGL these would become tests under tests/ using the existing test display, plus the example in examples/libs/. Not yet run on a board; the decoder itself has been measured on an ESP32-S3 (below).
Teaching
- A docs page under
docs/libs/like the GIF one: what RV565 is, how to enableLV_USE_RV565, and the API. - How to make a clip:
pip install rv565provides an encoder and a converter, and there is a browser converter at https://falera.elixpo.com/rv565/convert/. A clip can be turned into a C array for flash. - An example: play a clip from flash and one from an SD card.
Considerations
- Measured on an ESP32-S3 with a 320x240 SPI panel (outside LVGL): partial deltas cut the mean frame time on UI-style content from 31.4 ms to 14.8 ms. https://github.com/elixpo/rv565/blob/main/docs/RESULTS_V7.md
- Format spec: https://github.com/elixpo/rv565/blob/main/docs/FORMAT.md ; paper: arXiv:2610.35935.
- Licence: MIT, like LVGL.
- I'm the author of RV565 and would maintain the widget.
Activity
Bryght-Labs-Richard commentedon Nov 23, 2026
Would it be useful to refactor out any shared code from lv_gif? Purely selfish reasons here, as I'll also need a video playback widget soon.
Also, enabling the partial area update from the video codec all the way to the display driver is pretty neat.
Circuit-Overtime commentedon Nov 23, 2026
Thanks @Bryght-Labs-Richard and yes, I think there's a real shared piece, though it's the playback machinery rather than the decoding.
Comparing
lv_rv565.cwithsrc/widgets/gif/lv_gif.c, the two have the same skeleton:lv_imagesubclass whose image descriptor points at one frame buffer, decoded into in place;set_src/pause/resume/restart;LV_EVENT_READYat the end of each pass;lv_image_cache_drop()after each frame, then an invalidate;lv_gif) pausing while the object isn't visible, whichlv_rv565should have too.What differs is the timing and the repaint, which would stay with each widget:
ms_delay_next). RV565 has a fixed frame rate, solv_rv565works out which frame is due fromlv_tick_elaps()and catches up by up toLV_RV565_MAX_CATCHUPframes before it slows the clip down rather than stall the UI.lv_gifinvalidates the whole object every frame.lv_rv565asks the decoder which rows (partial deltas) or rectangles (region deltas) changed and callslv_obj_invalidate_area()on just those. It only does that when the image is drawn 1:1 (no scale, rotation or offset, and the content area is the clip's size); otherwise it falls back tolv_obj_invalidate().So the helper I'd picture is small and internal, something like a frame player embedded in each widget's struct: the timer, loop count, current frame, auto-pause, and the end-of-pass logic, calling back into the widget with "decode the next frame, tell me the delay to the one after". The widget keeps its decoder and decides what to invalidate. A video widget for another codec could reuse it the same way. I'd rather not start with a new public class until a third user shows what the API should be. @kisvegabor @AndreCostaaa, would you want this in
src/misc(or wherever you'd put it), and should it come before or withlv_rv565?On partial updates: on our badge (ESP32-S3, 320×240 SPI display) the same idea in our own player (not yet the LVGL widget) took a UI clip's SPI transfer from 14.82 ms to 6.23 ms a frame, and film from 27.47 ms to 15.78 ms, because only the changed rectangles go over the wire. In LVGL the invalidated areas flow through to the flush callback the same way, so a driver with partial flush gets the same win for free.
One thing I noticed while comparing, worth double-checking: in
gif_next_frame_task_cb(), afterlv_obj_send_event(obj, LV_EVENT_READY, NULL)the code readsgifobj->loop_countand may calllv_timer_pause(t)before it checksres. If a READY handler deletes the object, the destructor has already deleted the timer and freed the object by then.lv_rv565returns straight away whenres != LV_RESULT_OK. A shared helper would be a natural place to get that ordering right once.What will your video widget decode? If it's frame-based with known dirty areas (MJPEG tiles, say), the same invalidate-only-what-changed path should carry over.
Bryght-Labs-Richard commentedon Nov 23, 2026
It's an ESP-H264 player, so pretty device-specific.
Circuit-Overtime commentedon Nov 24, 2026
Alright, I think that's actually a good second user for the helper: the shared part really is the playback machinery and nothing codec-specific. For the ESP-H264 player I'd expect the split to look like this:
Shared: the timer, pause/resume/restart, loop count, LV_EVENT_READY, auto-pause while invisible (now in lv_rv565 too, elixpo/rv565#65), and dropping the image cache after each frame.
Specific to your widget: the decoder, the YUV to RGB conversion into the frame buffer the image descriptor points at, and where the frame timing comes from (container timestamps, or a frame rate the app sets for a raw stream).
Repaint: unless the decoder tells you which macroblocks changed, you'd invalidate the whole object each frame, as lv_gif does. So the helper's "decode the next frame" callback could optionally return dirty areas: lv_rv565 returns its changed rectangles, and a widget that returns none gets a full invalidate.
@kisvegabor, with two video widgets and lv_gif sharing this, would you like a small internal frame-player helper for them? If so, I can sketch it alongside lv_rv565 so there's something concrete to look at, and Richard could check it against his player before anything lands.