hbiyik / FFmpeg

PLEASE USE https://github.com/nyanmisaka/ffmpeg-rockchip REPO INSTEAD.
https://github.com/nyanmisaka/ffmpeg-rockchip
Other
90 stars 7 forks source link

Orange Pi 5 Plus issues with firefox and youtube #20

Closed kyak closed 1 year ago

kyak commented 1 year ago

Hi @hbiyik

Following discussion in https://aur.archlinux.org/packages/ffmpeg-mpp.

I have Orange Pi 5 Plus 8 Gb model. I've installed the following packages:

mesa-panfork-git
libva-mesa-driver-panfork-git
mesa-vdpau-panfork-git
mpp-git

I've also grabbed mali_csffw.bin from elsewhere (debian package) and put it in /lib/firmware.

My user is in video group.

Now, I've built ffmpeg-mpp 2:6.0-7 and trying to watch some video on youtube. I'm running firefox like this:

MOZ_DISABLE_RDD_SANDBOX=1 firefox

I'm using wayland and sway. Xorg is not even installed into the system. I'm running linux-aarch64-orangepi5 kernel (also from AUR).

The video plays, but there are the following errors in journalctl:

mpp[5232]: mpp_info: mpp version: e34f0dd1 author: Herman Chen   2023-07-17 [hal_vp8e]: Fix crash on unsupport input format
kernel: rga_mm: RGA_MMU unsupported Memory larger than 4G!
kernel: rga_mm: scheduler core[4] unsupported mm_flag[0x0]!
kernel: rga_mm: rga_mm_map_buffer iommu_map virtual address error!
kernel: rga_mm: job buffer map failed!                                                                                                                                                        kernel: rga_mm: dst channel map job buffer failed!
kernel: rga_mm: failed to map buffer
kernel: rga_job: rga_job_commit: failed to map job info
kernel: rga_job: request[6] task[0] job_commit failed.
kernel: rga_job: rga request commit failed!
kernel: rga: request[6] submit failed!

Attached is the output of pacman -Qsq for your reference of packages I have installed. Observe that I have kodi-rpi installed, which works fine overall - except that I'm looking forward to using kodi-matrix-mpp-git - but that's not before I figure out the ffmpeg/firefox issue.

One more note. When starting, Firefox complains it can't enable VA-API because vaapitest fails (I can provide exact error message if needed). I tried running vainfo and vdpauinfo, but they seem to work only in X11 sessions (complain about missing DISPLAY etc).

packages.txt

hbiyik commented 1 year ago

@kyak this is an RGA problem and was first fixed in the kernel (may rkr5.x?), and then mpp had provided a way to fallback to 32bit memory address space. Now mpp has broken its interface, and i think you are on an old kernel.

I have just patched the mpp to force use 32bit address space, and reverted the ones that was supposed to work.

For aur, please first clean install/update the mpp-git packet and then ffmpeg-mpp packet and it should be gone.

please feedback the results, if it is successfull i will apply the same stuff for the rest, ie: ffmpeg4-4, kodi* etc..

kyak commented 1 year ago

@hbiyik I've clean-rebuilt mpp-git and ffmpeg-mpp. But the error is the same. I'm on kernel 5.10.110 by the way.

Do you have some other ideas?

hbiyik commented 1 year ago

could you paste the output that is pushed to dmesg when below command is issued?

dma_heap_debug=1 ffplay somevideofile.mp4

kyak commented 1 year ago

There you go:

dma_heap_debug.txt

hbiyik commented 1 year ago

@kyak

i need to check to which dma device mpp is doing an mmap. For this

while ffplay is running with dma_heap_debug=1 ffplay somevideofile.mp4

please execute ls -la /proc/$(pidof ffplay)/fd

and check where the fd mentioned in the dmesg is mapped to something with dma32:

ie: for a dmesg output mpp_dma_heap: dev 24 free 48 size 4147200 ptr (nil)

it should point out to something with dma32

lr-x------ 1 alarm alarm 64 Aug 3 11:09 24 -> /dev/dma_heap/system-uncached-dma32

kyak commented 1 year ago

@hbiyik I've checked and I confirm that dma device to which mpp is doing mmap is /dev/dma_heap/system-uncached-dma32

In this particular run, the fd was 21.

In fact, here is the complete list of descriptors attached: fd.txt

hbiyik commented 1 year ago

i think i have an idea whats going on.

when you execute below command, do you see the same error on dmesg??

FFMPEG_RKMPP_PIXFMT=NV12 ffmpeg -i someinputfile.mp4 -c:v h264_rkmpp_encoder -y -width 1280 -height 720 out.mp4

