lvgl_v8_media 播放视频是否可以实现到lvgl_v9中?需要注意什么?

想要基于lvgl_v9实现lvgl_v8_media相同的功能,但是切换成lvgl_v9却无法显示。

[100131] I/h264 main: wait media exit
[100452] I/h264 ffmpeg_r: media_read_thread
[100471] E/h264 ffmpeg_r: mediaplayer_start rock.mp4 fmt=2
ffurl_open_whitelist ret=0
[107352] I/h264 ffmpeg_r: video codec: format=0
[107376] I/h264 ffmpeg_r: video codec: h264 stream w=180 h=180,period=109
[107405] E/h264 ffmpeg_r: Could not find audio stream
[107426] E/h264 ffmpeg_r: cannot find audio stream

[107454] I/h264 aud_dec: audio decode task run

[107476] I/h264 vid_dec: video decode task run

[107495] I/h264 ffmpeg_r: mediaplayer_start ok
play resumed
play resumed
play resumed
play resumed
play resumed
play resumed
play resumed
[295073] I/h264 ffmpeg_r: read frame error eof
play end
[295408] I/h264 ffmpeg_r: wait audio dec thread exit
[295736] I/h264 ffmpeg_r: wait audio dec thread exit
[296065] I/h264 main: ffmpeg_close
[296080] I/h264 main: mediaplayer_stop async
[296146] I/h264 main: ffmpeg_open
[296163] I/h264 ffmpeg_r: wait audio dec thread exit
[296195] I/media_dec vid_dec: video drop
[296221] I/media_dec vid_dec: video drop
[296243] I/media_dec vid_dec: video drop
[296457] I/h264 main: wait media exit
[296490] I/h264 ffmpeg_r: wait audio dec thread exit
[296784] I/h264 main: wait media exit
[296817] I/h264 aud_dec: audio decode_thread exit
[296837] I/h264 ffmpeg_r: wait audio dec thread exit
[296915] I/h264 vid_dec: video decode_thread exit
[297112] I/h264 main: wait media exit
[297178] I/h264 ffmpeg_r: wait video dec thread exit
[297298] I/h264 ffmpeg_r: media exit
[297440] I/h264 main: wait media exit
[297743] I/h264 ffmpeg_r: media_read_thread
[297762] E/h264 ffmpeg_r: mediaplayer_start local.mp4 fmt=2
ffurl_open_whitelist ret=-2
[298104] I/NO_TAG ffmpeg_r: fail_2 -2
[298121] E/h264 ffmpeg_r: avformat_open_input error
[298144] I/h264 ffmpeg_r: mediaplayer_start failed
[298164] E/h264 ffmpeg_r: media start error
[301437] I/h264 main: wait ffmpeg_read exit
[304325] I/h264 main: ffmpeg_open
[304649] I/h264 ffmpeg_r: media_read_thread
[304667] E/h264 ffmpeg_r: mediaplayer_start muse.mp4 fmt=2
ffurl_open_whitelist ret=0
[310455] I/h264 ffmpeg_r: video codec: format=0
[310478] I/h264 ffmpeg_r: video codec: h264 stream w=128 h=128,period=30
[310508] E/h264 ffmpeg_r: Could not find audio stream
[310528] E/h264 ffmpeg_r: cannot find audio stream

[310556] I/h264 aud_dec: audio decode task run

[310578] I/h264 vid_dec: video decode task run

[310598] I/h264 ffmpeg_r: mediaplayer_start ok
play resumed
play resumed
play resumed
[380352] I/h264 ffmpeg_r: read frame error eof
play end
[380427] I/h264 main: ffmpeg_close
[380442] I/h264 main: mediaplayer_stop async
[380508] I/h264 main: ffmpeg_open
[380526] I/media_dec vid_dec: video drop
[380550] I/media_dec vid_dec: video drop
[380571] I/media_dec vid_dec: video drop
[380688] I/h264 ffmpeg_r: wait audio dec thread exit
[380851] I/h264 main: wait media exit
[381015] I/h264 ffmpeg_r: wait audio dec thread exit
[381179] I/h264 main: wait media exit
[381244] I/h264 vid_dec: video decode_thread exit
[381343] I/h264 aud_dec: audio decode_thread exit
[381362] I/h264 ffmpeg_r: wait audio dec thread exit
[381484] I/h264 ffmpeg_r: media exit
[381507] I/h264 main: wait media exit
[381830] I/h264 ffmpeg_r: media_read_thread
[381849] E/h264 ffmpeg_r: mediaplayer_start rock.mp4 fmt=2
ffurl_open_whitelist ret=0
[388746] I/h264 ffmpeg_r: video codec: format=0
[388769] I/h264 ffmpeg_r: video codec: h264 stream w=180 h=180,period=109
[388798] E/h264 ffmpeg_r: Could not find audio stream
[388819] E/h264 ffmpeg_r: cannot find audio stream

[388847] I/h264 aud_dec: audio decode task run

[388869] I/h264 vid_dec: video decode task run

[388888] I/h264 ffmpeg_r: mediaplayer_start ok
play resumed
play resumed

视频播放本身(middleware\media)是没有问题的,他是一个独立的代码跟lvgl版本无关.

移植到lvgl v9上面需要注意的是:

  1. 视频解码完成后的图像如何在lvgl显示。这个图像的格式描述头,在v8和v9上面有很大的差异
  2. 视频解码完成后的图像数据是指向一个指针数组的,这个数组的前3个word分别是y,u,v buffer的地址。即对应lvgl v9上面的LV_COLOR_FORMAT_I420格式,但是v9上面这个格式的显示,官方的代码是没有实现的,需要靠外部的硬件渲染加速度,我们的EPIC硬件渲染加速也还没有适配这个格式,需要稍加改动
    else if (LV_IMG_CF_YUV420_PLANAR2 == src->header.cf)
    {
        uint8_t **yuv = (uint8_t **)p_fg_layer->data;
        p_fg_layer->yuv.y_buf = yuv[0];
        p_fg_layer->yuv.u_buf = yuv[1];
        p_fg_layer->yuv.v_buf = yuv[2];
    }