ThijsDeschildre
Posts: 17
Joined: Thu Sep 27, 2012 11:35 pm

RPi4 video performance

Sat Mar 21, 2020 10:34 pm

I don't know what forum this question would suit best, so I put it here.
I set up a RPi4 with 4GB ram up as home theater PC, with a heatsink and fan, fast SD card, Raspbian and Kodi. The Kodi interface is very slow to navigate. There's plenty of plugins to stream South Park and TV, and the performance is abysmal. The plugins only run single threaded and are choppy at resolutions like 720p or less.
I stopped using Kodi, from the Raspbian desktop I can run Chrome which streams video from common platforms at an acceptable resolution. Using smplayer, VLC, etc... with video files from a NAS, 4K video is simply impossible and 1080p video is hit or miss. Everything is connected by gigabit ethernet.

Some questions:
What distribution and player offer best video performance?
What resolution/bitrate can I expect to play smoothly?


From what I read, the RPi4 needs no additional licensing for video codecs, and should offer best performance with X265/HEVC codecs.
I believe Kodi uses omxplayer for video playback. I tried using it from commandline, and can't say it offers better performance .

User avatar
rpiMike
Posts: 1206
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: RPi4 video performance

Sat Mar 21, 2020 10:47 pm

Have you tried LibreELEC ?

https://libreelec.tv/raspberry-pi-4/

Rascas
Posts: 644
Joined: Tue Mar 11, 2014 6:18 pm
Location: Porto, Portugal
Contact: Website

Re: RPi4 video performance

Sat Mar 21, 2020 11:13 pm

Kodi on Raspbian on the RPi 4 works fine here as a video player, also connected to another RPi 3 serving as NAS. It plays all my movie/tv series colection at any resolution, even Blueray rips. It should also play any 720p video file even at software decoding. I suspect that you didn't setup Kodi properly, like for example, you need to increase GPU memory, the recommended for the RPi 4 is 320MB. Without it, it won't work properly. But without a Kodi debug log, I can't say for sure what is your problem...
If you just want to use the RPi 4 only for Kodi, I recommend LibreELEC, it is just "plug'n play".

dustnbone
Posts: 225
Joined: Tue Nov 05, 2019 2:49 am

Re: RPi4 video performance

Sun Mar 22, 2020 3:52 am

Also recommend LibreELEC, it works really well on the Pi4. HEVC and H.264 at 1080p never exhibit any frame drops, UI is very snappy. Maybe once every 2 months I try to play something it doesn't like and Kodi coughs a hairball and restarts itself. Aside from that no complaints.

I don't have a 4K display connected to it so I can't attest to it's ability to do that but from what I've heard 4K HEVC works fine.

ThijsDeschildre
Posts: 17
Joined: Thu Sep 27, 2012 11:35 pm

Re: RPi4 video performance

Sun Mar 22, 2020 10:44 am

rpiMike wrote:
Sat Mar 21, 2020 10:47 pm
Have you tried LibreELEC ?

https://libreelec.tv/raspberry-pi-4/
not yet. Ivaguely recall reading how libreelec should have the best performance, but I couldn't find any confirmation when I tried looking this up
Rascas wrote:
Sat Mar 21, 2020 11:13 pm
t should also play any 720p video file even at software decoding. I suspect that you didn't setup Kodi properly, like for example, you need to increase GPU memory, the recommended for the RPi 4 is 320MB
I haven't increased GPU memory yet. I also had to make a change so a USB mouse would be smooth instead of choppy. kind of baffling how this was necessary. I also get tearing when running raspbian at 1080p on a 4K TV, but that's part of my unrelated gripes.
dustnbone wrote:
Sun Mar 22, 2020 3:52 am
Also recommend LibreELEC, it works really well on the Pi4. HEVC and H.264 at 1080p never exhibit any frame drops, UI is very snappy. Maybe once every 2 months I try to play something it doesn't like and Kodi coughs a hairball and restarts itself. Aside from that no complaints.

