JeffyCN / libv4l-rkmpp

A rockchip-mpp V4L2 wrapper plugin for chromium V4L2 VDA/VEA
GNU Lesser General Public License v2.1
79 stars 26 forks source link

some videos are displayed all green #5

Closed amazingfate closed 1 year ago

amazingfate commented 1 year ago

I've packaged the latest code in a ppa: https://launchpad.net/~liujianfeng1994/+archive/ubuntu/rockchip-multimedia/. And I can play some video with hardware accelerated decode in a patched chromium 101.0.4951.15 on radxa rock5b ,a rk3588 board. But there are some videos in bilibili.com that are displayed all green, for example: https://www.bilibili.com/video/BV1wE411M7nK. This seems to be a rga related issue. I Added this patch to show more log:

diff --git a/src/utils.c b/src/utils.c
index 8f090eb..3d1123a 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -126,12 +126,14 @@ static int rkmpp_copy_buffer(struct rkmpp_context *ctx,
        }

        /* Nothing to do for mmap buffer */
-       if (buffer->memory == V4L2_MEMORY_MMAP)
-               return 0;
+       if (buffer->memory == V4L2_MEMORY_MMAP) {
+               LOGE("Nothing to do for mmap buffer\n");
+               return 0;}

        queue = rkmpp_get_queue(ctx, buffer->type);
-       if (!queue)
-               return -1;
+       if (!queue) {
+               LOGE("Can't get queue\n");
+               return -1;}

        rkmpp_ptr = mpp_buffer_get_ptr(rkmpp_buffer->rkmpp_buf);
        rkmpp_format = queue->rkmpp_format;

And I got this debug log: https://paste.ubuntu.com/p/3VVPVcwt7W/ rkmpp_copy_buffer always return -1 because of buffer->memory == V4L2_MEMORY_MMAP. And the output of cat /proc/interrupts |grep rga shows that the rga is not used. It this the root cause? Or any other things that I've ignored.

JeffyCN commented 1 year ago

copy buffer should return 0 directly for mmaped memory, since the userspace is using the same buffer(mmaped from exported dmabuf), no need to copy it.

rga is kind of broken in 3588, but i don't think it would related to this issue.

maybe try to: 1/ make sure mpp is returning valid frames 2/ make sure mpp frame's format is nv12 3/ maybe try to dump the input packages and check it with gstreamer+mpp 4/ maybe try to dump the output frames

amazingfate commented 1 year ago

After adding some logs I can see the mpp's frame is NV12,same as other normal videos. Any way to dump the mpp packages or the output frames?

amazingfate commented 1 year ago
I think there are something to do with video resolution. I found some other green videos: video url video resolution video codec
https://www.bilibili.com/video/BV1wE411M7nK/ 1376x776 h264
https://www.bilibili.com/video/BV1MR4y1T7YN 2160x1080 h264
https://www.bilibili.com/video/BV1t34y1U7CN 1440x1080 h264
https://www.bilibili.com/video/BV15z4y1Z734 2160x1080 h264

While other 1920x1080 h264 videos can play well.

JeffyCN commented 1 year ago

maybe try local videos, you can use ffmpeg to change resolution, to make sure it's a resolution related issue

amazingfate commented 1 year ago

After updating to chromium 105.0.5195.125, there is only one video(https://www.bilibili.com/video/BV1wE411M7nK) playing green among the above 4 videos. After turing to 720p in the bilibili web player it can also play well. I downloaded the video from bilibili, converted it to mp4 and played by chromium, also green. But I can play it well using mpv with rkmpp acceleration.

JeffyCN commented 1 year ago

it looks like the size is not aligned, so mpp will give aligned frame, maybe chromium doesn't handle that will

JeffyCN commented 1 year ago

tested on 3588 evb with buildroot + prebuilt chromium-wayland 101.0.4951.54, it works well with a local converted 1376x776 h.264 video.

that bilibili link only has 1080p / 720p / 360p here

amazingfate commented 1 year ago

tested on 3588 evb with buildroot + prebuilt chromium-wayland 101.0.4951.54, it works well with a local converted 1376x776 h.264 video.

that bilibili link only has 1080p / 720p / 360p here

Here is the video I downloaded from bilibili: https://cowtransfer.com/s/925bcee23c384c. Open it with chromium and from chrome://media-internals I can see that chromium is using VDAVideoDecoder, but the video is green.

JeffyCN commented 1 year ago

that works well too. [867.245] [RKMPP] [5458] rkmpp_apply_info_change(225): frame info changed: 1376x776) [867.248] [RKMPP] [5455] plugin_mmap(945): mmap buffer(2): 0x7fa2180000, fd: 136 [867.249] [RKMPP] [5455] plugin_mmap(945): mmap buffer(3): 0x7fa1d80000, fd: 137 [867.249] [RKMPP] [5455] rkmpp_dec_g_selection(624): visible rect: 1376x776 [867.249] [RKMPP] [5455] rkmpp_dec_dqevent(420): dequeue resolution change event [867.250] [RKMPP] [5455] rkmpp_dec_g_selection(624): visible rect: 1376x776

amazingfate commented 1 year ago

That's weird. I'm basicly using the build config and patch from https://github.com/saiarcot895/chromium-ubuntu-build. I will try to build without the original patches to see if things will change.

amazingfate commented 1 year ago

BTW, I'm using panfork mesa gpu driver instead of mali driver. I don't know if this is related.

JeffyCN commented 1 year ago

maybe you can try to dump this plugin's outbuf(or memset it to non-green data), if we're returning correct frames, this issue is likely related to chromium itself...

amazingfate commented 1 year ago

I find that if the video size is not divisible by 36 then it will get played green by rkmpp. Since I'm using panfrost mesa gpu driver and you can play well using mali gpu driver in buildroot, I will dive into the source code of chromium to see what really happends when I have time. This two videos, video_54.mp4 is played green while video_72 is played well.

https://user-images.githubusercontent.com/5022901/207275896-246490ad-2bbd-4860-86c8-9305eeeec47d.mp4

https://user-images.githubusercontent.com/5022901/207275940-a677b643-7098-4164-a185-047f30e59978.mp4

JeffyCN commented 1 year ago

ok, that seems like a chromium+mesa issue.

could be alignment requirement for texture in mesa

amazingfate commented 1 year ago

Confirmed, when using the close source mali driver, video_54.mp4 is playing well. I will report this issue to the developer of mesa.