Audio sync and video stuttering

  • Dear all,

    I am having an issue with 9.2.1 on the RPi4 (I know it is still in development). On each video file (regardless of MKV ot M2TS or 1080p or 4K) the video stutters and at the same time, the audio starts playing ahead of the video. The effect gets more pronounced until the audio is a good few seconds ahead and it becomes unwatchable. If the video is paused and resumed, this is corrected for a few minutes or so before it starts again.

    I have tried combinations of turning on and off MMAL acceleration, switching "adjust display refresh rate" (on start/stop , always, off), "sync playback to display", as well as adding a vast range of resolutions and refresh rates to the whitelist. I have also turned on hdmi_enable_4k=1 in config.txt but this seems to have mde no difference.

    I am new to the forum and reasonably new to LibreELEC so apologies if I have overlooked something simple or if this is a known issue, or indeed if I am just being dumb. Any help would be appreciated as this is frustrating, as you can imagine! If logs would help, I would be happy to supply. :thumbup:

    The issue appears to be similar to that described in the thread 2 RPI 4 model B, playback issue on 1 although that issue presents with just one file.

    Many thanks in advance,

    Toby

  • Hi Chewitt,

    Thanks for your reply. I have not tried that, when I get home tomorrow I will give it a go and let you know. I will also try to increase the GPU allocated memory to see if that helps.

    Many thanks, I'll get back to you

    Toby

  • I have a similar problem, but not as severe: 4k video exhibits hesitations -- perhaps even slowdowns without actually stopping -- but without audio problems. Regular HD videos appear to be ok.

    I have a rpi4 and libreelect 9.2.1 just upgraded yesterday. I added hdmi_enable_4kp60=1 to my setup.txt and while I was there changed gpu_mem to 512k.

    (From what I read, that last one may have been ineffectual.)

    Before I made those changes to the setup file, the same hesitations were present, but if I tried to run the movie and look at the cpu stats from the main menu, the screen would blank and the sound would hesitate and it was just a general mess. Stop the stats and just watch the movie and it went back to mild (but annoying) hesitations.

    After the changes, all that went away.... alas except the mild hesitation in the video.

    I tried your suggestion to whitelist only the 59.94 and 60 hz video formats in the whitelist. (I do not have a 50 available: presumably because we're in the land of 60Hz.

    I do not yet have a 4k TV, so a) this isn't terribly important to me yet and b) there are no higher resolutions available in the menu as one might expect.

    Here's running:

    Code
    bick-ubtu3 ~$ iperf -c kodi --port 5201
    ------------------------------------------------------------
    Client connecting to kodi, TCP port 5201
    TCP window size: 85.0 KByte (default)
    ------------------------------------------------------------
    [  3] local 192.168.2.128 port 59088 connected with 192.168.2.120 port 5201
    [ ID] Interval       Transfer     Bandwidth
    [  3]  0.0-10.0 sec   732 MBytes   614 Mbits/sec
    bick-ubtu3 ~$

    I took a few screenshots of an HD movie, a UHD movie, and iperf running. Here they are:

    So I don't think there's a network issue.

    I watched the cpu temp and whether it was throttled as the movie runs and the cpu never went above 47° and that's not even close to throttling. It never showed as throttled, either.

    (BTW, that's in a FLIRC case with no fan. I had my RP3 in a FLIRC case and it did very well with no fan. Looks like RP4 is doing ok, too.)


    One more bit of data: the onscreen player process info (key 'O') shows this:

    Video decoder: ff-hevc-mmal (HW)

    Pixel format: rpi

    Deinterlace method: none

    Video stream: 3,840x2,160 px1.78 AR, 23.976 FPS

    Audio stream: FL, FR, FC, LFE, SL, SR, ff-eac3, 32 bits, 48,000 Hz

    System memory usage: 12% (stable) System CPU usage; (all over the place as usual, bbut max seems to be 37% for brief moments, dodging from one cpu to the other... lows in the single digits, most teens to 20's. I know. Not terribly [word meaning science in the adjectival form]. :) )

    top shows the load average to be 1.33, 1.00, 0.9 as the movie runs. That's a little more [word meaning science in the adjectival form].

    Anyone know what's going on here?

    P.S. If you're wondering why [word meaning science in the adjectival form] instead of ... erm... I dare not say it ... it's because I got this message as I tried to save:

    oops. well, there apparently I said it.

    P.P.S.

    Here's a video I took with my phone that demonstrates the stutter issue.

    External Content youtu.be
    Content embedded from external sources will not be displayed without your consent.
    Through the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.

    Edited once, last by fbicknel: added video (March 15, 2020 at 5:31 PM).

  • Hi Chewitt,

    In the whitelist with a 4K resolution, I only have frequencies 30Hz and below, despite having hdmi_enable_4kp60=1 set in the config file.

    I changed the resolution to 1080p using the frequencies you suggested as well as increasing the GPU memory to 512 as fbicknel said and the same problem shows. It makes me wonder because the audio plays flawlessly, and it seems to be the fact that the video is stuttering sets it progressively further behind the audio.

    As in the case of fbnicknel, my CPU is definitely not overloaded. Something which may be a further symptom is slight screen tearing on the transitions in the GUI, as if the refresh rate is slightly out.

    Do you have any more ideas? I am having a brainstorm but at the moment am at a loss.

    Many thanks again,

    Toby

  • I have default config.txt (no hdmi_enable_4kp60=1 or GPU increases) and a LG 4K TV with 23.976/24/50/59.94/60 Hz modes set for 1080p and 23.976/24/25/29.97/30 set for 4K and the desktop defaulted to 1080p. Apart from washed out HDR content (as no HDR support) I have no issues playing anything. I don't have any 4K60 media .. hence no need to force that config.

    fbicknel is playing [email protected] media on a 1080p panel and RPi4 isn't optimised for that kind of thing (and won't be for aeons) so best option for him would be to re-rip that Movie in 1080p.

    NB: The issue witth 25/29.97/30 modes is that Kodi always outputs progressive so interlaced media requires 50/59.94/60 so that each half-frame can be rendered as a full frame. There is no 4K interlaced media so this is only a 1080 thing.

    At the end of the day not all media is ripped properly, not all TVs support all refresh rates, and RPi4 support under MMAL "is what it is" because it was a quick and dirty hack to ensure something worked at launch. The focus of all development is on GBM/V4L2 not MMAL.

  • Thanks, chewitt, that helps.

    My goal with the new rpi4 upgrade was to get that hardware squared away before the 4k tv purchase. (The old rpi3 will become something like a pi-hole or the like.) (A second rpi4 is on the way with plans to make it an NFS server for the household... but now I'm way off topic. Sorry.)

    Your comment about my panel being 1080p seems to hint that there's extra work for the processor to change my (test) movie's 4k format to 1080p.

    Would I be correct to assume that upgrading the panel to 4k might improve things?

    Is there a similar issue with older movies that are 1080p if they were shown on the 4k display? Or is that a much "easier" conversion for the processor(s) involved?

    ... and now I'm off to see what all that acronym stuff at the end of your note is all about. Should be a good read. :)

  • Converting 4K media to 1080p is handled in hardware but you still need to copy 4K images in memory and on cheap ARM boards (even well made ones like the RPi4) that doesn't come for free. If you play 4K media on a 4K panel (witth whitelist entries) there's no conversion involved. Scaling lower resolution content to 4K has a similar process but with the desktop size at 1080p Kodi will scale SD media to 1080p and output 1080p and the TV can internally handle the upscale to the 4K native panel resolution. You could also force Kodi to run at 4K desktop, but the TV will do a massively better and more efficient job at scaling 1080p to 4K than Kodi/RPi4 will. Low-power ARM boards are fantastic when everything is aligned and they can work to their strenghts. If you want something that can convert anything to anything .. start with a Core i7 NUC as you'll need the CPU grunt :)

  • Very very illuminating and helpful, chewitt.

    I was hoping it was the old (2002 Samsung) TV that was contributing to the problem.

    Now that I know this, I can feel more confident about the conversion to 4k coming up.

    Thanks so much.

  • I have default config.txt (no hdmi_enable_4kp60=1 or GPU increases) and a LG 4K TV with 23.976/24/50/59.94/60 Hz modes set for 1080p and 23.976/24/25/29.97/30 set for 4K and the desktop defaulted to 1080p. Apart from washed out HDR content (as no HDR support) I have no issues playing anything. I don't have any 4K60 media .. hence no need to force that config.

    Hi Everyone,

    I've got an LG 4K TV too and I replaced my old Rpi2 with a new Rpi4 so I can watch 4K content, but I get these playback issues on 1080p. (Not tested 4K yet)

    I've tried the settings which were mentioned in this post:

    Here

    But that doesn't help. It would be nice if someone could check my log if there is something you can notice.

    kodi.log

    Thanks

  • I haven't found related errors at your latest log, so I think it's about a lack of system resources.

    Quote

    Enable HQ Scalers above 50%

    Disable HQ Scalers, and hopefully it will set some system resources free.

    You're still at log level 0, but that's not your fault. GUI settings overwrite advancedsettings.xml. Try to switch to log level 2 at GUI.