Skip to content

Commit

Permalink
Fix issues with the plugin:
Browse files Browse the repository at this point in the history
- Improve audio bitrate calculator to default to x2 channels when calculating if the stream does not define the number of channels
- Fix bug where "Write your own FFmpeg params" options were not being applied correctly to the FFmpeg command
- Remove support for v1 plugin executor
  • Loading branch information
Josh5 committed Sep 3, 2022
1 parent 71cc2cc commit ecd8785
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 21 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

**<span style="color:#56adda">0.0.5</span>**
- Update FFmpeg helper
- Remove support for v1 plugin executor
- Improve audio bitrate calculator to default to x2 channels when calculating if the stream does not define the number of channels
- Fix bug where "Write your own FFmpeg params" options were not being applied correctly to the FFmpeg command

**<span style="color:#56adda">0.0.4</span>**
- Update FFmpeg helper
- Add platform declaration
Expand Down
3 changes: 1 addition & 2 deletions info.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"author": "Josh.5",
"compatibility": [
1,
2
],
"description": "Ensure all audio streams are encoded with the AAC codec using the native FFmpeg aac encoder.",
Expand All @@ -16,5 +15,5 @@
"on_worker_process": 0
},
"tags": "audio,encoder,ffmpeg,library file test",
"version": "0.0.4"
"version": "0.0.5"
}
2 changes: 1 addition & 1 deletion lib/ffmpeg
Submodule ffmpeg updated 2 files
+41 −4 probe.py
+46 −20 stream_mapper.py
51 changes: 33 additions & 18 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,40 @@ def __init__(self):
self.codec = 'aac'
self.encoder = 'aac'

def set_settings(self, settings):
def set_default_values(self, settings, abspath, probe):
"""
Configure the stream mapper with defaults
:param settings:
:param abspath:
:param probe:
:return:
"""
self.abspath = abspath
# Set the file probe data
self.set_probe(probe)
# Set the input file
self.set_input_file(abspath)
# Configure settings
self.settings = settings

# Build default options of advanced mode
if self.settings.get_setting('advanced'):
# If any main options are provided, overwrite them
main_options = settings.get_setting('main_options').split()
if main_options:
# Overwrite all main options
self.main_options = main_options
# If any advanced options are provided, overwrite them
advanced_options = settings.get_setting('advanced_options').split()
if advanced_options:
# Overwrite all advanced options
self.advanced_options = advanced_options

@staticmethod
def calculate_bitrate(stream_info: dict):
channels = stream_info.get('channels')
# If no channel count is provided, assume the highest bitrate for 6 channels
if not channels:
logger.debug("Stream did not contain 'channels'. Setting max AC3 bit rate (640k).")
return 384

return (int(stream_info.get('channels')) * 64)
channels = stream_info.get('channels', 2)
return int(channels) * 64

def test_stream_needs_processing(self, stream_info: dict):
# Ignore streams already of the required codec_name
Expand Down Expand Up @@ -169,8 +191,7 @@ def on_library_management_file_test(data):

# Get stream mapper
mapper = PluginStreamMapper()
mapper.set_settings(settings)
mapper.set_probe(probe)
mapper.set_default_values(settings, abspath, probe)

if mapper.streams_need_processing():
# Mark this file to be added to the pending tasks
Expand Down Expand Up @@ -212,15 +233,11 @@ def on_worker_process(data):
return data

# Configure settings object (maintain compatibility with v1 plugins)
if data.get('library_id'):
settings = Settings(library_id=data.get('library_id'))
else:
settings = Settings()
settings = Settings(library_id=data.get('library_id'))

# Get stream mapper
mapper = PluginStreamMapper()
mapper.set_settings(settings)
mapper.set_probe(probe)
mapper.set_default_values(settings, abspath, probe)

if mapper.streams_need_processing():
# Set the input file
Expand All @@ -240,5 +257,3 @@ def on_worker_process(data):
parser = Parser(logger)
parser.set_probe(probe)
data['command_progress_parser'] = parser.parse_progress

return data

0 comments on commit ecd8785

Please sign in to comment.