mpvnet-player / mpv.net

🎞 mpv.net is a media player for Windows with a modern GUI.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Profile selection doesn't work

uugaabuugaa opened this issue · comments

commented

Ctrl+p script-message-to mpvnet select-profile #menu: View > Show Profile Selection

Doesn't work neither from keybind nor from menu. However,

Ctrl+P script-message-to mpvnet show-profiles #menu: View > Show Profiles

this works, which shows:

profile3

    ytdl-format = bestvideo[height<=?1440][filesize!=null]+bestaudio/best
    sub-auto = fuzzy
    ytdl-raw-options = sub-lang="en",write-sub=,write-auto-sub=
    sub-font = Noto Color Emoji
    scale = ewa_lanczossharp
    cscale = ewa_lanczossharp
    dscale = mitchell
    slang = en,eng

profile2

    ytdl-format = bestvideo[height<=?1080][filesize!=null]+bestaudio/best
    sub-auto = fuzzy
    ytdl-raw-options = sub-lang="en",write-sub=,write-auto-sub=
    sub-font = Noto Color Emoji
    slang = en,eng

profile1

    ytdl-format = bestvideo[height<=?1440][filesize!=null]+bestaudio/best
    sub-auto = fuzzy
    ytdl-raw-options = sub-lang="en",write-sub=,write-auto-sub=
    sub-font = Noto Color Emoji
    scale = bilinear
    cscale = bilinear
    dscale = bilinear
    slang = en,eng

dont-log

    script-opts-append = memo-enabled=no

sw-fast

    sws-scaler = bilinear
    sws-fast = yes
    zimg-scaler = bilinear
    zimg-dither = no

low-latency

    audio-buffer = 0
    vd-lavc-threads = 1
    cache-pause = no
    demuxer-lavf-o-add = fflags=+nobuffer
    demuxer-lavf-probe-info = nostreams
    demuxer-lavf-analyzeduration = 0.1
    video-sync = audio
    interpolation = no
    video-latency-hacks = yes
    stream-buffer-size = 4k

gpu-hq

    profile = high-quality

high-quality

    scale = ewa_lanczossharp
    hdr-peak-percentile = 99.995
    hdr-contrast-recovery = 0.30
    deband = yes

fast

    scale = bilinear
    dscale = bilinear
    dither = no
    correct-downscaling = no
    linear-downscaling = no
    sigmoid-upscaling = no
    hdr-compute-peak = no
    allow-delayed-peak-detect = yes

encoding

    vo = lavc
    ao = lavc
    keep-open = no
    force-window = no
    gapless-audio = yes
    resume-playback = no
    load-scripts = no
    osc = no
    framedrop = no

libmpv

    config = no
    idle = yes
    terminal = no
    input-terminal = no
    osc = no
    input-default-bindings = no
    input-vo-keyboard = no
    input-media-keys = no

builtin-pseudo-gui

    terminal = no
    force-window = yes
    idle = once
    screenshot-dir = ~~desktop/

pseudo-gui

    player-operation-mode = pseudo-gui

default

It leads me to my second problem, when I try to use profile cycling lua scripts to make it work they go through the profiles like pseudo-gui, builtin-pseudo-gui, libmpv, encoding. I haven't put them in my mpv.conf so why would they appear as profiles? Is there a way to ignore such profiles when I'm using scripts to cycle through? Or make select-profile work somehow because I've only found lua scripts that can cycle through profiles and not select from an item list.

Using --config=no gives me same issue.

Steps to reproduce the behavior:

  1. Put KEY script-message-to mpvnet select-profile #menu: View > Show Profile Selection in input.conf
  2. Press KEY
  3. Nothing happens

Expected behavior
Show profile selection menu.

mpv.net version: 7.1.1.0

From what i know select-profile used command palette which was removed in mpv.net v7 because of some incompatibilities, so that won't work.

I haven't put them in my mpv.conf so why would they appear as profiles?

They're internal mpv profiles, and any profile cycling script will be using profile-list command that lists every single one that's available.

You can try cycle-profile that allows you to choose which profiles to cycles through, eg: script-message cycle-profiles profile1 profile2 "profile 3"

commented

You can try cycle-profile that allows you to choose which profiles to cycles through, eg: script-message cycle-profiles profile1 profile2 "profile 3"

Just found that script and came to edit the issue. Also found this.

From what i know select-profile used command palette which was removed in mpv.net v7 because of some incompatibilities, so that won't work.

Is apply-profile also removed? I used to have one or two keybinds to directly apply a perticular profile which didn't require to go through all the profiles. I guess putting most used profiles first in input.conf using CogenRedTester's script will do for now.

Edit: Found out that script-message cycle-profiles profile1 "" will eventually select profile1 so I guess keybinds to select profile is good to go as well. I think you can close this issue.

