find update, dd update, usage

This commit is contained in:
yosh 2023-04-19 16:40:43 -04:00
parent 22ac378902
commit 18ceb3c756
1 changed files with 37 additions and 35 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
# flacconv 1.4.1 // use https://github.com/yoshiyoshyosh/flacconv for issues
# flacconv 1.4.2 // use https://github.com/yoshiyoshyosh/flacconv for issues
GREEN="$(tput setf 2)" || GREEN="$(tput setaf 2)"
RED="$(tput setf 4)" || RED="$(tput setaf 1)"
@ -101,7 +101,7 @@ process_file() {
metaflac --export-picture-to=- "$infile" 1>/dev/null 2>&1 || RMPIC=1
# first detect any potential ID3 tags
head_bytes="$(dd if="$infile" of=/dev/stdout bs=1 count=3 2>/dev/null)"
head_bytes="$(dd if="$infile" bs=1 count=3 2>/dev/null)"
if [ "$head_bytes" = "ID3" ]; then
warn "invalid id3 tags found in $infile, you should get that fixed!"
# in a previous version this would remove invalid id3 tags automatically
@ -177,39 +177,41 @@ process_file() {
}
usage() {
errecho \
'usage: '"$BN"' [-huvVipe3] [-b BITRATE] [-l LEVEL] [-k KEYS] [-r KEYS] [-j THREADS] [--] [DIRECTORY...]
'"$BN"' recursively converts directories of flac files to opus/mp3
DIRECTORY can be specified multiple times. if omitted, the current directory is used
by default, this script outputs opus with variable bitrate 128k
IF ENCODING TO MP3, -k AND -r WILL NOT WORK. the only metadata that will be kept is the following:
TITLE, ARTIST, ALBUM, ALBUMARTIST, DATE, GENRE, TRACKNUMBER, COMMENT, and the cover picture
(blame id3. just use opus)
cat >&2 <<-EOF
usage: $BN [-huvVipe3] [-b BITRATE] [-l LEVEL] [-k KEYS] [-r KEYS] [-j THREADS] [--] [DIRECTORY...]
-h show script help
-u check for updates
-v verbose output (messy with multithreading)
-V very verbose output (VERY messy, use only for debugging and with like, -j 1)
-i ignore script-stopping warnings
-d delete original flac files after transcoding
-3 switch output filetype to mp3
-b <BITRATE> output bitrate in kbits (default 128)
this value is variable for opus & CBR for mp3
-l <LEVEL> mp3 only: use specified mp3 variable quality (0-9). integer only
OVERRIDES -b
-k <KEYS> keep specified flac metadata KEYS in output file
keys can be checked with metaflac --export-tags-to=- FILE
option argument is a PIPE-separated list of keys to keep, case-insensitive
(i.e. -k '\''artist|title|albumartist|album|date'\'')
if both -k and -r are not present, all keys are kept.
-r <KEYS> remove specified flac metadata KEYS in output file
option argument is of the same format as -k
if set to "ALL" (with capitalization), all keys are removed
-p remove embedded picture in output files
-e remove the "encoder" tag that automatically gets applied with opusenc
(requires opustags)
-j <THREADS> use the specified amount of threads for parallel processing
if omitted, CPU core count will be used'
$BN recursively converts directories of flac files to opus/mp3
DIRECTORY can be specified multiple times. if omitted, the current directory is used
by default, this script outputs opus with variable bitrate 128k
IF ENCODING TO MP3, -k AND -r WILL NOT WORK. the only metadata that will be kept is the following:
TITLE, ARTIST, ALBUM, ALBUMARTIST, DATE, GENRE, TRACKNUMBER, COMMENT, and the cover picture
(blame id3. just use opus)
-h show script help
-u check for updates
-v verbose output (messy with multithreading)
-V very verbose output (VERY messy, use only for debugging and with like, -j 1)
-i ignore script-stopping warnings
-d delete original flac files after transcoding
-3 switch output filetype to mp3
-b <BITRATE> output bitrate in kbits (default 128)
this value is variable for opus & CBR for mp3
-l <LEVEL> mp3 only: use specified mp3 variable quality (0-9). integer only
OVERRIDES -b
-k <KEYS> keep specified flac metadata KEYS in output file
keys can be checked with metaflac --export-tags-to=- FILE
option argument is a PIPE-separated list of keys to keep, case-insensitive
(i.e. -k "artist|title|albumartist|album|date")
if both -k and -r are not present, all keys are kept.
-r <KEYS> remove specified flac metadata KEYS in output file
option argument is of the same format as -k
if set to "ALL" (with capitalization), all keys are removed
-p remove embedded picture in output files
-e remove the "encoder" tag that automatically gets applied with opusenc
(requires opustags)
-j <THREADS> use the specified amount of threads for parallel processing
if omitted, CPU core count will be used
EOF
}
VERBOSE=
@ -258,7 +260,7 @@ command -v metaflac 1>/dev/null 2>&1 || fail 'flac tools are not installed! (met
# I do not want to change it to account for this
# you should never put newlines in paths
# it is a very bad idea for many programs
FLACFILES="$(find "$@" -type f -name "*.flac")"
FLACFILES="$(find "$@" -type f -iname "*.[fF][lL][aA][cC]")"
[ "$FLACFILES" ] || fail 'no flac files found!'
# make a fifo/fd for parallel stuff