Mpv: Place screenshots on a folder with the video title

Created on 19 Jun 2017  路  8Comments  路  Source: mpv-player/mpv

Would this be possible? Something like

screenshot-directory="C:/Users/George/Video Screenshots/$video_name$/"

Most helpful comment

Try this

local utils = require("mp.utils")
local basedir = mp.get_property("options/screenshot-directory")
mp.register_event("file-loaded", function()
    local filedir = mp.get_property("filename/no-ext")
    local dir = utils.join_path(basedir, filedir)
    mp.set_property("options/screenshot-directory", dir)
end)

All 8 comments

The directory can be part of the screenshot-template option.

How would I do that? I tried screenshot-template=%F/"%F %P" but no dice.

Just to be clear, the result I want is:

Taking a screenshot for "Star Wars.mkv" = "C:/Users/George/Video Screenshots/Star Wars/Star Wars 00_01_54.989.jpeg"

Taking a screenshot for "Manchester by the Sea.mkv" = "C:/Users/George/Video Screenshots/Manchester by the Sea/Manchester by the Sea 00_01_54.989.jpeg"

It has to do with the fact the directory does not exists and mpv won't try to create it.

Yeah, that's what I'm asking - if there is a way it can create it like that for each file, but I guess not, so all I can do is request it.

You can do it with a Lua script, such as

mp.register_event("file-loaded", function()
    local dirname = mp.get_property("filename/no-ext")
    mp.set_property("options/screenshot-directory", dirname)
end)

This will make sure that the screenshot-directory option is always set to the name of the current file (without the extension).

Nice!!! Thanks!! Any chance it could create the folder on the path specified on screenshot-directory? Right now it's making it on the same folder as the video. I tried, but I don't know .lua nor much coding so it didn't work.

Try this

local utils = require("mp.utils")
local basedir = mp.get_property("options/screenshot-directory")
mp.register_event("file-loaded", function()
    local filedir = mp.get_property("filename/no-ext")
    local dir = utils.join_path(basedir, filedir)
    mp.set_property("options/screenshot-directory", dir)
end)

Certified hacker stuff right here, thanks so much!!

Was this page helpful?
0 / 5 - 0 ratings