Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffmpeg-mpp: high CPU usage when used with mpv #8

Closed
gentooarch opened this issue Nov 27, 2023 · 14 comments
Closed

ffmpeg-mpp: high CPU usage when used with mpv #8

gentooarch opened this issue Nov 27, 2023 · 14 comments

Comments

@gentooarch
Copy link

gentooarch commented Nov 27, 2023

ping @hbiyik :
My device is Orangepi5,I has used this image
https://github.com/7Ji/orangepi5-archlinuxarm/releases/download/nightly/ArchLinuxARM-aarch64-OrangePi5-20231127_022252-rkloader-5.img.gz

I installed libmali-valhall-g610,mesa-panfork-git ,librga-multi,mpp-git,ffmpeg4.4-mpp,ffmpeg-mpp,libv4l-rkmpp-git ,dri2to3-git,mali-valhall-g610-firmware,libmali-valhall-g610-{dummy,gbm,wayland-gbm,x11-gbm,x11-wayland-gbm},ffmpeg-mpp,ffmpeg4.4-mpp,libv4l-rkmpp-git,v4l-utils-mpp

question:
I used mpv to play 1080p15fps h264 video in archlinux .The CPU usage is two times higher than hardware decoding in armbian.

this is mpv debug in archlinux:
echo 7 | sudo tee /sys/module/rk_vcodec/parameters/mpp_dev_debug
dmesg -w
[ 1348.429954] irq_status=00000107
[ 1348.430022] irq_status=00000107
[ 1348.628529] irq_status=00000107
[ 1348.628929] irq_status=00000107

How to solve this question?

@7Ji 7Ji changed the title CPU usage is high like software decoding ffmpeg-mpp: high CPU usage when used with mpv Nov 28, 2023
@7Ji
Copy link
Contributor

7Ji commented Nov 28, 2023

@hbiyik
I feel the existing decoding pipeline hack in ffmpeg-mpp a bit odd from what I expected to see. Namely the mpp debugging message only reports irq_status but not the codec. Using my chromium-mpp package the kmesg would start with [codec name] and I can't remember exactly what it would report after. Did the codec detail was somehow lost when passing to mpp and that was what caused the lack of offload?

@skyseedtbgmailcom
Also, sorry but my OPi5 Plus's RAM was corrupted and I've sent it back to OPi to repair it, and the only RK3588 SBC in my hand, OPi5, has to take the heavy duty to keep the repo up-to-date. I can't check in depth on desktop how this all happens. But can you check if chromium-mpp works and report its kmesg debug lines?

@hbiyik
Copy link

hbiyik commented Nov 28, 2023

try those ones out
ffmpeg -i pathtofile -loglevel debug -an -sn -f null -
mpv --msg-level=ffmpeg=trace pathtofile
mpv --hwdec=rkmpp --msg-level=ffmpeg=trace pathtofile

those should print out whats happening

@gentooarch
Copy link
Author

gentooarch commented Nov 29, 2023

ffmpeg.log
mpvhwdecmsg.log
mpvmsg.log
ping @hbiyik :
I upload three attach files for prints,you read them,thanks.

@hbiyik
Copy link

hbiyik commented Nov 29, 2023

i spotted several problems:

it seems that your ffmpeg-mpp version is old. can you provide below command out put, you should get below versions, if not, do a pacman -Syyu

[alarm@alarm ~]$ pacman -Q | grep ffmpeg
ffmpeg-mpp 2:6.0-10
ffmpeg4.4-mpp 4.4.4-15

also current mpv in archlinux-arm repo has a build bug, it does not handle drm_prime output properly. It is fixed when the package is rebuild ie:

cd /tmp/
yay -G mpv
cd mpv
makepkg -siA --skippgpcheck

now you should be able to

mpv --hwdec=rkmpp --msg-level=ffmpeg=debug somefile.mp4

you can actually measure the cpu load with:

ps -C nameoftheprocess(ie:mpv) -o %cpu,%mem,cmd

and here are my measurements:
mpv with drm prime: %30/8 = %4 cpuload

%CPU %MEM CMD
33.6  2.2 mpv --hwdec=rkmpp --msg-level=ffmpeg=debug /home/alarm/hiresvids/jelly/jellyfish-10-mbps-hd-hevc.mkv

mpv with soft plane: %60/8 = %8 cpuload

%CPU %MEM CMD
64.8  2.3 mpv --msg-level=ffmpeg=debug /home/alarm/hiresvids/jelly/jellyfish-10-mbps-hd-hevc.mkv

ffplay with softplane %60/8 = %8 cpuload

%CPU %MEM CMD
58.4  2.1 ffplay /home/alarm/hiresvids/jelly/jellyfish-10-mbps-hd-hevc.mkv

division by 8 comes from 8 cpu cores, the measurement is %800 when cpu is fully load. so i bases the percantage according to 1 cpu core and we have 8.

@hbiyik
Copy link

hbiyik commented Nov 29, 2023

@7Ji libv4l-mpp is using mpp logging facilities that why you see debug entries there, ffmpeg is using another logging interface.

@7Ji
Copy link
Contributor

7Ji commented Nov 30, 2023

also current mpv in archlinux-arm repo has a build bug, it does not handle drm_prime output properly. It is fixed when the package is rebuild ie:

We could provide also a mpv package as an alternative in that case. Should we?

ffmpeg-mpp version is old.

@skyseedtbgmailcom

How did you get that package from? In any sense we wouldn't support an outdated package. Please only use either the PKGBUILD here or binary releases from my repo.

@kyak
Copy link

kyak commented Nov 30, 2023

also current mpv in archlinux-arm repo has a build bug, it does not handle drm_prime output properly. It is fixed when the package is rebuild ie:

We could provide also a mpv package as an alternative in that case. Should we?

That would be great. Since you build mpv on target, this will work. Something like mpv-mpp, I guess.

@7Ji
Copy link
Contributor

7Ji commented Nov 30, 2023

also current mpv in archlinux-arm repo has a build bug, it does not handle drm_prime output properly. It is fixed when the package is rebuild ie:

We could provide also a mpv package as an alternative in that case. Should we?

That would be great. Since you build mpv on target, this will work. Something like mpv-mpp, I guess.

No it would only be mpv, as there's nothing changed.

@hbiyik
Copy link

hbiyik commented Nov 30, 2023

i dont think it is necessary to provide mpv in this reppo, they will rebuild it someday and it will be fixed, or may just need to ask archlinux-arm to rebuild. Also softplanes still work, and it is good enoguh for normal use cases.

@gentooarch
Copy link
Author

gentooarch commented Nov 30, 2023

i spotted several problems:

it seems that your ffmpeg-mpp version is old. can you provide below command out put, you should get below versions, if not, do a pacman -Syyu

[alarm@alarm ~]$ pacman -Q | grep ffmpeg
ffmpeg-mpp 2:6.0-10
ffmpeg4.4-mpp 4.4.4-15

also current mpv in archlinux-arm repo has a build bug, it does not handle drm_prime output properly. It is fixed when the package is rebuild ie:

cd /tmp/
yay -G mpv
cd mpv
makepkg -siA --skippgpcheck

now you should be able to

mpv --hwdec=rkmpp --msg-level=ffmpeg=debug somefile.mp4

you can actually measure the cpu load with:

ps -C nameoftheprocess(ie:mpv) -o %cpu,%mem,cmd

and here are my measurements: mpv with drm prime: %30/8 = %4 cpuload

%CPU %MEM CMD
33.6  2.2 mpv --hwdec=rkmpp --msg-level=ffmpeg=debug /home/alarm/hiresvids/jelly/jellyfish-10-mbps-hd-hevc.mkv

mpv with soft plane: %60/8 = %8 cpuload

%CPU %MEM CMD
64.8  2.3 mpv --msg-level=ffmpeg=debug /home/alarm/hiresvids/jelly/jellyfish-10-mbps-hd-hevc.mkv

ffplay with softplane %60/8 = %8 cpuload

%CPU %MEM CMD
58.4  2.1 ffplay /home/alarm/hiresvids/jelly/jellyfish-10-mbps-hd-hevc.mkv

division by 8 comes from 8 cpu cores, the measurement is %800 when cpu is fully load. so i bases the percantage according to 1 cpu core and we have 8.

I have finished pacman -Syu.
pacman -Q | grep ffmpeg
ffmpeg-mpp 2:6.0-10
ffmpeg4.4-mpp 4.4.4-15

As you say,now the question mpv can't use drm prime.When I type --hwdec=rkmpp for the mpv.If will print that:

[vo/gpu/drmprime] mapping DRM dmabuf failed
[vo/gpu] Mapping hardware decoded surface failed.
AV: 00:00:00 / 00:09:54 (0%) A-V: 0.000
[vo/gpu/drmprime] Mapped surface with format 'nv12' has unexpected number of planes. (0 layers and 0 planes, but expected 2 planes)

Now,mpv onley with soft plane:The cpu usage is the same as you about 60% for 1080p15fps video.

ps -C mpv -o %cpu,%mem,cmd
%CPU %MEM CMD
60.2 1.4 mpv /home/abc/vsftpd.mp4

Than I try to copy mpv from armbian.It can run drm prime in archlinux.But the cpu usage also 60% in archlinux.

@gentooarch
Copy link
Author

any

my pacman mirrorlist is:
Server = http://mirror.archlinuxarm.org/$arch/$repo
Server = https://github.com/7Ji/archrepo/releases/download/$arch

I have been run pacman -Syu.
Now mpv only can run soft plane.It have to rebuild.

@hbiyik
Copy link

hbiyik commented Nov 30, 2023

your cpu usage is normal, same as mine, armbian should also give the same.

@7Ji
Copy link
Contributor

7Ji commented Dec 1, 2023

@kyak @skyseedtbgmailcom

I've added mpv to the repo's aarch64 build list and it should be uploaded later by the builder after the latest build

7Ji/archrepo@d9f8988

This uses the exact same PKGBUILD from Arch (x86) and does not have any difference besides being built against the latest ALARM dependencies. As such it does not have a unique pkgrel to force a update from or to the official mpv.

To install it after the builder uploading it, run pacman -Syu 7Ji:mpv. Similarly, to revert back to the official one, run pacman -Syu extra:mpv

@7Ji
Copy link
Contributor

7Ji commented Dec 3, 2023

quote @skyseedtbgmailcom :

刚才在archlinux更新了mpv确实又把cpu占用率百分之60降到30,十分满意,我在gentoo出的bug是我自己的问题,与你无关,因为我写ebuild的脚本还没有完全写好导致的bug,十分感谢,现在的archlinux已经比较完美了

Close as the mpv package in our repo has fixed the problem introduced in alarm's mpv

@7Ji 7Ji closed this as completed Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants