diff --git a/.github/RELEASE/subs2srs.conf b/.github/RELEASE/subs2srs.conf index ad37695..da3d305 100644 --- a/.github/RELEASE/subs2srs.conf +++ b/.github/RELEASE/subs2srs.conf @@ -199,9 +199,12 @@ animated_snapshot_quality=5 ## # Audio format. -# Do not switch to `mp3` unless your computer doesn't support `opus`. +# Opus is the recommended format. +# It may be required to use a different format when Opus is not supported. +# This is the case on certain computers or devices which are running proprietary operating systems. audio_format=opus #audio_format=mp3 +#audio_format=caf # Sane values are 16k-32k for opus, 64k-128k for mp3. audio_bitrate=24k diff --git a/README.md b/README.md index be856e5..fd6371f 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,13 @@ set `audio_format` to `mp3` and/or `snapshot_format` to `jpg`. Otherwise, I recommend sticking with `opus` and `webp`, as they greatly reduce the size of the generated files. +If you still use AnkiMobile (the [proprietary](https://www.gnu.org/proprietary/) Anki app), +set `audio_format` to [caf](https://en.wikipedia.org/wiki/Core_Audio_Format) for compatibility. +The resulting files will use `Opus` as the coding format and Apple's Core Audio +format as the container format, but will still have the `.ogg` extension to make +it easier to open in media players because the `.caf` extension is not commonly +recognized. + If no matter what mpvacious fails to create audio clips and/or snapshots, change `use_ffmpeg` to `yes`. By using ffmpeg instead of the encoder built in mpv you can work around most encoder issues. diff --git a/cfg_mgr.lua b/cfg_mgr.lua index 0cf05c8..2da488b 100644 --- a/cfg_mgr.lua +++ b/cfg_mgr.lua @@ -22,7 +22,9 @@ local default_profile_filename = 'subs2srs' local profiles_filename = 'subs2srs_profiles' local function set_audio_format() - if self.config.audio_format == 'opus' then + if self.config.audio_format == 'opus' or self.config.audio_format == 'caf' then + -- https://opus-codec.org/ + -- https://en.wikipedia.org/wiki/Core_Audio_Format self.config.audio_codec = 'libopus' self.config.audio_extension = '.ogg' else diff --git a/encoder.lua b/encoder.lua index 7f200c4..59759a3 100644 --- a/encoder.lua +++ b/encoder.lua @@ -164,6 +164,7 @@ ffmpeg.make_audio_args = function(source_path, output_path, start_timestamp, end '-map', string.format("0:%s", tostring(audio_track_id)), '-ac', '1', '-codec:a', self.config.audio_codec, + '-f', self.config.audio_format, '-vbr', 'on', '-compression_level', '10', '-application', 'voip', @@ -244,6 +245,7 @@ mpv.make_audio_args = function(source_path, output_path, start_timestamp, end_ti '--oacopts-add=application=voip', '--oacopts-add=compression_level=10', table.concat { '--oac=', self.config.audio_codec }, + table.concat { '--of=', self.config.audio_format }, table.concat { '--start=', toms(start_timestamp), }, table.concat { '--end=', toms(end_timestamp), }, table.concat { '--aid=', audio_track_id }, diff --git a/utils/forvo.lua b/utils/forvo.lua index 391f757..09bc596 100644 --- a/utils/forvo.lua +++ b/utils/forvo.lua @@ -42,6 +42,7 @@ local function reencode(source_path, dest_path) '--oacopts-add=compression_level=10', '--af-append=silenceremove=1:0:-50dB', table.concat { '--oac=', self.config.audio_codec }, + table.concat { '--of=', self.config.audio_format }, table.concat { '--oacopts-add=b=', self.config.audio_bitrate }, table.concat { '-o=', dest_path } }