jellyfin-mpv-shim icon indicating copy to clipboard operation
jellyfin-mpv-shim copied to clipboard

Change refresh rates based on video framerate

Open sebaslavigne opened this issue 3 years ago • 7 comments

Is your feature request related to a problem? Please describe. When a video uses a different framerate to that of the screen, and specially if the screen framerate is not a multiple of the video framerate, the image can have noticeable lack of smoothness.

Describe the solution you'd like Have the client change the refresh rate of the screen (if supported) to a multiple of that of the video. For example, if the video plays at 25fps, change the refresh rate to 25, 50 or 75 Hz, whichever is the highest supported. TVs usually allow for common NTSC or PAL framerates (23.97, 29.97, 59.94, etc.).

Describe alternatives you've considered I've tried using Lutz Vieweg's mpv-plugin-xrandr by configuring mpv-shim to use an external player with that script loaded, but since mpv-shim starts an instance of mpv with the --idle=yes flag, the script only works for the first playback, and it does not return to the former framerate once the player quits (because it doesn't shutdown mpv).

I was able to add an event handler on the script to return to the former framerate when playback stopped, but I was not able to make it change refresh rates again on subsequent videos.

sebaslavigne avatar Jan 24 '22 21:01 sebaslavigne

Please see: https://gist.github.com/iwalton3/764b95871a52cbb23c4959a4da76e3d6

iwalton3 avatar Jan 24 '22 22:01 iwalton3

Thank you! I understand I have to add modes to xrandr fitting framerates supported by my screen, and then modify the script to call those modes?

sebaslavigne avatar Jan 24 '22 22:01 sebaslavigne

In essence yes. Some modes are not declared as supported but you can add them if you set some overrides in xorg.conf.

iwalton3 avatar Jan 24 '22 22:01 iwalton3

Describe alternatives you've considered I've tried using Lutz Vieweg's mpv-plugin-xrandr by configuring mpv-shim to use an external player with that script loaded, but since mpv-shim starts an instance of mpv with the --idle=yes flag, the script only works for the first playback, and it does not return to the former framerate once the player quits (because it doesn't shutdown mpv).

I was able to add an event handler on the script to return to the former framerate when playback stopped, but I was not able to make it change refresh rates again on subsequent videos.

Not sure if we are using the same script but I added this to make mine work:

function on_start_file()
  xrandr_previously_set = {}
  xrandr_cfps = nil
  xrandr_set_rate()
end
mp.register_event("file-loaded", on_start_file)
mp.register_event("end-file", xrandr_set_old_rate)

tillbaks avatar Feb 17 '22 20:02 tillbaks

Any chance of building a feature like this into jellyfin-mpv-shim?

tremby avatar Apr 26 '22 19:04 tremby

It isn’t planned because it requires different code on each platform and the xrandr script works well enough for me.

Jellyfin Media Player does have this feature, but of course there are many limitations for customization in that player.

iwalton3 avatar Apr 27 '22 02:04 iwalton3

I see. Thanks. I'll look into getting the script working.

I can't use Jellyfin Media Player since there's no build for Raspi.

tremby avatar Apr 27 '22 02:04 tremby