Is apply-profile also removed? I used to have one or two keybinds to directly apply a perticular profile which didn't require to go through all the profiles. I guess putting most used profiles first in input.conf using CogenRedTester's script will do for now.

Edit: Found out that script-message cycle-profiles profile1 "" will eventually select profile1 so I guess keybinds to select profile is good to go as well. I think you can close this issue.

apply-profile is a mpv command, so that one certainly wasn't removed in mpv.net.

You should be able to bind them in input.conf like this:

n apply-profile youtubeprofilename; show-text "Applying profile: youtube"
n apply-profile "youtube profilename"; show-text "Applying profile: youtube"


Here's a barebones script that displays a profile list based on recent script:

selectProfileList.lua

local o = {
    profiles = "",
    font_bold = false,
    font_scale = 40,
    border_size = 0.7,
    hi_color = "FFCF46"
}

(require "mp.options").read_options(o)
local msg = require "mp.msg"

local profiles = {}
for profile in string.gmatch(o.profiles, "([^,]+)") do
    table.insert(profiles, profile)
end

-- Hide mpv's built-in profiles
local blacklisted_profiles = {
    "pseudo-gui",
    "builtin-pseudo-gui",
    "libmpv",
    "encoding",
    "fast",
    "high-quality",
    "gpu-hq",
    "low-latency",
    "sw-fast",
    "default",
}

local function is_blacklisted(profile)
    for _, blacklisted_profile in ipairs(blacklisted_profiles) do
        if profile == blacklisted_profile then
            return true
        end
    end
    return false
end

-- Use profile-list if no profiles are defined in the config file
if #profiles == 0 then
    local profile_list = mp.get_property_native("profile-list", {})
    for _, profile in ipairs(profile_list) do
        if not is_blacklisted(profile.name) then
            table.insert(profiles, profile.name)
        end
    end
end

local function apply_profile(profile_name)
    if profile_name then
        msg.info("Applying profile", profile_name)
        mp.commandv("apply-profile", profile_name)
    else
        msg.error("Unknown profile")
        mp.osd_message("Unknown profile")
    end
end

-- Display list on OSD
function draw_list(list, choice)
    local bold_tag = o.font_bold and "{\\b1}" or ""
    local msg = string.format("{\\fscx%f}{\\fscy%f}{\\bord%f}%s",
                o.font_scale, o.font_scale, o.border_size, bold_tag)
    local hi_color = o.hi_color:gsub("(%x%x)(%x%x)(%x%x)","%3%2%1")
    for i=1, #list, 1 do
        local p = list[i]
        if i == choice then
            msg = msg.."{\\1c&H"..hi_color.."}"..p.."\\N\\N{\\1c&HFFFFFF}"
        else
            msg = msg..p.."\\N\\N"
        end
    end
    mp.set_osd_ass(0, 0, msg)
end

-- Handle up/down keys
function select(list, choice, inc)
    choice = choice + inc
    if choice < 1 then
        choice = 1
    elseif choice > #list then
        choice = #list
    end
    draw_list(list, choice)
    return choice
end

-- Load profile and remove binds
function load(list, choice)
    unbind()
    if choice <= #list then
        apply_profile(list[choice])
        mp.osd_message("Applying profile: \"" .. list[choice] .. "\"")
    end
end

-- Unbind keys
function unbind()
    mp.remove_key_binding("profile-UP")
    mp.remove_key_binding("profile-DOWN")
    mp.remove_key_binding("profile-ENTER")
    mp.remove_key_binding("profile-KP_ENTER")
    mp.remove_key_binding("profile-ESC")
    mp.set_osd_ass(0, 0, "")
    list_drawn = false
end

-- Display list and add keybinds
function display_list()
    if list_drawn then
        unbind()
        return
    end
    local choice = 1
    draw_list(profiles, choice)
    list_drawn = true

    mp.add_forced_key_binding("UP", "profile-UP", function()
        choice = select(profiles, choice, -1)
    end, {repeatable=true})
    mp.add_forced_key_binding("DOWN", "profile-DOWN", function()
        choice = select(profiles, choice, 1)
    end, {repeatable=true})
    mp.add_forced_key_binding("ENTER", "profile-ENTER", function()
        load(profiles, choice)
    end)
    mp.add_forced_key_binding("KP_ENTER", "profile-KP_ENTER", function()
        load(profiles, choice)
    end)
    mp.add_forced_key_binding("ESC", "profile-ESC", function()
        unbind()
    end)
end

mp.add_key_binding(nil, "display-profiles", display_list)

selectProfileList.conf

# Font settings
font_bold=no
font_scale=40
border_size=0.7
hi_color=FFCF46
# Comma separated list of profile names: profile1,pro file 2,profile3…
profiles=

Ctrl+p script-message-to selectProfileList display-profiles

 
You can customise your own list in the config file, if profiles is empty it will list every available profile while also filtering out the built-in ones.