You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will use the defaults to create a 320Kbps MP3 file.
72
74
73
-
*For any other setting, you **must** use one of the supported methods to pass arguments to the script. See the [Syntax](./README.md#syntax) section below.*
75
+
*For any other setting, you **must** use one of the supported methods to pass arguments to the script. See the [Command-Line Syntax](./README.md#command-line-syntax) section below.*
74
76
75
-
## Usage
76
-
New file(s) will be placed in the same directory as the original FLAC file(s) (unless redirected with the `--output` option below) and have the same owner and permissions. Existing files with the same track name will be overwritten.
77
+
# Usage
78
+
New file(s) will be placed in the same directory as the original FLAC file(s) (unless redirected with the `--output` option below) with permissions preserved. Existing files with the same track name will be overwritten. Owner is preserved if the script is executed as root.
77
79
78
80
By default, if you've configured Lidarr's **Recycle Bin** path correctly, the original audio file will be moved there.
79
81
![danger] **NOTE:** If you have *not* configured the Recycle Bin, the original FLAC audio file(s) will be deleted and permanently lost. This behavior may be modified with the `--keep-file` option.
80
82
81
-
### Syntax
82
-
>**Note:** The _Arguments_ field for Custom Scripts was removed in Lidarr release [v0.7.0.1347](https://github.com/lidarr/Lidarr/commit/b9d240924f8965ebb2c5e307e36b810ae076101e "Lidarr commit notes") due to security concerns.
83
-
84
-
To supply arguments to the script, you **must** either use one of the **[included wrapper scripts](./README.md#included-wrapper-scripts)**, create a **[custom wrapper script](./README.md#example-wrapper-script)**, or set the `FLAC2MP3_ARGS` **[environment variable](./README.md#environment-variable)**.
83
+
## Command-Line Syntax
84
+
>**Note:** The *Arguments* field for Custom Scripts was removed in Lidarr release [v0.7.0.1347](https://github.com/lidarr/Lidarr/commit/b9d240924f8965ebb2c5e307e36b810ae076101e "Lidarr commit notes") due to security concerns.
85
85
86
-
#### Command Line Options and Arguments
87
-
The script may be called with optional commandline arguments.
86
+
### Options and Arguments
87
+
The script may be called with optional command-line arguments.
-b, --bitrate|\<bitrate\>|Sets the output quality in constant bits per second (CBR).<br/>Examples: 160k, 240k, 300000<br/>**Note:** May not be specified with `-v`, `-a`, or `-e`.
97
97
-v, --quality|\<quality\>|Sets the output variable bit rate (VBR).<br/>Specify a value between 0 and 9, with 0 being the highest quality.<br/>See the [FFmpeg MP3 Encoding Guide](https://trac.ffmpeg.org/wiki/Encode/MP3) for more details.<br/>**Note:** May not be specified with `-b`, `-a`, or `-e`.
98
-
-a, --advanced|\"\<options\>\"|Advanced ffmpeg options.<br/>The specified `options` replace all script defaults and are sent directly to ffmpeg.<br/>The `options` value must be enclosed in quotes.<br/>See [FFmpeg Options](https://ffmpeg.org/ffmpeg.html#Options) for details on valid options, and [Guidelines for high quality audio encoding](https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio) for suggested usage.<br/>**Note:** Requires the `-e` option to also be specified. May not be specified with `-v` or `-b`.<br/>![warning] **WARNING:** You must specify an audio codec (by including a `-c:a <codec>` ffmpeg option) or the resulting file will contain no audio!<br/>![warning] **WARNING:** Invalid `options` could result in script failure!
98
+
-a, --advanced<!-- markdownlint-disable-line MD013 -->|\"\<options\>\"|Advanced ffmpeg options.<br/>The specified `options` replace all script defaults and are sent directly to ffmpeg.<br/>The `options` value must be enclosed in quotes.<br/>See [FFmpeg Options](https://ffmpeg.org/ffmpeg.html#Options) for details on valid options, and [Guidelines for high quality audio encoding](https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio) for suggested usage.<br/>**Note:** Requires the `-e` option to also be specified. May not be specified with `-v` or `-b`.<br/>![warning] **WARNING:** You must specify an audio codec (by including a `-c:a <codec>` ffmpeg option) or the resulting file will contain no audio!<br/>![warning] **WARNING:** Invalid `options` could result in script failure!
99
99
-e, --extension|\<extension\>|Sets the output file extension.<br/>The extension may be prefixed by a dot (".") or not.<br/>Example: .ogg<br/>**Note:** Requires the `-a` option to also be specified. May not be specified with `-v` or `-b`.
100
100
-f, --file|<audio_file>|If included, the script enters **[Batch Mode](./README.md#batch-mode)** and converts the specified audio file.<br/>![warning] **WARNING:** Do not use this argument when called from Lidarr!
101
101
-o, --output|\<directory\>|Converted audio file(s) are saved to `directory` instead of being located in the same directory as the source audio file.<br/>The path will be created if it does not exist.
@@ -110,29 +110,36 @@ Option|Argument|Description
110
110
If neither `-b`, `-v`, `-a`, or `-e` options are specified, the script will default to a constant 320Kbps MP3.
111
111
112
112
#### Technical notes on advanced options
113
-
The `-a` option effectively makes the script a generic wrapper for ffmpeg. FFmpeg is executed once per track with only the loglevel, input filename, and output filename being set. All other options are passed unparsed to the commandline.
113
+
The `-a` option effectively makes the script a generic wrapper for ffmpeg. FFmpeg is executed once per track with only the loglevel, input filename, and output filename being set. All other options are passed unparsed to the command-line.
114
114
115
115
The exact format of the executed ffmpeg command is:
By default, the script only matches and interacts with FLAC files (specifically, files ending in ".flac"). The `-r` option allows the script to match on a user specified regular expression (i.e. "regex") pattern.
121
+
#### Technical notes on regular expressions
122
+
<!-- textlint-disable terminology -->
122
123
123
-
Files are passed to the script with the full Linux path intact. (Ex: `/path/to/audio/a-ha/Hunting High and Low/01 Take on Me.mp3`). Craft your regex with this in mind.
124
+
By default, the script only matches and interacts with FLAC files (specifically, files ending in ".flac"). The `-r` option allows the script to match on a user specified regular expression (i.e. "regex") pattern.
124
125
125
-
![warning] **NOTE:** Escaping special regex characters (like a dot `.`) requires a double backslash or a character class. A character class (i.e. `[.]`) is recommended because backslashes can be stripped by the bash shell and getting this right can be confusing.
126
+
<!-- textlint-enable -->
127
+
128
+
Files are passed to the script with the full Linux path intact. (Ex: `/path/to/audio/a-ha/Hunting High and Low/01 Take on Me.mp3`). Craft your regular expression with this in mind.
129
+
130
+
![warning] **NOTE:** Escaping special regular expression characters (like a dot `.`) requires a double backslash or a character class. A character class (i.e. `[.]`) is recommended because backslashes can be stripped by the bash shell and getting this right can be confusing.
126
131
127
132
For example, to convert all audio files to AAC audio files, use the following options:
Regular expression syntax is beyond the scope of this document. See this [tutorial](https://www.regular-expressions.info/tutorial.html "Regular Expressions Tutorial") for more information. Regex patterns may be tested [here](http://regexstorm.net/tester "regex tester").
138
+
Regular expression syntax is beyond the scope of this document. See this [tutorial](https://www.regular-expressions.info/tutorial.html "Regular Expressions Tutorial") for more information. Regular expression patterns may be tested [here](http://regexstorm.net/tester "regex tester").
133
139
134
-
### Examples
135
-
```
140
+
## Examples
141
+
142
+
```shell
136
143
-b 320k # Output 320 kbit/s MP3 (non-VBR; same as default behavior)
-d -b 160k # Enable debugging level 1, and output a 160 kbit/s MP3
@@ -150,26 +157,32 @@ Regular expression syntax is beyond the scope of this document. See this [tutor
150
157
# Place the converted file(s) in the specified directory and do not delete the original audio file(s)
151
158
```
152
159
153
-
#### Included Wrapper Scripts
160
+
## Wrapper Scripts
161
+
To supply arguments to the script, you must either use one of the included wrapper scripts, create a custom wrapper script, or set the `FLAC2MP3_ARGS` [environment variable](./README.md#environment-variable).
162
+
163
+
### Included Wrapper Scripts
154
164
For your convenience, several wrapper scripts are included in the `/usr/local/bin/` directory.
155
165
You may use any of these scripts in place of the `flac2mp3.sh` mentioned in the [Installation](./README.md#installation) section above.
156
166
157
-
```
167
+
```shell
158
168
flac2mp3-debug.sh # Enable debugging, level 1
159
169
flac2mp3-debug-2.sh # Enable debugging, level 2
160
170
flac2mp3-vbr.sh # Use variable bit rate MP3, quality 0
161
171
flac2opus.sh # Convert to Opus format using .opus extension, 192 kbit/s, no covert art
162
172
flac2alac.sh # Convert to Apple Lossless using an .m4a extension
163
173
```
164
174
165
-
#### Example Wrapper Script
175
+
### Example Wrapper Script
166
176
To configure an entry from the [Examples](./README.md#examples) section above, create and save a file called `flac2mp3-custom.sh` to `/config` containing the following text:
177
+
167
178
```shell
168
179
#!/bin/bash
169
180
170
181
. /usr/local/bin/flac2mp3.sh -d -b 160k
171
182
```
183
+
172
184
Make it executable:
185
+
173
186
```shell
174
187
chmod +x /config/flac2mp3-custom.sh
175
188
```
@@ -178,16 +191,18 @@ Then put `/config/flac2mp3-custom.sh` in the **Path** field in place of `/usr/lo
178
191
179
192
>**Note:** If you followed the Linuxserver.io recommendations when configuring your container, the `/config` directory will be mapped to an external storage location. It is therefore recommended to place custom scripts in the `/config` directory so they will survive container updates, but they may be placed anywhere that is accessible by Lidarr.
180
193
181
-
###Environment Variable
194
+
## Environment Variable
182
195
The `flac2mp3.sh` script also allows the use of arguments provided by the `FLAC2MP3_ARGS` environment variable. This allows advanced use cases without having to provide a custom script.
183
196
184
197
For example, the following value in your `docker run` command would convert any .mp3 to Opus:
Make sure to correctly use quotes and/or escape special characters when using this method. (See [regex notes](./README.md#technical-notes-on-regex) above.)
203
+
Make sure to correctly use quotes and/or escape special characters when using this method. (See [regular expression notes](./README.md#technical-notes-on-regular-expressions) above.)
190
204
In Docker Compose, the previous command would need an extra `$` to match the end-of-line:
>**NOTE:** The environment variable settings are _only_ used when **no** commandline arguments are present. **Any** commandline argument will disable the use of the environment variable.
214
+
>**NOTE:** The environment variable settings are *only* used when **no** command-line arguments are present. **Any** command-line argument will disable the use of the environment variable.
200
215
201
-
### Triggers
216
+
## Triggers
202
217
The only events/notification triggers that are supported are **On Release Import** and **On Upgrade**
203
218
204
-
### Batch Mode
205
-
Batch mode allows the script to be executed independently of Lidarr. It converts the file specified on the commandline and ignores any environment variables that are normally expected to be set by the music management program.
219
+
## Batch Mode
220
+
Batch mode allows the script to be executed independently of Lidarr. It converts the file specified on the command-line and ignores any environment variables that are normally expected to be set by the music management program.
206
221
207
222
Using this function, you can easily process all of your audio files in any subdirectory at once. See the [Batch Example](./README.md#batch-example) below.
208
223
209
-
#### Script Execution Differences in Batch Mode
224
+
### Script Execution Differences in Batch Mode
210
225
Because the script is not called from within Lidarr, expect the following behavior while in Batch Mode:
211
-
* *The filename must be specified on the commandline*<br/>(The `-f` option places the script in Batch Mode)
226
+
* *The filename must be specified on the command-line*<br/>(The `-f` option places the script in Batch Mode)
212
227
* *Lidarr APIs are not called and its database is not updated.*<br/>This may require a manual import of converted music files or an artist rescan.
213
228
* *Original audio files are deleted.*<br/>The Recycle Bin function is not available. (Modifiable using the `-k` option.)
214
229
215
-
#### Batch Example
216
-
To convert all .FLAC files in the `/music` directory to Apple Lossless Audio Codec (ALAC), enter the following at the Linux command line:
230
+
### Batch Example
231
+
To convert all .FLAC files in the `/music` directory to Apple Lossless Audio Codec (ALAC), enter the following at the Linux command-line:
232
+
217
233
```shell
218
234
find /music/ -type f -name "*.flac" | while read file; do /usr/local/bin/flac2mp3.sh -f "$file" -a "-c:a alac" -e m4a; done
219
235
```
220
236
221
-
### Logs
222
-
By default, a log file is created for the script activity called:
223
-
224
-
`/config/logs/flac2mp3.txt`
225
-
226
-
This log can be downloaded from Lidarr under *System* > *Log Files*. The log filename can be modified with the `--log` command-line option.
227
-
228
-
Log rotation is performed, with 5 log files of 1MB each kept, matching Lidarr's log retention.
229
-
>![danger] **NOTE:** If debug logging is enabled with a level above 1, the log file can grow very large very quickly and is much more likely to be rotated. *Do not leave high-level debug logging enabled permanently.*
230
-
231
-
#### Metadata Corrections
232
-
This feature is not meant for general purpose use. It is only documented here for completeness.
237
+
## Metadata Corrections
238
+
**This feature is not meant for general purpose use.** It is only documented here for completeness.
233
239
234
240
List of supported tags and metadata corrections that are applied:
235
241
@@ -244,6 +250,16 @@ List of supported tags and metadata corrections that are applied:
244
250
| |/Punk\|Alternative/|"Alternative & Punk"
245
251
| |/Rock/|"Rock"
246
252
253
+
## Logs
254
+
By default, a log file is created for the script activity called:
255
+
256
+
`/config/logs/flac2mp3.txt`
257
+
258
+
This log can be downloaded from Lidarr under *System* > *Log Files*. The log filename can be modified with the `--log` command-line option.
259
+
260
+
Log rotation is performed, with 5 log files of 1MB each kept, matching Lidarr's log retention.
261
+
>![danger] **NOTE:** If debug logging is enabled with a level above 1, the log file can grow very large very quickly and is much more likely to be rotated. *Do not leave high-level debug logging enabled permanently.*
262
+
247
263
# Uninstall
248
264
To completely remove the mod:
249
265
1. Delete the custom script from Lidarr's *Settings* > *Connect* screen that you created in the [Installation](./README.md#installation) section above.
0 commit comments