User avatar
Niccolo
Posts: 25
Joined: Mon Dec 14, 2015 8:45 am
Contact: Website

MPEG-4 video jerky on Raspberry Pi 4

Mon Mar 29, 2021 9:01 am

I upgraded my Kodi media center from the Raspberry Pi 3 to a new Raspberry Pi 4 with 4 Gb of RAM. Unfortunately all my old videos encoded with the XviD library into MPEG-4 format, play unacceptably jerky.
I know that the RPi4 does not have the hardware decoder for MPG2, using the vcgencmd command I see that also the MPG4 is missing:

Code: Select all

vcgencmd codec_enabled MPG4
MPG4=disabled
The FAQ says that the CPU is fast enough to decode the stream in software, but my experience is so jerky that is unacceptable. The Kodi log file reports the hardware error, but no hints about software under-performance:

Code: Select all

 ERROR: CMMALVideo::Open Failed to commit format for decoder input port vc.ril.video_decode:in:0(MP4V) (status=3 EINVAL)
 
The video is 1366x768 compressed at 6000 kbit/s (about 3 Gb per hour) with the following encoding:

Code: Select all

Format                                   : MPEG-4 Visual
Format profile                           : Advanced Simple@L4
Format settings, Matrix                  : Default (H.263)
Codec ID                                 : V_MPEG4/ISO/ASP
Frame rate                               : 29.970 (30000/1001) FPS
Writing library                          : XviD 67
 
Should the software decoding work flawlessly? Is that a Kodi problem?

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

Re: MPEG-4 video jerky on Raspberry Pi 4

Mon Mar 29, 2021 10:18 am

H263, MPEG4, and the option of MPEG2 and VC1 are all gone on Pi4.

Software decode is normally fast enough for 1080p30 in any of those codecs.
Are you using Kodi under Raspberry Pi OS, or as part of LibreElec? LibreElec is generally more optimised than Raspberry Pi OS.
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.

User avatar
Niccolo
Posts: 25
Joined: Mon Dec 14, 2015 8:45 am
Contact: Website

Re: MPEG-4 video jerky on Raspberry Pi 4

Mon Mar 29, 2021 3:25 pm

I use Kodi 18.7 as shipped with RaspiOS 10.8 Buster. Kodi is started via the kodi-standalone script from the text console, by a non-root user (actually I created a Systemd service for it). No X.org or desktop environment is instaled.

User avatar
Niccolo
Posts: 25
Joined: Mon Dec 14, 2015 8:45 am
Contact: Website

Re: MPEG-4 video jerky on Raspberry Pi 4

Tue Mar 30, 2021 6:58 am

Today I tried (on the same hardware) LibreELEC 9.2, which packs Kodi 18.9 over Linux Kernel 4.19.x. Indeed the same videos play perfectly smooth on that environment. So now the problem is to discover the differencies between RaspiOS Buster and LibreELEC.
The first step is to discover if the problem relies on the Operating System or in Kodi, do someone have hints on how to do the bisection?
P.S. I tried also LibreELEC 10.0 Beta, featuring Kodi 19.0 over Linux Kernel 5.10.17, videos are smooth here too.
Last edited by Niccolo on Tue Mar 30, 2021 8:52 am, edited 1 time in total.

fruitoftheloom
Posts: 27226
Joined: Tue Mar 25, 2014 12:40 pm

Re: MPEG-4 video jerky on Raspberry Pi 4

Tue Mar 30, 2021 7:32 am

Niccolo wrote:
Tue Mar 30, 2021 6:58 am
Today I tried (on the same hardware) LibreELEC 9.2, which packs Kodi 18.9 over Linux Kernel 4.19.x. Indeed the same videos play perfectly smooth on that environment. So now the problem is to discover the differencies between RaspiOS Buster and LibreELEC.
The first step is to discover if the problem relies on the Operating System or in Kodi, do someone have hints on how to do the bisection?

It will be hard to dissect LibreElec as it was not based on any Linux Distro.....


OpenElec which was LibreElecs troubled parent, state:

Unlike other Kodi solutions, OpenELEC is not based on Ubuntu. In fact, it's not based on any Linux distribution; OpenELEC has been built from scratch specifically to act as a media center. That means it doesn't include drivers for things that just won't be used like 3G cards and graphics tablets, for example.

https://openelec.tv/
Take what I advise as advice not the utopian holy grail, and it is gratis !!

User avatar
Niccolo
Posts: 25
Joined: Mon Dec 14, 2015 8:45 am
Contact: Website

Re: MPEG-4 video jerky on Raspberry Pi 4

Thu Apr 01, 2021 11:16 am

Hi folks! I'm very happy to inform you that I have discovered what it seems a regression.
Downgrading to kernel 5.4.83 solves the issue, also kernel 4.19.118 is ok.

So the final recipe to solve the bug was to revert to commit 453e49 by issuing the command:

Code: Select all

rpi-update 453e49bdd87325369b462b40e809d5f3187df21d
I verified that both 5.10.1 and 5.10.17 have the bug. That bug is not so apparent, unless you play MPEG4 videos, in which case is horrible. The only problem recorded into the kodi.log is the message

Code: Select all

2021-04-01 13:00:04.286 T:2561659088  NOTICE: CVideoPlayerAudio::Process - stream stalled
Now I think that I have to open an issue: if someone have some hints on where to open and what keywords to use, is welcome.

ZedeN
Posts: 13
Joined: Wed Sep 11, 2019 12:26 pm

Re: MPEG-4 video jerky on Raspberry Pi 4

Thu Apr 01, 2021 11:29 am

Thank you! Fixed the issues I had with 4K IPTV streams! viewtopic.php?f=35&t=308444

User avatar
Niccolo
Posts: 25
Joined: Mon Dec 14, 2015 8:45 am
Contact: Website

Re: MPEG-4 video jerky on Raspberry Pi 4

Thu Apr 01, 2021 6:31 pm

Just a followup: kernel 5.4.81 turned out to be unstable (firmware crashes) with some MPEG-TS files containing videos in AVC format, so I reverted to 4.19.118, which seems stable in my case (RaspiOS based on Buster 10.8). This is the commit I installed:

Code: Select all

rpi-update 866751bfd023e72bd96a8225cf567e03c334ecc4

User avatar
manu2007
Posts: 43
Joined: Fri Apr 02, 2021 1:13 pm

Re: MPEG-4 video jerky on Raspberry Pi 4

Thu Apr 08, 2021 4:33 pm

Niccolo wrote:
Thu Apr 01, 2021 6:31 pm

Code: Select all

rpi-update 866751bfd023e72bd96a8225cf567e03c334ecc4
Thanks a lot, that fixes the horrid tearing and jerkiness with video playback.

I've downloaded this simple test with youtube-dl in different resolutions :

https://www.youtube.com/watch?v=cuXsupMuik4

That demonstrates very clearly the difference.

:?

m4cios
Posts: 3
Joined: Tue Oct 16, 2012 3:48 pm

Re: MPEG-4 video jerky on Raspberry Pi 4

Mon Jun 28, 2021 12:26 pm

Niccolo wrote:
Thu Apr 01, 2021 6:31 pm
Just a followup: kernel 5.4.81 turned out to be unstable (firmware crashes) with some MPEG-TS files containing videos in AVC format, so I reverted to 4.19.118, which seems stable in my case (RaspiOS based on Buster 10.8). This is the commit I installed:

Code: Select all

rpi-update 866751bfd023e72bd96a8225cf567e03c334ecc4
That fixed all my problems with 720p xvid files. I hope it will be fixed in 5.10.17+ kernels.

Return to “Troubleshooting”