mpv-scripts icon indicating copy to clipboard operation
mpv-scripts copied to clipboard

encoding with lut3d cube filters encode.lua

Open mrfragger opened this issue 1 year ago • 0 comments

Not sure if this is possible at all or maybe I'm on the wrong path. ffmpeg -i input.mp4 -vf lut3d='/Users/username/.config/mpv/lut/abigailgonzalez/abigailgonzalez blade runner.cube' -c:v libx265 output.mp4

this will apply any lut3d cube file to the video.

If I use this script it'll show the filename of the path and filename of lut...call it showlut.lua

local function showlut()
	local showlut = mp.get_property_osd("lut")
	mp.osd_message(showlut, 20)
end

local function startObserving()
    mp.observe_property("lut", nil, showlut)
end

mp.add_key_binding('Ctrl+Alt+x', "lut", startObserving)

I added 500+ GMIC LUTs but I should've tested encoding before I did.

in mpv.conf

[abigailgonzalez blade runner]
lut='~/.config/mpv/lut/abigailgonzalez/abigailgonzalez blade runner.cube' 
[abigailgonzalez blue house]
lut='~/.config/mpv/lut/abigailgonzalez/abigailgonzalez blue house.cube' 
[abigailgonzalez blue ice]
lut='~/.config/mpv/lut/abigailgonzalez/abigailgonzalez blue ice.cube'

input.conf Ctrl+Alt+1 script-message cycle-profiles 'abigailgonzalez blade runner' 'abigailgonzalez blue house' 'abigailgonzalez blue ice' 'LUT none' #! [Video/Image] > [LUTs 1] > Abigail Gonzalez

in encode.lua under the function get_video_filters() section

    elseif name == "lut" then
        filter = "lut3d"


    elseif name == "lut" then
        local p = vf["params"]
        filter = string.format("lut3d=lut")


    elseif name == "lut" then
        filter = "lutrgb=g=0:b=0"

just seeing if it detects lut active then it'll do all red filter. None of these worked.

Just a sidenote: I do rotate with 4 degree increments and it encodes it properly with whatever angle is set. Not sure why transpose=clock, etc. is needed.

edit 1: ok adding to encode.conf does work ..now gotta figure out how to how to write the cube file to the conf on-the-fly somehow append_filter=lut3d=/Users/username/.config/mpv/lut/abigailgonzalez/abigailgonzalez monochrome 01.cube

using ~ doesn't work for ffmpeg append_filter=lut3d=~/.config/mpv/lut/abigailgonzalez/abigailgonzalez monochrome 01.cube

edit 2: ok found a solution but requires you to first find out whichever LUT you wanna encode with. Then copy that from the clipboard (using copystuff.lua) and paste it into the encode.conf (whichever one you intend to use) just appending append_filter=lut3d= restart mpv and encode away applying the LUT filter. and voila. Still wish there's a easier way for the average user though.

mrfragger avatar Oct 16 '24 18:10 mrfragger