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

[Encode] Wrong stream clip format

Open dardo82 opened this issue 5 years ago • 4 comments

When trying to clip a stream the output format is set by the file extension but not existing it always defaults to mkv.

dardo82 avatar Sep 17 '20 11:09 dardo82

You're talking about $x, right? It does indeed default to mkv if it cannot recognize the input format, should this be configurable?

occivink avatar Sep 17 '20 11:09 occivink

Should be the same as the stream format; i've modified the code:

function get_extension(path)
    local is_stream = not file_exists(path)
    local format = mp.get_property("file-format")
    local candidate = string.match(path, "%.([^.]+)$")
    if candidate then
        for _, ext in ipairs({ "mkv", "webm", "mp4", "avi" }) do
            if candidate == ext then
                return candidate
            else
                if is_stream then
                    if format == "mov,mp4,m4a,3gp,3g2,mj2" then
                        return "mp4"
                    end
                end
            end
        end
    end
    return "mkv"
end

dardo82 avatar Sep 17 '20 14:09 dardo82

mh yeah thinking about it we probably should just use the real format instead of trying to parse it from a filename.

occivink avatar Sep 17 '20 15:09 occivink

Right,the fix worked for me but it isn't general...

dardo82 avatar Sep 18 '20 03:09 dardo82