Skip to content

Commit

Permalink
Merge pull request #3 from NicholasFlamy/patch-1
Browse files Browse the repository at this point in the history
Improve ASAD Audio Encoder with Bitrate Default/None
  • Loading branch information
yajrendrag authored Apr 18, 2024
2 parents 8067739 + 47ac10c commit 293502d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
14 changes: 14 additions & 0 deletions source/asad_audio_encoder/description.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,17 @@ For information on the available encoder settings:
- Select the customize box if you wish to add custom audio encoder options or specifiy a custom file suffix.
- Text Areas for custom audio options and custom suffix will appear if check box is checked otherwise these fields are hidden.

#### FFmpeg command

```
ffmpeg \
-hide_banner \
-loglevel info \
-i /path/to/input/audio.wav \
-max_muxing_queue_size 9999 -strict -2 \
-map 0:a:<stream number> -c:a:<stream number> <encoder> -ac <audio channels count> \
-b:a:<stream number> <bitrate> # This line omitted when bitrate Default/None \
-map 0:<cover art/video stream number> -c:<cover art/video stream number> copy \
<CUSTOM AUDIO OPTIONS HERE> \
/path/to/output/audio.<file suffix>
```
42 changes: 28 additions & 14 deletions source/asad_audio_encoder/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
plugins.__init__.py
Written by: yajrendrag <[email protected]>
Date: 17 April 2024, (09:00 Am)
Date: 17 April 2024, (09:00 AM)
Copyright:
Copyright (C) 2024 Jay Gardner
Expand Down Expand Up @@ -38,15 +38,15 @@
"libfdk_aac": "m4a",
"libmp3lame": "mp3",
"libopus": "ogg",
"vorbis": "ogg",
"libvorbis": "ogg",
"flac": "flac",
"alac": "m4a",
}

class Settings(PluginSettings):
settings = {
"encoder": "libfdk_aac",
"channel_rate": "64k",
"channel_rate": "0",
"customize": False,
"custom_audio": "",
"custom_suffix": "",
Expand All @@ -62,19 +62,19 @@ def __init__(self, *args, **kwargs):
"select_options": [
{
"value": "libmp3lame",
"label": "libmp3lame",
"label": "mp3",
},
{
"value": "libfdk_aac",
"label": "libfdk_aac",
},
{
"value": "libopus",
"label": "libopus",
"label": "opus",
},
{
"value": "vorbis",
"label": "libvorbis",
"value": "libvorbis",
"label": "vorbis",
},
{
"value": "flac",
Expand All @@ -92,26 +92,38 @@ def __init__(self, *args, **kwargs):
"description": "Select data rate for each channel:",
"input_type": "select",
"select_options": [
{
"value": "32k",
"label": "32k",
},
{
"value": "48k",
"label": "48k",
},
{
"value": "64k",
"label": "64k",
},
{
"value": "128k",
"label": "128k",
"value": "96k",
"label": "96k",
},
{
"value": "192k",
"label": "192k",
"value": "128k",
"label": "128k",
},
{
"value": "256k",
"label": "256k",
"value": "160k",
"label": "160k",
},
{
"value": "keep each stream's existing rate",
"label": "keep each stream's existing rate",
},
{
"value": "0",
"label": "Default/None",
},
]
},
"customize": {
Expand Down Expand Up @@ -257,7 +269,9 @@ def on_worker_process(data):
bit_rate = t[2]
if channel_rate != "keep each stream's existing rate":
bit_rate = str(parse_size(channel_rate) * int(channels))
stream_map += ['-map', '0:a:'+str(i), '-c:a:'+str(i), encoder, '-ac', str(channels), '-b:a:'+str(i), str(bit_rate)]
stream_map += ['-map', '0:a:'+str(i), '-c:a:'+str(i), encoder, '-ac', str(channels)]
if channel_rate != "0":
stream_map += ['-b:a:'+str(i), str(bit_rate)]
all_streams.remove(absolute_stream)

for i in range(len(all_streams)):
Expand Down

0 comments on commit 293502d

Please sign in to comment.