parent
1bb2b97760
commit
13dd38ed56
46
README.md
46
README.md
|
@ -32,22 +32,58 @@ The *time-file* must have this format:
|
|||
|
||||
# Environment variables
|
||||
|
||||
The behavior of the script can be changed by several environment variables.
|
||||
|
||||
* **SIMULATION** [empty or not]\
|
||||
do not invoke ffmpeg
|
||||
* **NONUMBER** [empty or 1]\
|
||||
do not write song numbers
|
||||
|
||||
* **FORMAT** [mp3,ogg,opus,…]\
|
||||
see the ffmpeg documentation for the output formats available
|
||||
* **SEPARATOR** [separator] (default: ' - ')\
|
||||
* **FFOPTS** [any ffmpeg options] *(default: '-c:a copy')*\
|
||||
ffmpeg options, can be used to change audio quality\
|
||||
can be **required** to change in case input and output file formats differ\
|
||||
see the ffmpeg documentation for available parameters
|
||||
|
||||
* **NONUMBER** [empty or 1]\
|
||||
do not write song numbers
|
||||
* **SEPARATOR** [separator] *(default: ' - ')*\
|
||||
separator between number and name\
|
||||
example with SEPARATOR='_': 01_intro.opus 02_blah.opus…
|
||||
|
||||
* **HEADERS** [empty or 1]\
|
||||
print environment parameters (verbosity, simulation, etc.)
|
||||
* **VERBOSITY** [0-3] (default: 1)\
|
||||
* **VERBOSITY** [0-3] *(default: 1)*\
|
||||
0: no output except errors from ffmpeg\
|
||||
1: simple indications on the current track being extracted\
|
||||
2: print actual ffmpeg commands the script currently runs
|
||||
|
||||
# Different input and output file formats
|
||||
|
||||
In case you want to change the file format, let's say from `flac` to `opus`, you need to override the default ffmpeg options provided by `get-tracks.sh`.
|
||||
This is done through the `FFOPTS` environment variable, **which needs to NOT be empty** in order to replace the default `get-tracks.sh` behavior (which is `-c:a copy`).
|
||||
By default, `ffmpeg` performs re-encoding by itself.
|
||||
|
||||
```Bash
|
||||
FORMAT=opus FFOPTS=" " get-tracks.sh cd.flac cd.txt
|
||||
```
|
||||
|
||||
### Warning: sometimes you don't even need to
|
||||
|
||||
You may encounter files in some format like `webm` and you want to convert the output files in `opus`.
|
||||
But, inside the `webm` format, you **may** have `opus`-encoded audio.
|
||||
In these cases, no re-encoding is necessary, and you can do something like:
|
||||
|
||||
```Bash
|
||||
FORMAT=opus get-tracks.sh cd.webm cd.txt
|
||||
```
|
||||
|
||||
You'll have a warning mentionning FFOPTS (based on different formats).
|
||||
But the generated audio files won't have any quality loss.
|
||||
This happens sometimes with the `youtube-dl` utility.
|
||||
|
||||
In case there are actual `ffmpeg` errors, and you don't have output audio files, then the contained audio hadn't the right format.
|
||||
You'll have to re-encode.
|
||||
|
||||
# More
|
||||
|
||||
Run `get-track.sh` without arguments.
|
||||
You can get some help by running `get-track.sh` without arguments.
|
||||
|
|
|
@ -146,7 +146,7 @@ run_ffmpeg(){
|
|||
echo "extracting '$final_title'"
|
||||
;;
|
||||
v2)
|
||||
echo "ffmpeg $LOG_LEVEL $FROM $TO -i $INPUT_FILE '$OUTPUT_FILE'"
|
||||
echo "ffmpeg $LOG_LEVEL $FROM $TO -i $INPUT_FILE $FFOPTS '$OUTPUT_FILE'"
|
||||
;;
|
||||
*)
|
||||
echo "verbosity is not set properly" >&2
|
||||
|
@ -155,7 +155,7 @@ run_ffmpeg(){
|
|||
esac
|
||||
|
||||
if [ "$SIMULATION" = "" ]; then
|
||||
ffmpeg $LOG_LEVEL $FROM $TO -i "$INPUT_FILE" "$OUTPUT_FILE"
|
||||
ffmpeg $LOG_LEVEL $FROM $TO -i "$INPUT_FILE" $FFOPTS "$OUTPUT_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -195,17 +195,17 @@ Format for <song-list>:
|
|||
1:30 Second track
|
||||
|
||||
Environment variables:
|
||||
- SIMULATION [empty or not]
|
||||
do not invoke ffmpeg
|
||||
- NONUMBER [empty or 1]
|
||||
do not write song numbers
|
||||
- FORMAT [mp3,ogg,opus,…]
|
||||
see the ffmpeg documentation
|
||||
- SIMULATION [empty or not] do not invoke ffmpeg
|
||||
|
||||
- FORMAT [mp3,ogg,opus,…] see ffmpeg documentation
|
||||
- FFOPTS (default: '-c:a copy') see ffmpeg documentation
|
||||
|
||||
- NONUMBER [empty or 1] do not write song numbers
|
||||
- SEPARATOR [separator] (default: ' - ')
|
||||
separator between number and name
|
||||
example with SEPARATOR='_': 01_intro.opus 02_blah.opus…
|
||||
- HEADERS [empty or 1]
|
||||
print environment parameters (verbosity, simulation, etc.)
|
||||
|
||||
- HEADERS [empty or 1] print env params (verbosity, quality, etc.)
|
||||
- VERBOSITY [0-3] (default: 1)
|
||||
0: no output except errors from ffmpeg
|
||||
1: simple indications on the current track being extracted
|
||||
|
@ -219,13 +219,36 @@ header(){
|
|||
fi
|
||||
}
|
||||
|
||||
warning(){
|
||||
echo "WARNING: $*"
|
||||
}
|
||||
|
||||
# Default output format is based on the extension of the input audio file.
|
||||
if [ $# -eq 2 ]; then
|
||||
DEFAULT_FORMAT="$(echo $1 | awk -F . '{print $NF}')"
|
||||
else
|
||||
header "no default FORMAT selected"
|
||||
fi
|
||||
|
||||
if [ "$FORMAT" = "" ]; then
|
||||
header "default FORMAT: opus"
|
||||
FORMAT="opus"
|
||||
FORMAT="$DEFAULT_FORMAT"
|
||||
header "default FORMAT: ${FORMAT}"
|
||||
else
|
||||
header "FORMAT: $FORMAT"
|
||||
fi
|
||||
|
||||
# For unexperienced users, print a warning when input and output formats differ.
|
||||
# In case FFOPTS is set, encoding is expected to be handled, drop the warning.
|
||||
# Example (remove the get-tracks.sh default behavior, perform re-encoding):
|
||||
# FFOPTS=" "
|
||||
if [ "$FFOPTS" = "" ] && [ "$FORMAT" != "$DEFAULT_FORMAT" ]; then
|
||||
warning "input and output formats seem to differ"
|
||||
warning "1. re-encoding may be required (through the FFOPTS envvar)"
|
||||
warning "2. FFOPTS represents ffmpeg options, directly given to ffmpeg"
|
||||
warning ' (default: "-c:a copy" = copy without re-encoding)'
|
||||
warning ' You can put FFOPTS=" " if you want to perform re-encoding.'
|
||||
fi
|
||||
|
||||
if [ "$VERBOSITY" = "" ]; then
|
||||
header "default VERBOSITY: 1"
|
||||
VERBOSITY=1
|
||||
|
@ -249,6 +272,13 @@ else
|
|||
SEPARATOR=""
|
||||
fi
|
||||
|
||||
if [ "$FFOPTS" != "" ]; then
|
||||
header "FFOPTS envvar is set: ${FFOPTS}."
|
||||
else
|
||||
FFOPTS="-c:a copy"
|
||||
header "default FFOPTS: ${FFOPTS}"
|
||||
fi
|
||||
|
||||
if [ "$SIMULATION" != "" ]; then
|
||||
header "SIMULATION envvar is set: this is a simulation."
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue