What it does:
- Acts as a daemon, basically monitoring if some video is played, tries to get its framerate, and changes display mode accordingly.
What's needed:
- Root (Magisk)
- Busybox (Magisk module)
- 1080p or 2160p setup (only resolutions with 24/50/60 support)
What to do:
- Extract zip and copy 50afr to /data/adb/service.d (autostart place)
- Give file exec perms from terminal:
Code:
chmod +x /data/adb/service.d/50afr
- Either reboot device and let script work in the background, or launch script manually to see it at work. tip: -d switch shows some debug crap.
Notes:
- Startup resolution will be considered as default by script, the one it will go back to on video stop
- Tested on most common players (VLC, MX Player...) and some free IPTVs. I didn't try Kodi though, but should work everywhere hardware video decoding is used anyway.
- To update, just overwrite script. To remove, just delete script from where it is.
- Of course, script can be autostarted via init.d too, as long as root and busybox are there.
Advanced:
Some variables can be adjusted on top of script:
- SUPPORT_25_30 : 0 (disable) | 1 (enable) : Whether script can switch to 25hz and 30hz in addition to 24/50/60hz. Must be supported by TV. If disabled, 25/30fps will go to 50/60hz instead. Disabling also can save much useless blackouts (sync on double refresh rate barely hurts). Refresh rates such as 23.976, 29.97 and 59.94 are NOT supported and rounded to integer because only approximate fps can be caught.
- DEFAULT_TIME : In seconds, how long to wait before going back to default display mode after video stop.
- RETRIES : How many times script will look for current fps before considering it as reliable. Must be > 0 since video stop case checks 2 times if it's really stopped (1 try, 1 retry, at best). Recommended value is at least 2, depending on next option.
- TRY_DELAY : In seconds, delay between each retry, can be decimal value. Know that app such as Youtube takes at least 3-4 seconds to stabilize. So, expected values are about RETRIES*TRY_DELAY=3 or 4. But it entirely depends on apps you're using, if streaming from network, your network speed and so on. Therefore trial and error can be a good way to find what suits you.
SUPPORT_25_30=1 DEFAULT_TIME=3 RETRIES=3 TRY_DELAY=1
Enjoy! (or not, and report, or not!)

DOWNLOAD: afr_script.zip
CHANGELOG:
- 15/03/2019
- Compatibility fixes, no functionality change, no need to update if script didn't stop to work
- Compatibility fixes, no functionality change, no need to update if script didn't stop to work
- 01/03/2019
- Fixed: Refresh rate change would cause box to go into deep sleep when HDMI-CEC enabled !!
- Fixed: Preserve user defined scaling if any (Display -> Screen position)
- 26/02/2019
- Added custom delay for how long to wait before going back to default mode on video stop (DEFAULT_TIME)
- Now aborting still active past thread(s). Dramatically reduces useless "switches in a row", especially between videos in sequence
- 25/02/2019
- More codecs detected, some older were obviously excluded (mpeg1/2...)
- Better logging
- 22/02/2019
- Added (optional) 25/30hz support
- Increased delays to prevent false positives
- 21/02/2019
- Added 24hz support
- More reliable fps detection
- 20/02/2019
- Initial release
- 50/60hz support
Comment