Skip to content

Commit

Permalink
Merge pull request #437 from Unmanic/pr-encoder_audio_ac3
Browse files Browse the repository at this point in the history
[encoder_audio_ac3] v0.0.8
  • Loading branch information
Josh5 authored Jan 30, 2025
2 parents dff8a57 + 10df1cd commit 65471cc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions source/encoder_audio_ac3/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

**<span style="color:#56adda">0.0.8</span>**
- add check in calculate_bitrate and custom_stream_mapping to set channels to 6 if channels > 6. ffmpeg cannot encode > 6 channels of ac3 audio.

**<span style="color:#56adda">0.0.7</span>**
- fix stray character in custom stream mapping function

Expand Down
2 changes: 1 addition & 1 deletion source/encoder_audio_ac3/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"on_worker_process": 0
},
"tags": "audio,encoder,ffmpeg,library file test",
"version": "0.0.7"
"version": "0.0.8"
}
5 changes: 5 additions & 0 deletions source/encoder_audio_ac3/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ def calculate_bitrate(stream_info: dict):
logger.debug("Stream did not contain 'channels'. Setting max AC3 bit rate (640k).")
return '640'

if int(channels) > 6:
channels = 6

# Determine bitrate based on source channel count
if int(channels) <= 2:
logger.debug("Stream 'channels' is <= 2. Setting AC3 bit rate to 448k.")
Expand Down Expand Up @@ -171,6 +174,8 @@ def custom_stream_mapping(self, stream_info: dict, stream_id: int):
# Use 64K for the bitrate per channel
calculated_bitrate = self.calculate_bitrate(stream_info)
channels = int(stream_info.get('channels'))
if int(channels) > 6:
channels = 6
stream_encoding += [
'-ac:a:{}'.format(stream_id), '{}'.format(channels), '-b:a:{}'.format(stream_id), "{}k".format(calculated_bitrate)
]
Expand Down

0 comments on commit 65471cc

Please sign in to comment.