Upload files to "/"
This better fucking recognize that it was chmodded but I don't expect it to.
This commit is contained in:
@@ -0,0 +1,65 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
OUTPUT="audiobook.m4b"
|
||||||
|
FILES="files.txt"
|
||||||
|
CHAPTERS="chapters.txt"
|
||||||
|
|
||||||
|
# list of MP3 files in filename order
|
||||||
|
find . -maxdepth 1 -name '*.mp3' -print0 |
|
||||||
|
sort -z |
|
||||||
|
while IFS= read -r -d '' file; do
|
||||||
|
file="${file#./}"
|
||||||
|
printf "file '%s'\n" "$file"
|
||||||
|
done > "$FILES"
|
||||||
|
|
||||||
|
# start chapter metadata file
|
||||||
|
{
|
||||||
|
echo ";FFMETADATA1"
|
||||||
|
} > "$CHAPTERS"
|
||||||
|
|
||||||
|
START=0
|
||||||
|
|
||||||
|
while IFS= read -r line; do
|
||||||
|
FILE="${line#file \'}"
|
||||||
|
FILE="${FILE%\'}"
|
||||||
|
|
||||||
|
# duration in milliseconds
|
||||||
|
DURATION=$(ffprobe \
|
||||||
|
-v error \
|
||||||
|
-show_entries format=duration \
|
||||||
|
-of csv=p=0 \
|
||||||
|
"$FILE")
|
||||||
|
|
||||||
|
DURATION_MS=$(awk "BEGIN {printf \"%.0f\", $DURATION * 1000}")
|
||||||
|
END=$((START + DURATION_MS))
|
||||||
|
|
||||||
|
# filename as the chapter title
|
||||||
|
TITLE="${FILE%.mp3}"
|
||||||
|
|
||||||
|
cat >> "$CHAPTERS" <<EOF
|
||||||
|
[CHAPTER]
|
||||||
|
TIMEBASE=1/1000
|
||||||
|
START=$START
|
||||||
|
END=$END
|
||||||
|
title=$TITLE
|
||||||
|
EOF
|
||||||
|
|
||||||
|
START=$END
|
||||||
|
|
||||||
|
done < "$FILES"
|
||||||
|
|
||||||
|
read -p "Press Enter key after making any corrections to $CHAPTERS"
|
||||||
|
|
||||||
|
ffmpeg \
|
||||||
|
-f concat \
|
||||||
|
-safe 0 \
|
||||||
|
-i "$FILES" \
|
||||||
|
-i "$CHAPTERS" \
|
||||||
|
-map 0:a \
|
||||||
|
-map_metadata 1 \
|
||||||
|
-c:a aac \
|
||||||
|
-b:a 128k \
|
||||||
|
-movflags +faststart \
|
||||||
|
"$OUTPUT"
|
||||||
Reference in New Issue
Block a user