Add backend support for reducing energy use#5780
Conversation
This commit will: - Add a new reduceEnergyUse setting to Preferences - Add a new configureEnergyUse method to PlayerCore - Change PlayerCore.startMPV to call the new configureEnergyUse method When the reduceEnergyUse setting is enabled the configureEnergyUse method will apply mpv's builtin fast profile to reduce the energy used by mpv. As the fast profile does not support restoring the old values of the options set by the profile, changes to the reduceEnergyUse setting require IINA to be restarted.
|
This PR only provides the backend support for this feature. I did not include UI as it would generate merge conflicts with some outstanding PRs. This can be tested by enabling the feature using the See issue #5697 for details on the need for this change. |
|
Is there a user request for this? I'm not sure if it's appropriate to treat them as equivalent, because MPV has many profiles, but this setting only has two options (reduce energy use or not). A user conf file can also override this, and the user might not know what's happening just looking at the name of this setting. Perhaps a profile selector would be better? |
|
Good point about expanding this to be a general profile settings. This is about issue #5697 where users with old Macs are complaining because the increase in energy use is noticeable for them and the improvement in picture quality, not so much. This is a regression for these users. This is not for advanced users who know mpv and can create a I was expecting we'd add a One of the users thought IINA ought to just do this by default for Intel Macs. I'm thinking that would not be appropriate for the newer more powerful Intel Macs. Anyway, I only coded up the backend as I wanted advice on how to handle this. Thoughts? |
|
Tried to list all available builtin profiles of the current release of mpv: mpv --profile=help
Available profiles:
enc-to-hp-slate-7 MP4 for HP Slate 7 (1024x600, crazy aspect)
enc-to-nok-6300 3GP for Nokia 6300
enc-to-nok-n900 MP4 for Nokia N900
enc-to-dvdntsc DVD-Video NTSC, use dvdauthor -v ntsc -a ac3+en (MUST be used with 4:3 or 16:9 aspect, and 720x480, 704x480, 352x480 or 352x240 resolution)
enc-to-dvdpal DVD-Video PAL, use dvdauthor -v pal -a ac3+en (MUST be used with 4:3 or 16:9 aspect, and 720x576, 704x576, 352x576 or 352x288 resolution)
enc-f-webm VP9 + Opus (for WebM)
enc-f-mp4 H.264 + AAC (for MP4)
enc-f-avi MPEG-4 + MP3 (for AVI)
enc-f-3gp H.263 + AAC (for 3GP)
enc-v-vp9 VP9 (libvpx)
enc-v-vp8 VP8 (libvpx)
enc-v-mpeg4 MPEG-4 Part 2 (FFmpeg)
enc-v-mpeg2 MPEG-2 Video (FFmpeg)
enc-v-h264 H.264 (x264)
enc-v-h263 H.263 (FFmpeg)
enc-a-opus Opus (libopus or FFmpeg)
enc-a-vorbis Vorbis (libvorbis or FFmpeg)
enc-a-mp3 MP3 (LAME)
enc-a-ac3 AC3 (FFmpeg)
enc-a-aac AAC (libfdk-aac or FFmpeg)
box
sub-box
osd-box
sw-fast
low-latency
gpu-hq
high-quality
fast
encoding
libmpv
builtin-pseudo-gui
pseudo-gui
defaultOnly a few of them are reasonable as a option in our UI. Also I think its better to implement this under
|
|
I implemented a popup button to select builtin mpv profiles:
The code is on the mpv-profile branch. Verified by observe the |
|
This does not address the problem I was trying to address… This goes into IINA design philosophy. Which of these best describes IINA?:
I would say that IINA is a more 1. than 2. For the most part mpv is mostly hidden. It is exposed in
The problem I was trying to solve is that when IINA upgraded from mpv 0.35.0 to 0.38.0 the amount of CPU/energy used during playback greatly increased due to mpv deciding to change the defaults of several options to slightly improve picture quality. This increased load caused problems for users with old hardware. Users that understood mpv probably used IINA's This is the reason why I was suggesting a I believe adding support for profiles would address discussion #6032. But to me the first step would be to address the serious problems in the existing There are other ways in which IINA falls short on being a "UI frontend for mpv". In some cases, for example HDR settings, IINA will stomp on advanced user's attempts to apply mpv configuration. In The problem that comes up the most with advanced configuration is the failure to support dynamic key assignment from Lua scripts. I remember @svobs discussing changes needed to support this with the mpv project. I don't know if he was able to solve this problem. Tuesday is my busy day. I will take a look at the |
Check out the current dev branch, this has already be fixed by 712d9cd :) While I agree you that we indeed hide most of the mpv features from the users, but having the ability to choose builtin mpv profile is still important imo. So may be we can move this feature to General or A/V tab and rename it to "video quality", rename the options, with some descriptive text to tell users the difference between the options. |
|
First on this:
I did before I posted that. I had selected a row, clicked on On this:
I'd leave this setting on the However… I had forgotten about the details of this PR. It is coming back to me now and I'm thinking we should not make any changes to IINA at this point in time. More on this after some info and experiments… On this:
It is just apply-profile, without
It is really desirable for IINA to respond dynamically to changes to a setting. Using this command with the restore argument allows IINA to properly respond to a user disabling the The following shows the other reason why I was using this command… I set
Checking the log files I see IINA is setting the option to But checking the mpv log it is like that did not happen: Nothing. Nothing at all. If instead I enable I came to the conclusion that for some reason However Experimenting further… Despite there being nothing in the mpv log file the changes the fast profile applies seem to have been made: In either case if I try and check the value of the low-batt@gag ~$ echo '{ "command": ["get_property", "profile"] }' | socat - /tmp/mpv-socket | jq
{
"request_id": 0,
"error": "error accessing property"
}
low-batt@gag ~$ Probably some of this is simple to fix in mpv, but we don't want to distract them with that now as we have critical mpv problems that need to be fixed. I'm thinking we close this PR and don't take any action on this at this time. Eventually we report the odd mpv behavior to the mpv project. Some feedback on the changes even though I don't think we should implement anything now… This error: Is because the new logging that lists settings that were changed from their defaults needs to be updated when a new settings value class is added. Possibly we could avoid this by making it data driven. To do that you might change the settings from being static This is the old way: chkErr(setOptionString(MPVOption.ProgramBehavior.profile, Preference.MpvProfile(rawValue: profile)!.description, level: .verbose))Other code that passes settings values to mpv now does this: return String(describing: Preference.enum(for: key) as Preference.HardwareDecoderOption)To match up with the other enums declared in enum MpvProfile: Int, InitializingFromKey, CaseIterable {
static let defaultValue: Preference.MpvProfile = .default
init?(key: Preference.Key) {
self.init(rawValue: Preference.integer(for: key))
}
var description: String {
switch self {
case .default: "default"
case .fast : "fast"
case .high_quality: "high-quality"
case .low_latency: "low-latency"
}
}
case `default` = 0
case fast
case high_quality
case low_latency
} |


This commit will:
reduceEnergyUsesetting toPreferencesconfigureEnergyUsemethod toPlayerCorePlayerCore.startMPVto call the newconfigureEnergyUsemethodWhen the
reduceEnergyUsesetting is enabled theconfigureEnergyUsemethod will apply mpv's builtinfastprofile to reduce the energy used by mpv.As the
fastprofile does not support restoring the old values of the options set by the profile, changes to thereduceEnergyUsesetting require IINA to be restarted.Description: