Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use-filedir-conf=yes-options doesn't apply to .m3u-playlist entries #15803

Open
6 tasks done
zzzealed opened this issue Feb 5, 2025 · 13 comments
Open
6 tasks done

use-filedir-conf=yes-options doesn't apply to .m3u-playlist entries #15803

zzzealed opened this issue Feb 5, 2025 · 13 comments

Comments

@zzzealed
Copy link

zzzealed commented Feb 5, 2025

mpv Information

mpv v0.39.0-723-g38ad1ed0 Copyright © 2000-2025 mpv/MPlayer/mplayer2 projects
 built on Feb  2 2025 00:05:18
libplacebo version: v7.350.0 (v7.349.0-30-g056b852-dirty)
FFmpeg version: N-118390-g9b5a4c0ae
FFmpeg library versions:
   libavcodec      61.31.101
   libavdevice     61.4.100
   libavfilter     10.9.100
   libavformat     61.9.106
   libavutil       59.56.100
   libswresample   5.4.100
   libswscale      8.13.100

Other Information

- Windows version: Microsoft Windows [Version 10.0.26100.2894]
- GPU model, driver and version: Geforce RTX 2070, NVIDIA-driver v/566.36
- Source of mpv: https://github.com/shinchiro/mpv-winbuild-cmake
- Latest known working version: N/A
- Issue started after the following happened: N/A

Reproduction Steps

  1. Create test.m3u8-file containing links to videos like subdir/video.mp4
  2. Create mpv.conf-file in same directory, containing configuration like fullscreen=yes or save-position-on-quit=yes
  3. mpv --no-config --use-filedir-conf test.m3u8

Expected Behavior

Options from the mpv.conf-file next to the test.m3u8-file should be applied.

Actual Behavior

Options from the mpv.conf-file next to the test.m3u8-file are not applied.

Log File

output.txt

Sample Files

No response

I carefully read all instruction and confirm that I did the following:

  • I tested with the latest mpv version to validate that the issue is not already fixed.
  • I provided all required information including system and mpv version.
  • I produced the log file with the exact same set of files, parameters, and conditions used in "Reproduction Steps", with the addition of --log-file=output.txt.
  • I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • I attached the full, untruncated log file.
  • I attached the backtrace in the case of a crash.

Edit:

Also happens to local videofiles, I discovered. Even with profile-restore=copy in external mpv.conf

@zzzealed zzzealed added the os:win label Feb 5, 2025
@zzzealed zzzealed changed the title use-filedir-conf=yes-options doesn't apply to "http://"-videofiles use-filedir-conf=yes-options doesn't apply to .m3u-playlists containing "http://"-videofiles Feb 13, 2025
@zzzealed zzzealed changed the title use-filedir-conf=yes-options doesn't apply to .m3u-playlists containing "http://"-videofiles use-filedir-conf=yes-options doesn't apply to .m3u-playlist entries Feb 13, 2025
@Bellavene
Copy link

Bellavene commented Feb 17, 2025

For me it works with playlists also
mpv b8839b1

@kasper93
Copy link
Contributor

It works as documented. It uses a file specific config that is currently played, so in your case subdir/mpv.conf will be used.

For this, mpv first tries to load a mpv.conf from the same directory as the file played and then tries to load any file-specific configuration.

Playlists are not played or shown as current file in mpv. This is essentially a feature request to add --use-playlistdir-conf option or something similar.

@zzzealed
Copy link
Author

zzzealed commented Feb 17, 2025

It works as documented. It uses a file specific config that is currently played, so in your case subdir/mpv.conf will be used.

For this, mpv first tries to load a mpv.conf from the same directory as the file played and then tries to load any file-specific configuration.

Playlists are not played or shown as current file in mpv. This is essentially a feature request to add --use-playlistdir-conf option or something similar.

I see. Well in that case, yeah I think it would be great as a feature.
In general I'm a bit confused by the --use-filedir-conf behaviour. Why doesn't the params set carry over to the next file, if it's outside or in a subdir of the external mpv.conf. Guess that's just how it was designed? Maybe just adding a feature that would allow these params to be carried over could also be an option.

@zzzealed
Copy link
Author

For me it works with playlists also mpv b8839b1

Exactly what options did you leave in the external mpv.conf? Because for me, it sometimes works with the playlist-start=3-option. Other options don't work though.

@Bellavene
Copy link

Bellavene commented Feb 23, 2025

I just have copied the whole mpv.conf into my parent music folder, m3u files are stored there too. Just enabled the visualization. I believe there is no need for you of my whole mpv.conf, this part is for music:

[extension.mp3]
profile=music

