summaryrefslogtreecommitdiff
path: root/config/mpv/scripts/subs2srs/encoder/codec_support.lua
blob: 26cd91ae2d467e2268051cdb62acc44a868c5cc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
--[[
Copyright: Ajatt-Tools and contributors
License: GNU GPL, version 3 or later; http://www.gnu.org/licenses/gpl.html

Check what codecs are supported by mpv.
If a desired codec is not supported, set the "use_ffmpeg" config option to "yes".
]]

local mp = require('mp')
local h = require('helpers')

local ovc_help = h.subprocess { 'mpv', '--ovc=help' }
local oac_help = h.subprocess { 'mpv', '--oac=help' }

local function is_audio_supported(codec)
    return oac_help.status == 0 and oac_help.stdout:find('--oac=' .. codec, 1, true) ~= nil
end

local function is_image_supported(codec)
    return ovc_help.status == 0 and ovc_help.stdout:find('--ovc=' .. codec, 1, true) ~= nil
end

local inspection_result = {
    snapshot = {
        ['libaom-av1'] = is_image_supported('libaom-av1'),
        libwebp = is_image_supported('libwebp'),
        mjpeg = is_image_supported('mjpeg'),
    },
    audio = {
        libmp3lame = is_audio_supported('libmp3lame'),
        libopus = is_audio_supported('libopus'),
    },
}
for type, codecs in pairs(inspection_result) do
    for codec, supported in pairs(codecs) do
        mp.msg.info(string.format("mpv supports %s codec %s: %s", type, codec, tostring(supported)))
    end
end

return inspection_result