hbiyik commented 1 year ago

and also with

ffmpeg -t 1 -f lavfi -i testsrc=s=1920x1080:r=30,format=nv12 -c:v h264_rkmpp_encoder -y -width 1280 -height 720 out.mp4

@kyak

kyak commented 1 year ago

With this command:

FFMPEG_RKMPP_PIXFMT=NV12 ffmpeg -i someinputfile.mp4 -c:v h264_rkmpp_encoder -y -width 1280 -height 720 out.mp4

I get this:

mpp[926]: mpp_info: mpp version: e34f0dd1 author: Herman Chen   2023-07-17 [hal_vp8e]: Fix crash on unsupport input format
mpp[926]: mpp_info: mpp version: e34f0dd1 author: Herman Chen   2023-07-17 [hal_vp8e]: Fix crash on unsupport input format
mpp[926]: mpp_enc: MPP_ENC_SET_RC_CFG bps 6000000 [5625000 : 6375000] fps [30:30] gop 60
mpp[926]: mpp_enc: mode cbr bps [5625000:6000000:6375000] fps fix [30/1] -> fix [30/1] gop i [60] v [0]

And with this command:

ffmpeg -t 1 -f lavfi -i testsrc=s=1920x1080:r=30,format=nv12 -c:v h264_rkmpp_encoder -y -width 1280 -height 720 out.mp4

I get this:

mpp[955]: mpp_info: mpp version: e34f0dd1 author: Herman Chen   2023-07-17 [hal_vp8e]: Fix crash on unsupport input format
mpp[955]: mpp_enc: MPP_ENC_SET_RC_CFG bps 6000000 [5625000 : 6375000] fps [30:30] gop 60
mpp[955]: mpp_enc: mode cbr bps [5625000:6000000:6375000] fps fix [30/1] -> fix [30/1] gop i [60] v [0]
hbiyik commented 1 year ago

@kyak but no

rga_mm: RGA_MMU unsupported Memory larger than 4G!

correct?

kyak commented 1 year ago

@kyak but no

rga_mm: RGA_MMU unsupported Memory larger than 4G!

correct?

This is correct! Nothing "red" is in journalctl

hbiyik commented 1 year ago

ok perfect, i understood whats going on, this not related mpp, but how i use the FFMpeg AVFrame buffers. I need to do some surgery and fundemental change in the code, and might take some time up to a week. When i am done could you test it when i ping you?

kyak commented 1 year ago

ok perfect, i understood whats going on, this not related mpp, but how i use the FFMpeg AVFrame buffers. I need to do some surgery and fundemental change in the code, and might take some time up to a week. When i am done could you test it when i ping you?

I will absolutely test this!

hbiyik commented 1 year ago

in the meanwhile you can use it with librga fallback, it should be in OK speed.

kyak commented 1 year ago

in the meanwhile you can use it with librga fallback, it should be in OK speed.

Yeah, I'll keep using it. Maybe try to switch to your kodi-mpp in the meantime.

What are your plans overall with these efforts? Do you plan to merge it to upstream ffmpeg, and what are the odds of accepting this upstream? Is it too hackish or is it not so bad?

hbiyik commented 1 year ago

it is kinda hackish but can be cleared, but thats not the reason, ffmpeg and rockchip has a legal case, so neither party care about each other so much.

hbiyik commented 1 year ago

@kyak i was faster than i expected :) can you test the the branch fix_noavbuffer branch. https://github.com/hbiyik/FFmpeg/tree/fix_noavbuffer You can verify that 4G error is gone by simply playing a file with ./ffplay in the build folder.

If i am correct with my hypotesis, it should fix 4gb memory error

Compilation is actually quite simple, you can refer to wiki https://github.com/hbiyik/FFmpeg/wiki

kyak commented 1 year ago

With your fix_noavbuffer branch, I'm getting this:

mpp[158566]: mpp_info: mpp version: e34f0dd1 author: Herman Chen   2023-07-17 [hal_vp8e]: Fix crash on unsupport input format
mpp[158566]: mpp_meta: ~MppMetaService cleaning leaked metadata
mpp[158566]: mpp_buffer: ~MppBufferService cleaning leaked group
mpp[158566]: mpp_buffer: ~MppBufferService cleaning leaked buffer
ffplay[158566]: mpp_mem_pool: put_pool found 1 used buffer size 304
ffplay[158566]: mpp_mem_pool: put_pool found 5 used buffer size 224
ffplay[158566]: mpp_mem_pool: put_pool found 1 used buffer size 224