[extension.m4a]
profile=music

[extension.flac]
profile=music

[extension.aiff]
profile=music

[music]
profile-desc="Music profile"
lavfi-complex=""
profile=scope
osd-msg1="${?media-title:${media-title}}${!media-title:No file.}"
osd-font-size=30
osd-scale-by-window=no
osd-align-x=right

[scope]
lavfi-complex='[aid1]asplit[ai][ao];[ai]showwaves=mode=cline:s=800x800:colors=red|random|random:r=25,split[wf][m];[vid1]scale=800x800,format=gbrp[vid];[m]alphaextract,negate,mergeplanes=0x0:format=gbrp[m];[vid][wf][m]maskedmerge[vo]'

After that, whenever I open m3u playlists stored in music folder they are playing with visualization.

@kasper93
Copy link
Contributor

After that, whenever I open m3u playlists stored in music folder they are playing with visualization.

Yes, because it loads the config from the media file location. Exactly as --use-filedir-conf is described. This issue is about the case when playlist (and config) is in different directory than the files.

@zzzealed
Copy link
Author

Yes like kasper93 described this works as intended. My feature-request attains to URLs and files in subdirectories.

@Bellavene
Copy link

Ah, sorry then.

@zzzealed
Copy link
Author

zzzealed commented Mar 8, 2025

For the time being, this is what me and DeepSeek came up with.

-- dynamic-include.lua
local utils = require 'mp.utils'

-- Store the initial input file path
local initial_input_path = nil

-- Function to normalize path separators (cross-platform)
local function normalize_path(path)
    return path:gsub("\\", "/")
end

-- Function to check if a file exists
local function file_exists(path)
    local file = io.open(path, "r")
    if file then
        file:close()
        return true
    end
    return false
end

-- Function to parse and apply configuration settings
local function apply_config_file(conf_path)
    local file = io.open(conf_path, "r")
    if not file then
        mp.msg.warn("Config file not found: " .. conf_path)
        return
    end

    mp.msg.info("Loading config file: " .. conf_path)
    for line in file:lines() do
        -- Skip comments and empty lines
        if not line:match("^%s*#") and not line:match("^%s*$") then
            -- Parse the line into a key and value
            local key, value = line:match("^([^=]+)=(.+)$")
            if key and value then
                key = key:gsub("%s+", "")  -- Remove whitespace
                value = value:gsub("%s+", "")  -- Remove whitespace
                -- Set the property or option
                local success, err = pcall(mp.set_property, key, value)
                if not success then
                    mp.msg.warn("Failed to set property: " .. key .. "=" .. value .. " (" .. err .. ")")
                else
                    mp.msg.info("Set property: " .. key .. "=" .. value)
                end
            else
                mp.msg.warn("Invalid line in config file: " .. line)
            end
        end
    end
    file:close()
end

-- Function to handle the initial input file
local function track_initial_input_path()
    -- Only process the first input file (playlist file)
    if initial_input_path then
        return
    end

    -- Get the path of the first input file
    local path = mp.get_property("path")
    if not path then
        mp.msg.warn("No file path available.")
        return
    end

    -- Normalize path separators
    initial_input_path = normalize_path(path)
    mp.msg.info("Initial input file path set to: " .. initial_input_path)

    -- Get the directory of the initial input file
    local dir = utils.split_path(initial_input_path)
    local conf_path = utils.join_path(dir, "mpv.conf")
    conf_path = normalize_path(conf_path)

    -- Check if the config file exists and apply it
    if file_exists(conf_path) then
        apply_config_file(conf_path)
    else
        mp.msg.warn("Config file not found: " .. conf_path)
    end
end

-- Register the event to run when a file starts loading
mp.register_event("start-file", track_initial_input_path)

I'm too tired to actually look this through, but it works. It applies any MPV option from a mpv.conf next to a foo.m3u8.

@guidocella
Copy link
Contributor

guidocella commented Mar 8, 2025

This also does it:

local utils = require 'mp.utils'
local first_entry = mp.get_property('playlist/0/filename')

if first_entry then
    local path = select(1, utils.split_path(first_entry)) .. 'mpv.conf'
    if utils.file_info(path) then
        mp.commandv('load-config-file', path)
    end
end

@kasper93
Copy link
Contributor

kasper93 commented Mar 8, 2025

local first_entry = mp.get_property('playlist/0/filename')

This should be playlist-path

@guidocella
Copy link
Contributor

playlist-path is not available on init. This applies the config file before the playlist is loaded.

@zzzealed
Copy link
Author

zzzealed commented Mar 9, 2025

DAMN @guidocella you're goated, good shit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants