mpv2oboeru

mpv helpers to create flashcards from movies and TV shows
git clone anongit@rnpnr.xyz:mpv2oboeru.git
Log | Files | Refs | Feed | README | LICENSE

Commit: cdb3f67c49983084db9b0f1d060384dc4ff5f80e
Parent: 7fc6480dd989a084bfb1e3564bbffcda8a7a899f
Author: Ren Tatsumoto
Date:   Mon, 16 Nov 2020 00:47:42 +0300

use opus and webp only if they're supported

see #11

Diffstat:
Msubs2srs.lua | 14++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/subs2srs.lua b/subs2srs.lua @@ -446,6 +446,16 @@ end local validate_config do + local function is_webp_supported() + local ret = subprocess { 'mpv', '--ovc=help' } + return ret.status == 0 and ret.stdout:match('--ovc=libwebp') + end + + local function is_opus_supported() + local ret = subprocess { 'mpv', '--oac=help' } + return ret.status == 0 and ret.stdout:match('--oac=libopus') + end + local function set_collection_path() if not is_dir(config.collection_path) then -- collection path wasn't specified. construct it using config.anki_user @@ -454,7 +464,7 @@ do end local function set_audio_format() - if config.audio_format == 'opus' then + if config.audio_format == 'opus' and is_opus_supported() then config.audio_codec = 'libopus' config.audio_extension = '.ogg' else @@ -464,7 +474,7 @@ do end local function set_video_format() - if config.snapshot_format == 'webp' then + if config.snapshot_format == 'webp' and is_webp_supported() then config.snapshot_extension = '.webp' config.snapshot_codec = 'libwebp' else