Commit: c5739bcf8e96995f0e8d55d1deab98644e90068b
Parent: 75d78aa3940105aa1dd1b66c778c69b059d20fdf
Author: Ren Tatsumoto
Date: Tue, 30 Nov 2021 10:27:47 +0300
support custom encoding arguments
mentioned in #37.
Diffstat:
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/.github/RELEASE/subs2srs.conf b/.github/RELEASE/subs2srs.conf
@@ -137,3 +137,12 @@ miscinfo_field=Notes
# It supports the same substitutions as note_tag. HTML is supported.
miscinfo_format=%n EP%d (%t)
#miscinfo_format=From <b>mpvacious</b> %n at %t.
+
+#######################################
+# Custom encoding arguments #
+#######################################
+
+# By default, set to remove silence from audio clips.
+
+ffmpeg_audio_args=-af silenceremove=1:0:-50dB
+mpv_audio_args=--af-append=silenceremove=1:0:-50dB
diff --git a/encoder.lua b/encoder.lua
@@ -87,7 +87,6 @@ ffmpeg.make_audio_args = function(source_path, output_path, start_timestamp, end
'-application', 'voip',
'-b:a', tostring(_config.audio_bitrate),
'-filter:a', string.format("volume=%.1f", _config.tie_volumes and mp.get_property_native('volume') / 100 or 1),
- '-af', 'silenceremove=1:0:-50dB',
output_path
}
end
@@ -136,7 +135,6 @@ mpv.make_audio_args = function(source_path, output_path, start_timestamp, end_ti
'--oacopts-add=vbr=on',
'--oacopts-add=application=voip',
'--oacopts-add=compression_level=10',
- '--af-append=silenceremove=1:0:-50dB',
table.concat { '--oac=', _config.audio_codec },
table.concat { '--start=', start_timestamp },
table.concat { '--end=', end_timestamp },
@@ -170,6 +168,10 @@ local create_audio = function(start_timestamp, end_timestamp, filename, padding)
end
local args = encoder.make_audio_args(source_path, output_path, start_timestamp, end_timestamp)
+ for arg in string.gmatch(_config.use_ffmpeg and _config.ffmpeg_audio_args or _config.mpv_audio_args, "%S+") do
+ -- Prepend before output path
+ table.insert(args, #args, arg)
+ end
local on_finish = function()
_store_fn(filename, output_path)
os.remove(output_path)
diff --git a/subs2srs.lua b/subs2srs.lua
@@ -51,6 +51,10 @@ local config = {
tie_volumes = false, -- if set to true, the volume of the outputted audio file depends on the volume of the player at the time of export
menu_font_size = 25,
+ -- Custom encoding args
+ ffmpeg_audio_args = '-af silenceremove=1:0:-50dB',
+ mpv_audio_args = '--af-append=silenceremove=1:0:-50dB',
+
-- Anki
create_deck = false, -- automatically create a deck for new cards
deck_name = "Learning", -- name of the deck for new cards