mirror of
https://github.com/KrumpetPirate/AAXtoMP3.git
synced 2024-11-18 03:08:57 +01:00
better HQ cover processing
This commit is contained in:
parent
d0b5bda46d
commit
b7e978c8bb
35
AAXtoMP3
35
AAXtoMP3
@ -324,7 +324,7 @@ validate_aax() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
validate_extra_files() {
|
validate_extra_files() {
|
||||||
local extra_media_file extra_title extra_chapter_file
|
local extra_media_file # extra_title extra_chapter_file
|
||||||
extra_media_file="$1"
|
extra_media_file="$1"
|
||||||
# Bash trick to delete, non greedy, from the end up until the first '-'
|
# Bash trick to delete, non greedy, from the end up until the first '-'
|
||||||
extra_title="${extra_media_file%-*}"
|
extra_title="${extra_media_file%-*}"
|
||||||
@ -336,7 +336,6 @@ validate_extra_files() {
|
|||||||
# Chapter file: BookTitle-chapters.json
|
# Chapter file: BookTitle-chapters.json
|
||||||
extra_chapter_file="${extra_title}-chapters.json"
|
extra_chapter_file="${extra_title}-chapters.json"
|
||||||
|
|
||||||
debug_vars "Audible-cli files" extra_media_file extra_title extra_chapter_file
|
|
||||||
|
|
||||||
# Test for chapter file existence
|
# Test for chapter file existence
|
||||||
if [[ ! -r "${extra_chapter_file}" ]] ; then
|
if [[ ! -r "${extra_chapter_file}" ]] ; then
|
||||||
@ -344,8 +343,16 @@ validate_extra_files() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test for cover art existence (any resolution)
|
extra_find_command='find -maxdepth 1 -regex ".*/${extra_title}_([0-9]+)\.jpg"'
|
||||||
if [[ ! $(find -maxdepth 1 -regex ".*/${extra_title}_([0-9]+)\\.jpg") ]]; then
|
# extra_cover_file="$(find -maxdepth 1 -regex \".*/${extra_title}_\(\[\0\-\9\]\+\)\\.jpg\")"
|
||||||
|
|
||||||
|
# We want the output of the find command, we will turn errexit on later
|
||||||
|
set +e errexit
|
||||||
|
extra_cover_file="$(eval ${extra_find_command})"
|
||||||
|
set -e errexit
|
||||||
|
|
||||||
|
debug_vars "Audible-cli files" extra_media_file extra_title extra_chapter_file extra_cover_file
|
||||||
|
if [[ "x${extra_cover_file}" == "x" ]] ; then
|
||||||
log "ERROR Cover File NOT Found"
|
log "ERROR Cover File NOT Found"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -479,10 +486,21 @@ do
|
|||||||
fi
|
fi
|
||||||
# Grab the cover art if available.
|
# Grab the cover art if available.
|
||||||
cover_file="${output_directory}/cover.jpg"
|
cover_file="${output_directory}/cover.jpg"
|
||||||
|
extra_crop_cover=''
|
||||||
if [ "${continue}" == "0" ]; then
|
if [ "${continue}" == "0" ]; then
|
||||||
|
if [ "${audibleCli}" == "1" ]; then
|
||||||
|
# We have a better quality cover file, copy it.
|
||||||
|
log "Copy cover file to ${cover_file}..."
|
||||||
|
cp "${extra_cover_file}" "${cover_file}"
|
||||||
|
|
||||||
|
# We now set a variable, ${extra_crop_cover}, which contains an additional
|
||||||
|
# ffmpeg flag. It crops the cover so the width and the height is divisible by two.
|
||||||
|
extra_crop_cover='-vf crop=trunc(iw/2)*2:trunc(ih/2)*2'
|
||||||
|
else
|
||||||
log "Extracting cover into ${cover_file}..."
|
log "Extracting cover into ${cover_file}..."
|
||||||
</dev/null ffmpeg -loglevel error -activation_bytes "${auth_code}" -i "${aax_file}" -an -codec:v copy "${cover_file}"
|
</dev/null ffmpeg -loglevel error -activation_bytes "${auth_code}" -i "${aax_file}" -an -codec:v copy "${cover_file}"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
# -----
|
# -----
|
||||||
# OK now spit the file if that's what you want.
|
# OK now spit the file if that's what you want.
|
||||||
# If we want multiple file we take the big mp3 and split it by chapter.
|
# If we want multiple file we take the big mp3 and split it by chapter.
|
||||||
@ -540,20 +558,21 @@ do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Big Long chapter debug
|
# Big Long chapter debug
|
||||||
debug_vars "Chapter Variables:" cover_file chapter_start chapter_end id3_version_param chapternum chapter_title chapter_file
|
debug_vars "Chapter Variables:" cover_file extra_crop_cover chapter_start chapter_end id3_version_param chapternum chapter_title chapter_file
|
||||||
if [ "$((${continueAt} > ${chapternum}))" = "0" ]; then
|
if [ "$((${continueAt} > ${chapternum}))" = "0" ]; then
|
||||||
# Extract chapter by time stamps start and finish of chapter.
|
# Extract chapter by time stamps start and finish of chapter.
|
||||||
# This extracts based on time stamps start and end.
|
# This extracts based on time stamps start and end.
|
||||||
log "Splitting chapter ${chapternum}/${chaptercount} start:${chapter_start%?}(s) end:${chapter_end}(s)"
|
log "Splitting chapter ${chapternum}/${chaptercount} start:${chapter_start%?}(s) end:${chapter_end}(s)"
|
||||||
</dev/null ffmpeg -loglevel quiet \
|
ffmpeg \
|
||||||
-nostats \
|
|
||||||
-ss "${chapter_start%?}" \
|
-ss "${chapter_start%?}" \
|
||||||
-to "${chapter_end}" \
|
-to "${chapter_end}" \
|
||||||
-i "${output_file}" \
|
-i "${output_file}" \
|
||||||
-i "${cover_file}" \
|
-i "${cover_file}" \
|
||||||
|
${extra_crop_cover} \
|
||||||
-map 0:0 \
|
-map 0:0 \
|
||||||
-map 1:0 \
|
-map 1:0 \
|
||||||
-acodec "${codec}" ${id3_version_param} \
|
-acodec "${codec}" \
|
||||||
|
${id3_version_param} \
|
||||||
-metadata:s:v title="Album cover" \
|
-metadata:s:v title="Album cover" \
|
||||||
-metadata:s:v comment="Cover (Front)" \
|
-metadata:s:v comment="Cover (Front)" \
|
||||||
-metadata track="${chapternum}" \
|
-metadata track="${chapternum}" \
|
||||||
|
Loading…
Reference in New Issue
Block a user