I don't have a 4K display connected to it so I can't attest to it's ability to do that but from what I've heard 4K HEVC works fine.
sounds very exciting, will try it. libreelec doesnt offer any features to use it as a desktop?
running a web browser, file browser or terminal would be great.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 25977
Joined: Sat Jul 30, 2011 7:41 pm

Re: RPi4 video performance

Sun Mar 22, 2020 2:14 pm

ThijsDeschildre wrote:
Sun Mar 22, 2020 10:44 am
rpiMike wrote:
Sat Mar 21, 2020 10:47 pm
Have you tried LibreELEC ?

https://libreelec.tv/raspberry-pi-4/
not yet. Ivaguely recall reading how libreelec should have the best performance, but I couldn't find any confirmation when I tried looking this up
Rascas wrote:
Sat Mar 21, 2020 11:13 pm
t should also play any 720p video file even at software decoding. I suspect that you didn't setup Kodi properly, like for example, you need to increase GPU memory, the recommended for the RPi 4 is 320MB
I haven't increased GPU memory yet. I also had to make a change so a USB mouse would be smooth instead of choppy. kind of baffling how this was necessary. I also get tearing when running raspbian at 1080p on a 4K TV, but that's part of my unrelated gripes.
dustnbone wrote:
Sun Mar 22, 2020 3:52 am
Also recommend LibreELEC, it works really well on the Pi4. HEVC and H.264 at 1080p never exhibit any frame drops, UI is very snappy. Maybe once every 2 months I try to play something it doesn't like and Kodi coughs a hairball and restarts itself. Aside from that no complaints.

I don't have a 4K display connected to it so I can't attest to it's ability to do that but from what I've heard 4K HEVC works fine.
sounds very exciting, will try it. libreelec doesnt offer any features to use it as a desktop?
running a web browser, file browser or terminal would be great.
Just have two SD cards, one for media, one for desktop. Works well like that.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“My wife said to me `...you’re not even listening`.
I thought, that’s an odd way to start a conversation.."

Rascas
Posts: 644
Joined: Tue Mar 11, 2014 6:18 pm
Location: Porto, Portugal
Contact: Website

Re: RPi4 video performance

Sun Mar 22, 2020 2:28 pm

ThijsDeschildre wrote:
Sun Mar 22, 2020 10:44 am
I haven't increased GPU memory yet. I also had to make a change so a USB mouse would be smooth instead of choppy. kind of baffling how this was necessary. I also get tearing when running raspbian at 1080p on a 4K TV, but that's part of my unrelated gripes.
That's why it didn't work good for you, if you don't increase GPU memory it will strugle to play almost anything.
Here you have information on how to setup Kodi on Raspbian:
viewtopic.php?f=66&t=251645
After that, 4K HEVC will play fine.

About the tearing, that's because of the fkms driver. It will be fixed when the kms driver is ready, probably before the Kodi 19 stable realease. Tearing may happen on desktop and Kodi interface but it won't happen when playing videos fullscreen. By now, tearing appears both on Kodi on Raspbian and on LibreELEC.

ThijsDeschildre
Posts: 17
Joined: Thu Sep 27, 2012 11:35 pm

Re: RPi4 video performance

Sun Mar 22, 2020 4:34 pm

I spent quite a bit of time on the RPI4 again. Increased GPU memory allocation to 512mb and set my resolution to 3840x2160.
Mouse responsiveness went down again, took me some time to adjust the whole desktop for running at a higher resolution. Bah.
smplayer didnt improve, VLC now refuses to show anything at all ( usrvcsm: [vcsm_malloc_cache]: [8719] [VLC frame]: ioctl mem-alloc FAILED [-1] (hdl: 0) and mmal_avcodec decoder error: CMA buf pool alloc buf failed).
Kodi is incredibly slow to run. The sliding menus feel extremely sluggish. Slideshow to play 4K content. Mouse pointer even more laggy.
vcgencmd get_mem gpu says gpu=512m

Using the RPi4 as HTPC or desktop is just a string of disappointments. Even if I get it working, it's not worth putting in all the time to get 4K up and running.

Rascas
Posts: 644
Joined: Tue Mar 11, 2014 6:18 pm
Location: Porto, Portugal
Contact: Website

Re: RPi4 video performance

Sun Mar 22, 2020 4:40 pm

Code snippets doesn't help... only full logs.
Try LibreELEC.

User avatar
dickon
Posts: 1180
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: RPi4 video performance

Sun Mar 22, 2020 4:45 pm

Er, that sounds like you've not enabled the >30fps modes in config.txt...

ThijsDeschildre
Posts: 17
Joined: Thu Sep 27, 2012 11:35 pm

Re: RPi4 video performance

Sun Mar 22, 2020 5:21 pm

dickon wrote:
Sun Mar 22, 2020 4:45 pm
Er, that sounds like you've not enabled the >30fps modes in config.txt...
I'm on 30hz, the 60hz option isn't available. All of the sudden I'm not sure if my TV supports 4K 60hz... it's a Samsung ue40mu6120
Last edited by ThijsDeschildre on Sun Mar 22, 2020 9:45 pm, edited 1 time in total.

User avatar
dickon
Posts: 1180
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: RPi4 video performance

Sun Mar 22, 2020 5:29 pm

You've got

Code: Select all

hdmi_enable_4kp60=1
in /boot/config.txt, yes?

ThijsDeschildre
Posts: 17
Joined: Thu Sep 27, 2012 11:35 pm

Re: RPi4 video performance

Sun Mar 22, 2020 8:55 pm

dickon wrote:
Sun Mar 22, 2020 5:29 pm
You've got

Code: Select all

hdmi_enable_4kp60=1
in /boot/config.txt, yes?
yes

User avatar
dickon
Posts: 1180
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: RPi4 video performance

Sun Mar 22, 2020 9:08 pm

Then grab the EDID, and run it through edidparser. Other things to check are that you've got the thing plugged into an HDMI 2.0 (or higher) port on the TV -- 1.4 can only handle the slower speeds, and <1.4 can't even handle those (at least, officially). I can't find a definitive list of versions that TV supports with a quick google, but try the manual.

User avatar
Imperf3kt
Posts: 3491
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: RPi4 video performance

Sun Mar 22, 2020 9:22 pm

Rascas wrote:
Sun Mar 22, 2020 2:28 pm
ThijsDeschildre wrote:
Sun Mar 22, 2020 10:44 am
I haven't increased GPU memory yet. I also had to make a change so a USB mouse would be smooth instead of choppy. kind of baffling how this was necessary. I also get tearing when running raspbian at 1080p on a 4K TV, but that's part of my unrelated gripes.
That's why it didn't work good for you, if you don't increase GPU memory it will strugle to play almost anything.
Here you have information on how to setup Kodi on Raspbian:
viewtopic.php?f=66&t=251645
After that, 4K HEVC will play fine.

About the tearing, that's because of the fkms driver. It will be fixed when the kms driver is ready, probably before the Kodi 19 stable realease. Tearing may happen on desktop and Kodi interface but it won't happen when playing videos fullscreen. By now, tearing appears both on Kodi on Raspbian and on LibreELEC.
Setting the gpu mem higher on a Pi4b does nothing for video playback.
viewtopic.php?f=28&t=249122&p=1521556#p1521562
55:55:44:44:4C
52:4C:52:42:41

ThijsDeschildre
Posts: 17
Joined: Thu Sep 27, 2012 11:35 pm

Re: RPi4 video performance

Sun Mar 22, 2020 9:38 pm

dickon wrote:
Sun Mar 22, 2020 9:08 pm
Then grab the EDID, and run it through edidparser. Other things to check are that you've got the thing plugged into an HDMI 2.0 (or higher) port on the TV -- 1.4 can only handle the slower speeds, and <1.4 can't even handle those (at least, officially). I can't find a definitive list of versions that TV supports with a quick google, but try the manual.
hmm, which field is this exactly?
you can find my edid file here https://pastebin.com/kdvPXci4

User avatar
dickon
Posts: 1180
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: RPi4 video performance

Sun Mar 22, 2020 9:45 pm

I can't see any 3840x2160 or 4096x2160 modes that are >30Hz in that. You're probably out of luck, unless there's a port that's specifically marked as HDMI 2.0 and your Pi isn't plugged into it.

There's not much 4kp60 content out there -- film is still a ludicrous 24Hz, after all, which is where most of the 4k content is sourced from -- which probably lets them claim 4k UHD.

Rascas
Posts: 644
Joined: Tue Mar 11, 2014 6:18 pm
Location: Porto, Portugal
Contact: Website

Re: RPi4 video performance

Mon Mar 23, 2020 1:12 am

Imperf3kt wrote:
Sun Mar 22, 2020 9:22 pm
Rascas wrote:
Sun Mar 22, 2020 2:28 pm
ThijsDeschildre wrote:
Sun Mar 22, 2020 10:44 am
I haven't increased GPU memory yet. I also had to make a change so a USB mouse would be smooth instead of choppy. kind of baffling how this was necessary. I also get tearing when running raspbian at 1080p on a 4K TV, but that's part of my unrelated gripes.
That's why it didn't work good for you, if you don't increase GPU memory it will strugle to play almost anything.
Here you have information on how to setup Kodi on Raspbian:
viewtopic.php?f=66&t=251645
After that, 4K HEVC will play fine.

About the tearing, that's because of the fkms driver. It will be fixed when the kms driver is ready, probably before the Kodi 19 stable realease. Tearing may happen on desktop and Kodi interface but it won't happen when playing videos fullscreen. By now, tearing appears both on Kodi on Raspbian and on LibreELEC.
Setting the gpu mem higher on a Pi4b does nothing for video playback.
viewtopic.php?f=28&t=249122&p=1521556#p1521562
Yes it does. The default 76MB (I believe that's the default now, not sure) for the GPU is only enough to allocate the textures of Kodi interface. Other skins (most of them) may consume more GPU memory. It can probably play some low resolution, low bitrate video files but it will strugle to play higher resolution/bitrate files (it starts to skip frames) or won't play it at all or even crash.
Some 4K HEVC high bitrate (> 50Mbit/s), 60fps may strugle to play with 256MB on the Pi 4 or don't play at all, that's why 320MB is the recommended for the RPi 4. That's why 320MB is the default on LibreELEC for the Pi4.

Of course that setting it higher than that won't improve performance or playback, and is wasted RAM.

You can check how much GPU RAM is being used at a determined time with this commands:
viewtopic.php?t=158157#p1029332

Here is an example of Kodi playing the file jellyfish-120-mbps-4k-uhd-hevc-10bit.mkv from here: http://jell.yfish.us/

Code: Select all

[email protected]:~ $ vcgencmd get_mem gpu
gpu=320M
[email protected]:~ $ vcgencmd get_mem reloc
reloc=84M
Notice that the playback of this file drops frames because it is HDR/10bit (the HDR/10bit support on the Raspberry Pi4 is not yet complete/perfect) and very high bitrate. It is just an example.
Try to play this file with the default settings, p.ex, not setting "gpu_mem=X", like "gpu_mem=320". It will crash instantly!
Last edited by Rascas on Mon Mar 23, 2020 4:20 am, edited 1 time in total.

User avatar
Imperf3kt
Posts: 3491
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: RPi4 video performance

Mon Mar 23, 2020 3:44 am

The default is 64MB, and I have provided one example of an engineer who has stated the Pi4b dynamically assigns the GPU memory.
Here is another, if you require it.
viewtopic.php?f=63&t=243637&p=1487320#p1487100
gpu_mem is pretty much only used for the H264 codec, camera, and if you access DIspmanX directly
55:55:44:44:4C
52:4C:52:42:41

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 8425
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: RPi4 video performance

Mon Mar 23, 2020 8:01 am

ThijsDeschildre wrote:
Sun Mar 22, 2020 9:38 pm
hmm, which field is this exactly?
you can find my edid file here https://pastebin.com/kdvPXci4
dickon wrote:
Sun Mar 22, 2020 9:45 pm
I can't see any 3840x2160 or 4096x2160 modes that are >30Hz in that. You're probably out of luck, unless there's a port that's specifically marked as HDMI 2.0 and your Pi isn't plugged into it.
Based on that your display only supports 4kp60 as YUV4:2:0.
Same answer as to viewtopic.php?f=28&t=267974#p1630237
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

ThijsDeschildre
Posts: 17
Joined: Thu Sep 27, 2012 11:35 pm

Re: RPi4 video performance

Mon Mar 23, 2020 10:51 pm

alright, no 60fps then. not a big deal, but very enlightening how it all works.
Rascas wrote:
Mon Mar 23, 2020 1:12 am
Yes it does. The default 76MB (I believe that's the default now, not sure) for the GPU is only enough to allocate the textures of Kodi interface. Other skins (most of them) may consume more GPU memory. It can probably play some low resolution, low bitrate video files but it will strugle to play higher resolution/bitrate files (it starts to skip frames) or won't play it at all or even crash.
Some 4K HEVC high bitrate (> 50Mbit/s), 60fps may strugle to play with 256MB on the Pi 4 or don't play at all, that's why 320MB is the recommended for the RPi 4. That's why 320MB is the default on LibreELEC for the Pi4.

Of course that setting it higher than that won't improve performance or playback, and is wasted RAM.

You can check how much GPU RAM is being used at a determined time with this commands:
viewtopic.php?t=158157#p1029332

Here is an example of Kodi playing the file jellyfish-120-mbps-4k-uhd-hevc-10bit.mkv from here: http://jell.yfish.us/
yeah, the jellyfish files are what I'm trying.
50mbps 4k sounds wild. I want to see that for myself.

ThijsDeschildre
Posts: 17
Joined: Thu Sep 27, 2012 11:35 pm

Re: RPi4 video performance

Mon Mar 23, 2020 11:28 pm

Took only 10 minutes to download, flash and set up libreelec. Amazing. 4K is playing now. Kodi is much more responsive. The mouse is a little bit slow but acceptable.
Maybe I'll set up an old PC/laptop to use as desktop, and automatically suspend to save power, and just keep the RPi4 for Kodi (since I have absolutely nothing else that plays 4K, except my gaming PC that's in another room).

User avatar
dickon
Posts: 1180
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: RPi4 video performance

Mon Mar 23, 2020 11:43 pm

ThijsDeschildre wrote:
Mon Mar 23, 2020 10:51 pm
50mbps 4k sounds wild. I want to see that for myself.
16k at (IIRC) ~150Mb/s is *really* wild...

(The 2012 Olympics opening ceremony was partially shot in that, with some very specialist cameras, as a technology demo by the BBC in conjunction with NHK, and I, along with a bunch of colleagues, got to see an hour or so's edit of it in the BBC Radio Theatre shortly afterwards. 'Wow' doesn't begin to cover it...).

FWLIW, I personally think chroma subsampling is as bad as interlacing and needs to die. 4:2:2 is minimally acceptable, but anything less is ridiculous. It's here to stay, unfortunately, despite being an analogue-era compression system.

Visitador
Posts: 1
Joined: Tue Mar 24, 2020 4:01 am

Re: RPi4 video performance

Tue Mar 24, 2020 4:12 am

I also recommend LibreELEC, it works perfectly with Pi4.
..

ThijsDeschildre
Posts: 17
Joined: Thu Sep 27, 2012 11:35 pm

Re: RPi4 video performance

Wed Mar 25, 2020 11:29 am

I wonder why video playback on Raspbian is so crappy. It's the standard OS for the Pi, so it doesn't make much sense.

Return to “General discussion”