The video doesn't play with lots of errors from ffplay like this:

[h264_rkmpp_decoder @ 0x7f9003e440] An invalid frame was output by a decoder. This is a bug, please report it.
[h264_rkmpp_decoder @ 0x7f9003e440] Failed set frame buffer (code = -1)
[h264_rkmpp_decoder @ 0x7f9003e440] Decoder Failed to get frame (code = -1)
[h264_rkmpp_decoder @ 0x7f9003e440] Failed set frame buffer (code = -1)
[h264_rkmpp_decoder @ 0x7f9003e440] Decoder Failed to get frame (code = -1)
[h264_rkmpp_decoder @ 0x7f9003e440] Failed set frame buffer (code = -1)
[h264_rkmpp_decoder @ 0x7f9003e440] Decoder Failed to get frame (code = -1)
[h264_rkmpp_decoder @ 0x7f9003e440] An invalid frame was output by a decoder. This is a bug, please report it.
hbiyik commented 1 year ago

Just sent an update, could you update to the latest rev and test again?

hbiyik commented 1 year ago

and what happens if you FFMPEG_RKMPP_PIXFMT=NV12 ./ffplay somefile.mp4

kyak commented 1 year ago

I just did git pull and make, I assumed it doesn't need a clean rebuild.

Without the FFMPEG_RKMPP_PIXFMT, there are new errors and video doesn't play:

mpp[159108]: mpp_info: mpp version: e34f0dd1 author: Herman Chen   2023-07-17 [hal_vp8e]: Fix crash on unsupport input format
mpp[159108]: mpp_meta: ~MppMetaService cleaning leaked metadata
mpp[159108]: mpp_buffer: ~MppBufferService cleaning leaked group
mpp[159108]: mpp_buffer: ~MppBufferService cleaning leaked buffer
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_dma_heap: ioctl alloc failed for Bad file descriptor
mpp[159108]: mpp_dma_heap: os_allocator_dma_heap_alloc dma_heap_alloc failed ret -1
mpp[159108]: mpp_buffer: mpp_buffer_create failed to create buffer with size 2097152
mpp[159108]: mpp_dma_heap: ioctl alloc failed for Bad file descriptor
mpp[159108]: mpp_dma_heap: os_allocator_dma_heap_alloc dma_heap_alloc failed ret -1
mpp[159108]: mpp_buffer: mpp_buffer_create failed to create buffer with size 12442624
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_dma_heap: ioctl alloc failed for Bad file descriptor
mpp[159108]: mpp_dma_heap: os_allocator_dma_heap_alloc dma_heap_alloc failed ret -1
mpp[159108]: mpp_buffer: mpp_buffer_create failed to create buffer with size 12442624
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_dma_heap: ioctl alloc failed for Bad file descriptor
mpp[159108]: mpp_dma_heap: os_allocator_dma_heap_alloc dma_heap_alloc failed ret -1
mpp[159108]: mpp_buffer: mpp_buffer_create failed to create buffer with size 12442624
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_dma_heap: ioctl alloc failed for Bad file descriptor
mpp[159108]: mpp_dma_heap: os_allocator_dma_heap_alloc dma_heap_alloc failed ret -1
mpp[159108]: mpp_buffer: mpp_buffer_create failed to create buffer with size 12442624
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_dma_heap: ioctl alloc failed for Bad file descriptor
mpp[159108]: mpp_dma_heap: os_allocator_dma_heap_alloc dma_heap_alloc failed ret -1
mpp[159108]: mpp_buffer: mpp_buffer_create failed to create buffer with size 12442624
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
mpp[159108]: mpp_dma_heap: ioctl alloc failed for Bad file descriptor
mpp[159108]: mpp_dma_heap: os_allocator_dma_heap_alloc dma_heap_alloc failed ret -1
mpp[159108]: mpp_buffer: mpp_buffer_create failed to create buffer with size 12442624
mpp[159108]: mpp_buffer: mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task
ffplay[159108]: mpp_mem_pool: put_pool found 4 used buffer size 304
ffplay[159108]: mpp_mem_pool: put_pool found 7 used buffer size 224
ffplay[159108]: mpp_mem_pool: put_pool found 2 used buffer size 224

With FFMPEG_RKMPP_PIXFMT, the video plays, but looks laggish - like some frames are being dropped.

The log is almost clear except for this one message:

mpp[159040]: mpp_info: mpp version: e34f0dd1 author: Herman Chen   2023-07-17 [hal_vp8e]: Fix crash on unsupport input format
kyak commented 1 year ago

