How to automatically change resolution after switching TVs?

  • Hi there,

    I have LibreELEC 11.0.6 running on RPi 3. I recently switched TVs from an unsatisfactory smart 4K down to a half-HD (720p, native resolution is 1360x768@60Hz) I had previously. Now, the problem is, even if I turn on the TV first, then LibreELEC, the TV displays "not supported" because the previous resolution is out of range for this TV. Usually, I leave the LibreELEC box turned on and just turn off the TV when I don't watch it. Of course, as I don't have a working display, everything has to be done through SSH, or the Web interface (which is unaffected).

    I came across a similar topic, but the proposed solution (capture EDID and set it up as a boot parameter) didn't work for me.

    Another topic gave a slightly different solution, that didn't work wither. It advised to put "video=HDMI-A-1:1360x768M@60" (I adapted from the topic according to my TV) among the kernel parameters in /flash/cmdline.txt

    What I tried, in details:

    Setting the resolution from the Web interface

    1. System > Display > Resolution
    2. Selected 1360x768
    3. Save
    4. The TV briefly flashed and I could see the Estuary skin color, but then turned dark and kept on displaying "Not supported".

    Capturing EDID and using it as a boot parameter

    The Wiki page doesn't give any specifics for RPi, so I loosely followed the x86_64 Intel instructions:

    Mounted /flash with read-write permissions: mount -o remount,rw /flash

    Tested display connection: tail /sys/class/drm/*/status

    Got:

    Code
    ==> /sys/class/drm/card0-HDMI-A-1/status <==
    connected
    
    ==> /sys/class/drm/card0-Writeback-1/status <==
    unknown

    Dumped EDID: getedid create

    Got:

    Code
    successfully installed edid override for HDMI-A-1

    Created the path and the actual EDID file:

    Code
    mkdir -p /storage/.config/firmware/edid
    cat /sys/class/drm/card0-HDMI-A-1/edid > /storage/.config/firmware/edid/edid.bin

    Then the cpio archive that will be loaded:

    Code
    cd ~
    mkdir -p cpio/lib/firmware/edid
    cp .config/firmware/edid/edid.bin cpio/lib/firmware/edid/
    cd cpio/
    find . -print | cpio -ov -H newc > ../edid.cpio

    Moved the file to the boot partition /flash:

    Code
    mv ../edid.cpio /flash/

    There it is:

    That's were the instructions for x86_64 don't work anymore: there's no syslinux.cfg or extlinux.conf in /flash on LibreELEC, so I edited cmdline.txt instead. It now looks like this:

    Code
    boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 quiet
    initrd=/edid.cpio drm.edid_firmware=HDMI-A-1:edid/edid-HDMI-A-1.bin video=HDMI-A-1:D

    According to the Wiki, a reboot is the last step. Except that it doesn't work. In the Web interface, the claimed resolution is correct at 1360x768, even kmsprint gives the correct resolution:

    Code
    Connector 0 (32) HDMI-A-1 (connected)
      Encoder 0 (31) TMDS
        Crtc 3 (90) [email protected] 85.500 1360/256/112/64/+ 768/18/6/3/+ 60 (60.02) P|D 
          Plane 4 (91) fb-id: 296 (crtcs: 0 1 2 3) 0,0 1360x768 -> 0,0 1360x768 (XR24 AR24 AB24 XB24 RG16 BG16 AR15 XR15 RG24 BG24 YU16 YV16 YU24 YV24 YU12 YV12 NV12 NV21 NV16 NV61 RGB8 BGR8 XR12 AR12 XB12 AB12 BX12 BA12 RX12 RA12)
            FB 296 1360x768 XR24

    What I want to achieve

    Set LibreELEC so it automatically probes for the highest supported resolution or, if probe gives no result (TV is turned off or disconnected), then use the latest one, much like a laptop does when first connecting to an unknown projector.

    While at it:

    I also wanted to give it a slight overclock and perhaps allocate more RAM to the GPU in order to get a more "fluid" experience and finally allow for basic x265 decoding. How much RAM should I give the GPU in LibreELEC?

    I'd like the boot time splash screen to be displayed with a 16/9 ratio. For as long as I can remember, the splash screen LibreELEC logo was always stretched from 4/3. This really is a minor detail.

  • Go to Best Answer
  • EDID capture fakes the presence of the TV so LE/Kodi boots and sees an HDMI connection when the TV is turned off. It does nothing more. It is not a magic cure for old TVs with weird resolutions. Ignore those guides/articles.

    Start over with a clean LE12b2 install (newer kernel/drivers and RPi firmware than LE11).

    If needed you can force the initial boot splash to 16:9 using "video=HDMI-A-1:1280x720M@60" in cmdline.txt but once Kodi runs it auto-switches based on available resolutions (determined from EDID data) so this does not force Kodi to a specific resolution.

    Creating /storage/.kodi/userdata/advancedsettings.xml with that ^ content may work to force the initial resolution. If the resolution is not available in the EDID data, it won't work. Start with standard 1280x720 resolution. If the 1360x768 resolution is 1080i it will not work as Kodi only outputs progressive and thus filters/ignores all interlaced modes.

  • X/ 1360x768 is old, but not weird! AFAIK this TV has 768 horizontal lines.

    How'd I do that without losing the database, painfully corrected in countless instances since the trackers make a lot of mistakes? Source settings, shortcuts, viewed state?

    I ported it over the years from Krypton to Nexus, encountered nonspecific problems after upgrading from one version to another (Widevine-protected streams never displaying properly, backup plugin never worked in auto mode…), to the point I am really wary of upgrading anymore, especially to a beta version. I mean, no matter how careful the process, things can get lost.

    To add some challenge, I don't currently have a working Linux computer.

    Besides, is starting over from scratch really expected when switching TVs?

    I mean, you say that on booting, Kodi should auto-switch by itself, why isn't it doing it this time? The wiki says Kodi should be the first in the chain to be booted, but EDID data is only sure to be available when the TV is turned on first… I'm lost.?(

  • Starting over should not be needed, but when faced with a weird/old TV that's not playing ball and someone with a much upgraded config (and thus likely hoarding unknown bits of old config) .. a clean install eliminates some guesswork and reduces the number of variables involved.

    RPi boots using code (that cannot be changed) in the chip. This boots firmware on the SD card which reads EDID data from HDMI, which boots Linux, which reads EDID data from HDMI, which boots Kodi, which reads EDID data from HDMI.

    RPi boots from an SD card. So just use a different card to test with LE12 and then the existing setup isn't touched. You don't need a Linux machine to create a bootable SD card (even lowly Windows can manage it, and we have an app to make it simple).

  • I've been using LE12 for the last 10 months on an RPi5 and it's been solid. The latest beta is now superseded by final release, but there's no real-world change. If you are cautious about updates (some are) then just experiment with a spare SD card.

  • Ok, done. After setting up the correct time, the few updated plugins installed without a protest.

    However, the added "video=HDMI-A-1:1360x768M@60" in cmdline.txt didn't help: logo is still stretched from 4/3.

    Weird: when I reboot from the GUI, the LibreELEC logo appears twice in a row. May not be relevant but curious nevertheless.

    Now, how would I restore "just enough" settings to make it usable without a lengthy library scan yet avoid common pitfalls?

  • Just a thought here. Over the years some of the older TVs we've owned had settings to adjust the picture size/AR and many times I recall needing a few tweaks when using LE and or Kodi. As for porting from old versions I've never had any luck and found that a fresh new install removes all doubt about artifacts from old builds. LE12 on my RPi5 is also been solid and trouble free (after saving the EDID setup).

  • chewitt Worked after a few adjustments. At first the splash screen displayed with the proper ratio, but the GUI required manual adjustment to the TV's native 1360x768 resolution as the picture was cropped on all four sides.

    I then proceeded on installing an addon to view some local TV, which required Widevine. This time, it displayed correctly (WIN!)

    Then tried to overclock following milhouse's conservative settings, but just got a kernel panic :-/

    Reddirt Of course going the clean reinstall method is sure to yield consistent results. But I'm not really sure the average end-user would like to lose its "viewed" state, at the very least, or go through all reconfiguring scraper plugins, correct hundreds of mismatched media by hand, etc.

  • The choice is pretty simple. Fresh install with accompanying headaches or chase unkownn maybes. Trust me I get it and have been on both sides as most of us have been. Today it's so easy to load up a complete working LE system on a thumb drive and test out everything before building a semi permanent system to me is a no-brainer. I think the average user does this for the love of the hobby and new discoveries. Chasing a perfect bug free bit of software with so many variables seems a little foolish.

  • Sure, after all LibreELEC isn't exactly a "productivity" software. Unlike a regular OS upgrade where one must be fully operational within a very short timeframe, it's not unreasonable for a LE user to take a bit of time to reconfigure everything from scratch every year and a half, or whenever a new LE version comes out. There's no such thing as a bug-free software, even a (comparatively) simpler like LE.

    Still, while a library scan can run (mostly) unattended and third-party plugins source reconfigured, there are two parts I'd really like to keep:

    • "ghost" media that disappeared in a HDD crash. I replace them whenever I can, but not actively looking for them. I know it's not the "cleanest" way to keep a list, but I haven't found a decent tool that would spit out a text list according to a given criteria. How can I extract said "ghost" media?
    • The "viewed" state. Can this part of the database be restored over a fresh library scan?

    That, and finding the right overclocking settings…

  • You're beyond my understanding with the Library issues. I keep my system very simple and have all of our movies ripped from our DVDs on a hard drive in a folder named "Movies" and of course TV shows in a folder named "TV Shows". They all are right there in alphabetical order when we want to watch them. Not elegant I know but simply works for us. I've never had a need for the Library functions (so far) and unless I'm missing something important all works fine.

    Regarding overclocking you might look on the Raspberry Pi website. I have friends who like to brag about overclocking their Rpi's and how fast they are just before they ask me for help with their software issues. Good Luck.;)

  • "ghost" media that disappeared in a HDD crash. I replace them whenever I can, but not actively looking for them. I know it's not the "cleanest" way to keep a list, but I haven't found a decent tool that would spit out a text list according to a given criteria. How can I extract said "ghost" media?

    Kodi Settings > Media > Clean Library should remove anything that's missing. IIRC there are Kodi add-ons that run this on a schedule or you can do it the old-school way and invoke a clean using the command line "kodi-send" tool from a cron task.

    The "viewed" state. Can this part of the database be restored over a fresh library scan?

    Just backup the DB files and guisettings.xml/sources.xml/passwords.xml files (and for bonus credit, the add-on settings files) then stop Kodi and restore them to the clean install before restarting Kodi .. and on restart it will migrate (update) the DB files to latest versions with all content and viewed state intact. The guisettings.xml file handles all the rest of Kodi GUI config and if you backed up the add-on settings you still need to reinstall the add-ons but nothing needs to be reconfigured from scratch.

    Learn how to do that ^ and Kodi updates from a clean install are trivial and take 5 minutes.

  • I keep my system very simple and have all of our movies ripped from our DVDs on a hard drive

    I have 5 of them, each containing the same folders (each representing a resolution/source). Makes hand-sorting easier. I don't move files between disks as this loses the "watched" state on Kodi and creates duplicates. Keeping few HDDs makes things simpler but riskier should one crash, and my experience of HDD reliability isn't exactly stellar. More HDDs means more noise but more security.

    Seems you're using Kodi as a specialized file browser rather than a full fledged media player that fetches additional data. Which is not a criticism btw, but sure doesn't fit my needs.

    friends who like to brag about overclocking

    I don't care one bit about bragging. I'd like to be able to play x265 without stuttering / overheating, knowing the RPi3 doesn't have hardware-accelerated x265 decoding.

    Kodi Settings > Media > Clean Library should remove anything that's missing.

    That's exactly what I don't want to do. I want to keep the missing ones so I can replace them whenever I find them. Like in "Oh, I'd like Mad Genius tonight… Open the tile for details… last button… read path… crap, it was on usb6, don't bother, it's a ghost". Not the most efficient way to find them.

    Or, as said, find a way to write the missing filenames in a text file in a given directory, and keep the library clean.

    Learn how to do that ^ and Kodi updates from a clean install are trivial and take 5 minutes.

    Indeed that looks very clean. I guess I'd have to do that after cleaning up the library, which can only be done when I can get the list of missing files. Any idea on how to do that?

  • No idea, but I'd start with running a scan with Kodi in debug mode and tailing the logs to see if there's anything that can be grep'd in a future scan/run.