Automatic frame rate switching in TV box ensures video output matches the video frame rate in order to avoid skipped frames (judder) from time to time, and makes the videos much smoother to watch, especially to trained eyes.
The problem is that the feature is not always implemented, and/or does not work for all apps. AFRd auto frame rate daemon aims to solve this issue by automatically switching video output to match the video framerate ? e.g. 23.976 fps or 59.94 fps ? on Android TV boxes powered by one of Amlogic 64-bit processors, be it S905, S905X, S905X2, S912, S905W and other more recent Armv8 processors from the company.

Developed by Andrey Zabolotny (anpaza), AFRd is Linux daemon can be linked to either bionic for Android, or glibc for Linux operating systems, and the source code can be found on Github.
It relies on two techniques to detect the video frame rate, and adequately change video output (HDMI) frame rate:
- Kernel uevent-based notifications available in AmLogic 3.14 kernels up to Kernel 4.9 used in Android 7 and 8. Example of uevent when a 29.976 fps movie is started (FRAME_RATE_HINT contains the info):
1 2 3 4 5 6 7 8 9 |
change@/devices/virtual/tv/tv ACTION=change DEVPATH=/devices/virtual/tv/tv SUBSYSTEM=tv FRAME_RATE_HINT=3203 MAJOR=254 MINOR=0 DEVNAME=tv SEQNUM=2787 |
- In newer kernels or when uevent notifications are not generated, video decoder notifications emitted at the start and end of playback are used instead. Example of video start:
Since the frame rate is not shown in the data, the daemon will check /sys/class/vdec/vdec_status when the event above is detected:1
2
3
4
5
6add@/devices/vdec.25/amvdec_h264.0
ACTION=add
DEVPATH=/devices/vdec.25/amvdec_h264.0
SUBSYSTEM=platform
MODALIAS=platform:amvdec_h264
SEQNUM=2786
Frame dur is used is not zero, otherwise frame rate data is selected with 23 fps meaning 23.976 fps, 29 is 29.970fps and 59 represents 59.94 fps.1
2
3
4
5
6
7
8
9vdec channel 0 statistics:
device name : amvdec_h264
frame width : 1920
frame height : 1080
frame rate : 24 fps
bit rate : 856 kbps
status : 63
frame dur : 4000
...
The installation will be easily in Android, as Andrey provides an apk (ru.cobra.zap.afrd-0.3.2.apk) which you can install in your rooted TV box.

Then you can enter the app to enable/disable auto frame rate, and adjust other settings such as preferred frequencies. It?s also possible to directly edit AFDR configuration, and/or control the daemon through an API as explained in details in the Github page.
Source:
CNXsoft
https://www.cnx-software.com/2019/07...gic-processors
Comment