I could insert some printfs in convert_mpp_to_av (i see you were trying to change the return code) to see which branch i'm hitting. And also to make sure that it did in fact rebuild..

hbiyik commented 1 year ago

mpp_buffer_ref_dec found non-positive ref_count 0 caller try_proc_dec_task This mainly happens because there is a buffer region that has already been freeed, and tried to be freed again.

mpp[159108]: mpp_dma_heap: ioctl alloc failed for Bad file descriptor This is because the mmaped file descriptior is invalid. But previous we verified that it is pointing out to: /dev/dma_heap/system-uncached-dma32

With FFMPEG_RKMPP_PIXFMT, the video plays, but looks laggish this is also normal, because ffplay softconvert them to YUV420p to import to the EGL. But atleast verifies some parts of the code is still right..

Actually i have no idea whats going on, may be some libraries of ffmpeg or mpp are being used from different verions. I generally sandbox my ffmpeg when testing with a script like below. May be thats the root cause..

export PATH="/home/alarm/extusb/ffmpeg:$PATH"
export LD_LIBRARY_PATH="/home/alarm/extusb/ffmpeg/libavcodec:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="/home/alarm/extusb/ffmpeg/libavdevice:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="/home/alarm/extusb/ffmpeg/libavfilter:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="/home/alarm/extusb/ffmpeg/libavformat:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="/home/alarm/extusb/ffmpeg/libavutil:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="/home/alarm/extusb/ffmpeg/libpostproc:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="/home/alarm/extusb/ffmpeg/libswresample:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="/home/alarm/extusb/ffmpeg/libswscale:$LD_LIBRARY_PATH"
kyak commented 1 year ago

Something weird was going on, so I rebooted the board.

Now, without the FFMPEG_RKMPP_PIXFMT, ffplay returns error code -4.

So I'm here, in this else branch: https://github.com/hbiyik/FFmpeg/commit/d60e49031614bac9954571cc98a454f4506b44c2#diff-899689d050d42d2021ef8d83d12e2040f36c86efc374fc3c1b5825dedfbb4cd6R558

hbiyik commented 1 year ago

ok what does the No software conversion for %s -> %s available message say?, it is -4 then it shoudl complain about some format mismatch, or can you provide the full ffmpeg log, at first it should log what the format is..

kyak commented 1 year ago

ok what does the No software conversion for %s -> %s available message say?, it is -4 then it shoudl complain about some format mismatch, or can you provide the full ffmpeg log, at first it should log what the format is..

It actually doesn't say that. Here's the ffplay log:

[h264_rkmpp_decoder @ 0x7f7c03e440] An invalid frame was output by a decoder. This is a bug, please report it.
[h264_rkmpp_decoder @ 0x7f7c03e440] Failed set frame buffer (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Decoder Failed to get frame (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Failed set frame buffer (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Decoder Failed to get frame (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Failed set frame buffer (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Decoder Failed to get frame (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Failed set frame buffer (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Decoder Failed to get frame (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Failed set frame buffer (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Decoder Failed to get frame (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Failed set frame buffer (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Decoder Failed to get frame (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Failed set frame buffer (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Decoder Failed to get frame (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Failed set frame buffer (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Decoder Failed to get frame (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Failed set frame buffer (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Decoder Failed to get frame (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Failed set frame buffer (code = -4)
[h264_rkmpp_decoder @ 0x7f7c03e440] Decoder Failed to get frame (code = -4)
rga_api version 1.9.3_[0] 0 aq=  185KB vq=    0KB sq=    0B f=0/0

And lot's of these messages..

hbiyik commented 1 year ago

ah sure :) ffplay -loglevel debug somefile.mp4.. we need to debug log

kyak commented 1 year ago

I don't get it. This error code -4 maybe coming from somewhere else. Still this message is not showing up:

[h264_rkmpp_decoder @ 0x7f8c03e440] Decoder Failed to get frame (code = -4)
[h264_rkmpp_decoder @ 0x7f8c03e440] An invalid frame was output by a decoder. This is a bug, please report it.
[h264_rkmpp_decoder @ 0x7f8c03e440] Wrote 132688 bytes to decoder
[h264_rkmpp_decoder @ 0x7f8c03e440] Received a frame.
[h264_rkmpp_decoder @ 0x7f8c03e440] Failed set frame buffer (code = -4)
[h264_rkmpp_decoder @ 0x7f8c03e440] Decoder Failed to get frame (code = -4)
[h264_rkmpp_decoder @ 0x7f8c03e440] An invalid frame was output by a decoder. This is a bug, please report it.
[h264_rkmpp_decoder @ 0x7f8c03e440] Wrote 133984 bytes to decoder
[h264_rkmpp_decoder @ 0x7f8c03e440] Wrote 136544 bytes to decoder
[h264_rkmpp_decoder @ 0x7f8c03e440] Received a frame.
kyak commented 1 year ago

I've changed this to ret = -42:

[h264_rkmpp_decoder @ 0x7f7803e440] Failed set frame buffer (code = -42)
[h264_rkmpp_decoder @ 0x7f7803e440] Decoder Failed to get frame (code = -42)
[h264_rkmpp_decoder @ 0x7f7803e440] An invalid frame was output by a decoder. This is a bug, please report it.
[h264_rkmpp_decoder @ 0x7f7803e440] Received a frame.
[h264_rkmpp_decoder @ 0x7f7803e440] Failed set frame buffer (code = -42)
[h264_rkmpp_decoder @ 0x7f7803e440] Decoder Failed to get frame (code = -42)
[h264_rkmpp_decoder @ 0x7f7803e440] Received a frame.
[h264_rkmpp_decoder @ 0x7f7803e440] Failed set frame buffer (code = -42)
[h264_rkmpp_decoder @ 0x7f7803e440] Decoder Failed to get frame (code = -42)
[h264_rkmpp_decoder @ 0x7f7803e440] Wrote 123984 bytes to decoder
[h264_rkmpp_decoder @ 0x7f7803e440] Received a frame.
[h264_rkmpp_decoder @ 0x7f7803e440] Failed set frame buffer (code = -1)
[h264_rkmpp_decoder @ 0x7f7803e440] Decoder Failed to get frame (code = -1)
[h264_rkmpp_decoder @ 0x7f7803e440] Received a frame.
[h264_rkmpp_decoder @ 0x7f7803e440] Failed set frame buffer (code = -1)
[h264_rkmpp_decoder @ 0x7f7803e440] Decoder Failed to get frame (code = -1)
hbiyik commented 1 year ago

what kind of games is this code playing :)

kyak commented 1 year ago

-1 is probably from me hitting ctrl-c

hbiyik commented 1 year ago
        else { <--------- You are sure there is a curly bracket here right? if not it can return -4 without logging,
            ret = -4;
            av_log(avctx, AV_LOG_ERROR, "No software conversion for %s -> %s available\n",
                    av_get_pix_fmt_name(informat), av_get_pix_fmt_name(outformat));
        }
kyak commented 1 year ago

image

hbiyik commented 1 year ago

added another log to somewhere else could you pull make and run?

22b94219dfb2173776386bbe08f69eaaaa022238

kyak commented 1 year ago

added another log to somewhere else could you pull make and run?

22b9421

Converting nv12 -> yuv420p

hbiyik commented 1 year ago

not likely, but 502d736a22478ae490152812995c1253ff6f06f2?

kyak commented 1 year ago

not likely, but 502d736?

What's going on? The video now plays!

hbiyik commented 1 year ago

ah i understand its my shit coding. let me do some investigation before i explain whats going on.

kyak commented 1 year ago

Nothing spectacular in ffmpeg output now, and the output from mpp is like this:

mpp[2049]: mpp_info: mpp version: e34f0dd1 author: Herman Chen   2023-07-17 [hal_vp8e]: Fix crash on unsupport input format
mpp[2049]: mpp_buffer: mpp_group 0x7f7802c048 tag unknown caller rkmpp_init_codec mode internal type ion deinit with 99532800 bytes not released
mpp[2049]: mpp_buffer:
              dumping buffer group 0x7f7802c048 id 3 from mpp_buffer_group_deinit
mpp[2049]: mpp_buffer: mode internal
mpp[2049]: mpp_buffer: type ion
mpp[2049]: mpp_buffer: limit size 0 count 0
mpp[2049]: mpp_buffer: used buffer count 6
mpp[2049]: mpp_buffer: buffer 0x7f5c004e48 fd   40 size   16588800 ref_count   1 discard 0 caller try_proc_dec_task
mpp[2049]: mpp_buffer: buffer 0x7f5c003f48 fd   31 size   16588800 ref_count   1 discard 0 caller try_proc_dec_task
mpp[2049]: mpp_buffer: buffer 0x7f5c005748 fd   44 size   16588800 ref_count   1 discard 0 caller try_proc_dec_task
mpp[2049]: mpp_buffer: buffer 0x7f64056cc8 fd   41 size   16588800 ref_count   1 discard 0 caller try_proc_dec_task
mpp[2049]: mpp_buffer: buffer 0x7f64052128 fd   38 size   16588800 ref_count   1 discard 0 caller try_proc_dec_task
mpp[2049]: mpp_buffer: buffer 0x7f5c005a48 fd   46 size   16588800 ref_count   1 discard 0 caller try_proc_dec_task
mpp[2049]: mpp_buffer: unused buffer count 0
mpp[2049]: mpp_buffer: ~MppBufferService cleaning leaked buffer
hbiyik commented 1 year ago

thats ok, dont mind about those clearing stuff.

hbiyik commented 1 year ago

@kyak so this whole convert_mpp_to_av function is designed with the assumption that

ret=0 do some stuff, if fails, set ret to some negative number and return it.

But when u initialize a local variable in function its value is never guaranteed unless you explicitly state its value. In our case ret value was never initialized, and when the compiler is building the code to assembly it was setting the ret variable in to the stack value where the value of -42 is stored in the code section of .. else { ret = -42. Since on initialization we don't force a number, it was just allocating the interger to the value of -42.

This is why it was returning -42, or -4 even though the code never branches there, and never prints out the message. Actually the logic was working fine, but not returning 0, but -4 or -42 all the time.

hbiyik commented 1 year ago

moral of the story: initialize your locals before using them :)

hbiyik commented 1 year ago

Could you run below tests and check if it will ever complain about 4g error? you only need h264_1080p_30_sdr.mp4 h264 file, you can use https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/1080/Big_Buck_Bunny_1080_10s_10MB.mp4

ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=nv12 -c:v h264_rkmpp_encoder -y tests/oddalign_nv12.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=yuv420p -c:v h264_rkmpp_encoder -y tests/oddalign_420p.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=nv16 -c:v h264_rkmpp_encoder -y tests/oddalign_nv16.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=yuv422p -c:v h264_rkmpp_encoder -y tests/oddalign_422p.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=nv24 -c:v h264_rkmpp_encoder -y tests/oddalign_nv24.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=yuv444p -c:v h264_rkmpp_encoder -y tests/oddalign_444p.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=yuyv422 -c:v h264_rkmpp_encoder -y tests/oddalign_yuyv422.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=uyvy422 -c:v h264_rkmpp_encoder -y tests/oddalign_uyvy422.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=bgr24 -c:v h264_rkmpp_encoder -y tests/oddalign_bgr24.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=bgra -c:v h264_rkmpp_encoder -y tests/oddalign_bgra.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=bgr0 -c:v h264_rkmpp_encoder -y tests/oddalign_bgr0.mp4

ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=nv12 -c:v hevc_rkmpp_encoder -y tests/oddalign_hevc_nv12.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=yuv420p -c:v hevc_rkmpp_encoder -y tests/oddalign_hevc_420p.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=nv16 -c:v hevc_rkmpp_encoder -y tests/oddalign_hevc_nv16.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=yuv422p -c:v hevc_rkmpp_encoder -y tests/oddalign_hevc_422p.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=nv24 -c:v hevc_rkmpp_encoder -y tests/oddalign_hevc_nv24.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=yuv444p -c:v hevc_rkmpp_encoder -y tests/oddalign_hevc_444p.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=yuyv422 -c:v hevc_rkmpp_encoder -y tests/oddalign_hevc_yuyv422.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=uyvy422 -c:v hevc_rkmpp_encoder -y tests/oddalign_hevc_uyvy422.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=bgr24 -c:v hevc_rkmpp_encoder -y tests/oddalign_hevc_bgr24.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=bgra -c:v hevc_rkmpp_encoder -y tests/oddalign_hevc_bgra.mp4
ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=bgr0 -c:v hevc_rkmpp_encoder -y tests/oddalign_hevc_bgr0.mp4

ffmpeg -t 1 -f lavfi -i testsrc=s=720x480:r=30,format=nv12 -c:v hevc_rkmpp_encoder -y -width 360 -height 240 tests/oddalign_hevc_nv12_rga.mp4

#vp8
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=nv12" -loglevel info -c:v vp8_rkmpp_encoder -y tests/test_vp8_soft_nv12.mkv
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=nv16" -loglevel info -c:v vp8_rkmpp_encoder -y tests/test_vp8_soft_nv16.mkv
FFMPEG_RKMPP_PIXFMT=DRMPRIME ffmpeg -i h264_1080p_30_sdr.mp4 -loglevel info -c:v vp8_rkmpp_encoder -y tests/test_vp8_soft_nv12_drm.mkv
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuv420p" -loglevel info -c:v vp8_rkmpp_encoder -y tests/test_vp8_soft_yuv420p.mkv
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuv422p" -loglevel info -c:v vp8_rkmpp_encoder -y tests/test_vp8_soft_yuv422p.mkv
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=bgr0" -loglevel info -c:v vp8_rkmpp_encoder -y tests/test_vp8_soft_bgr0.mkv
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=bgra" -loglevel info -c:v vp8_rkmpp_encoder -y tests/test_vp8_soft_bgra.mkv
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuyv422" -loglevel info -c:v vp8_rkmpp_encoder -y tests/test_vp8_soft_yuyv422.mkv
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=uyvy422" -loglevel info -c:v vp8_rkmpp_encoder -y tests/test_vp8_soft_uyvy422.mkv

#h264
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=nv12" -loglevel info -c:v h264_rkmpp_encoder -y tests/test_h264_soft_nv12.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=nv16" -loglevel info -c:v h264_rkmpp_encoder -y tests/test_h264_soft_nv16.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuv420p" -loglevel info -c:v h264_rkmpp_encoder -y tests/test_h264_soft_yuv420p.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuv422p" -loglevel info -c:v h264_rkmpp_encoder -y tests/test_h264_soft_yuv422p.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=bgr0" -loglevel info -c:v h264_rkmpp_encoder -y tests/test_h264_soft_bgr0.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=bgra" -loglevel info -c:v h264_rkmpp_encoder -y tests/test_h264_soft_bgra.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=bgr24" -loglevel info -c:v h264_rkmpp_encoder -y tests/test_h264_soft_bgr24.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuyv422" -loglevel info -c:v h264_rkmpp_encoder -y tests/test_h264_soft_yuyv422.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=uyvy422" -loglevel info -c:v h264_rkmpp_encoder -y tests/test_h264_soft_uyvy422.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=nv24" -loglevel info -c:v h264_rkmpp_encoder -y tests/test_h264_soft_nv24.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuv444p" -loglevel info -c:v h264_rkmpp_encoder -y tests/test_h264_soft_yuv444p.mp4

#hevc
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=nv12" -loglevel info -c:v hevc_rkmpp_encoder -y tests/test_hevc_soft_nv12.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=nv16" -loglevel info -c:v hevc_rkmpp_encoder -y tests/test_hevc_soft_nv16.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuv420p" -loglevel info -c:v hevc_rkmpp_encoder -y tests/test_hevc_soft_yuv420p.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuv422p" -loglevel info -c:v hevc_rkmpp_encoder -y tests/test_hevc_soft_yuv422p.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=bgr0" -loglevel info -c:v hevc_rkmpp_encoder -y tests/test_hevc_soft_bgr0.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=bgra" -loglevel info -c:v hevc_rkmpp_encoder -y tests/test_hevc_soft_bgra.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=bgr24" -loglevel info -c:v hevc_rkmpp_encoder -y tests/test_hevc_soft_bgr24.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuyv422" -loglevel info -c:v hevc_rkmpp_encoder -y tests/test_hevc_soft_yuyv422.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=uyvy422" -loglevel info -c:v hevc_rkmpp_encoder -y tests/test_hevc_soft_uyvy422.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=nv24" -loglevel info -c:v hevc_rkmpp_encoder -y tests/test_hevc_soft_nv24.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuv444p" -loglevel info -c:v hevc_rkmpp_encoder -y tests/test_hevc_soft_yuv444p.mp4

#drm
ffmpeg -t 5 -init_hw_device drm=dr:/dev/dri/renderD128 -filter_hw_device dr -f lavfi -i testsrc=s=1280x720,format=nv12 -vf hwupload,format=drm_prime -c:v h264_rkmpp_encoder -y tests/test_drm_nv12.mp4
ffmpeg -t 5 -init_hw_device drm=dr:/dev/dri/renderD128 -filter_hw_device dr -f lavfi -i testsrc=s=1280x720,format=nv16 -vf hwupload,format=drm_prime -c:v h264_rkmpp_encoder -y tests/test_drm_nv16.mp4
ffmpeg -t 5 -init_hw_device drm=dr:/dev/dri/renderD128 -filter_hw_device dr -f lavfi -i testsrc=s=1280x720,format=bgr24 -vf hwupload,format=drm_prime -c:v h264_rkmpp_encoder -y tests/test_drm_nv24.mp4
ffmpeg -t 5 -init_hw_device drm=dr:/dev/dri/renderD128 -filter_hw_device dr -f lavfi -i testsrc=s=1280x720,format=yuyv422 -vf hwupload,format=drm_prime -c:v h264_rkmpp_encoder -y tests/test_drm_yuyv422.mp4
ffmpeg -t 5 -init_hw_device drm=dr:/dev/dri/renderD128 -filter_hw_device dr -f lavfi -i testsrc=s=1280x720,format=uyvy422 -vf hwupload,format=drm_prime -c:v h264_rkmpp_encoder -y tests/test_drm_uyvy422.mp4
ffmpeg -t 5 -init_hw_device drm=dr:/dev/dri/renderD128 -filter_hw_device dr -f lavfi -i testsrc=s=1280x720,format=bgra -vf hwupload,format=drm_prime -c:v h264_rkmpp_encoder -y tests/test_drm_bgra.mp4

#vp8
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=nv12" -loglevel info -c:v vp8_rkmpp_encoder -y -width 1280 -height 720 tests/test_vp8_scale_nv12.mkv
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=nv16" -loglevel info -c:v vp8_rkmpp_encoder -y -width 1280 -height 720 tests/test_vp8_scale_nv16.mkv
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuv420p" -loglevel info -c:v vp8_rkmpp_encoder -y -width 1280 -height 720 tests/test_vp8_scale_yuv420p.mkv
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuv422p" -loglevel info -c:v vp8_rkmpp_encoder -y -width 1280 -height 720 tests/test_vp8_scale_yuv422p.mkv

#h264
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=nv12" -loglevel info -c:v h264_rkmpp_encoder -y -width 1280 -height 720 tests/test_h264_scale_nv12.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=nv16" -loglevel info -c:v h264_rkmpp_encoder -y -width 1280 -height 720 tests/test_h264_scale_nv16.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuv420p" -loglevel info -c:v h264_rkmpp_encoder -y -width 1280 -height 720 tests/test_h264_scale_yuv420p.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuv422p" -loglevel info -c:v h264_rkmpp_encoder -y -width 1280 -height 720 tests/test_h264_scale_yuv422p.mp4

#hevc
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=nv12" -loglevel info -c:v hevc_rkmpp_encoder -y -width 1280 -height 720 tests/test_hevc_scale_nv12.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=nv16" -loglevel info -c:v hevc_rkmpp_encoder -y -width 1280 -height 720 tests/test_hevc_scale_nv16.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuv420p" -loglevel info -c:v hevc_rkmpp_encoder -y -width 1280 -height 720 tests/test_hevc_scale_yuv420p.mp4
ffmpeg -c:v h264 -i h264_1080p_30_sdr.mp4 -filter:v "format=yuv422p" -loglevel info -c:v hevc_rkmpp_encoder -y -width 1280 -height 720 tests/test_hevc_scale_yuv422p.mp4

#drm
ffmpeg -t 5 -init_hw_device drm=dr:/dev/dri/renderD128 -filter_hw_device dr -f lavfi -i testsrc=s=1280x720,format=nv12 -vf hwupload,format=drm_prime -c:v h264_rkmpp_encoder -width 1280 -height 720 -y tests/test_drm_nv12_scale720p.mp4
ffmpeg -t 5 -init_hw_device drm=dr:/dev/dri/renderD128 -filter_hw_device dr -f lavfi -i testsrc=s=1280x720,format=nv16 -vf hwupload,format=drm_prime -c:v h264_rkmpp_encoder -width 1280 -height 720 -y tests/test_drm_nv16_scale720p.mp4
hbiyik commented 1 year ago

@kyak i know i am at the spam territory but with the below commit

5d75d15b0475855484b6fb89a2ab39bd948688ad

i have also added in the root folder /mpp-arch package where it does not do this horrible patch. And requests 32bit buffer from mpp in ffmpeg properly. I would expect this should cover to prevent 4G issue.

so could you please makepkg -si this package. really install to the system and replace the existing. and clean build the ffmpeg to check if the problem with 4G is gone or not?

kyak commented 1 year ago

@hbiyik no problem at all; I'm grateful for your efforts.

I will run above tests with mpp-arch and ffmpeg from fix_noavbuffer branch and let you know how it goes.

kyak commented 1 year ago

@hbiyik Not a single 4G error running the above tests with mpp-arch and ffmpeg from fix_noavbuffer!

Are we good now?

Thank you so much!

hbiyik commented 1 year ago

@kyak with the latest commit and modded mpp-arch right? And also ffplay does not complain ad well?

kyak commented 1 year ago

@kyak with the latest commit and modded mpp-arch right? And also ffplay does not complain ad well?

That's right. And ffplay also doesn't complain.

hbiyik commented 1 year ago

Ok then im merging this and marking as solved and after tgat ill update arch packages. Thanks for your support