Make sure MP4 files are stream-able

This commit is contained in:
Nemo 2021-09-29 13:31:20 +05:30
parent 56bf33f531
commit ffaca3fbbb
3 changed files with 8 additions and 3 deletions

View File

@ -9,11 +9,15 @@ IFS=$'\n\t'
# So once you have it, you can save it and then re-use it for instant future decryption using ffmpeg.
# This gets it from my password manager
gettoken Keys/AUDIBLE_ACTIVATION_BYTES
export AUDIBLE_ACTIVATION_BYTES=$(pass show Keys/AUDIBLE_ACTIVATION_BYTES)
for i in *.aax; do
m4a_file="${i%%.*}.m4a"
if [ ! -e "$m4a_file" ]; then
ffmpeg -loglevel panic -y -activation_bytes ${AUDIBLE_ACTIVATION_BYTES} -i "$i" -c:a copy -vn "$m4a_file"
ffmpeg -loglevel panic -y -activation_bytes ${AUDIBLE_ACTIVATION_BYTES} -i "$i" -c:a copy -movflags +faststart -vn "$m4a_file"
# See https://github.com/captn3m0/Scripts/blob/master/fix-audible-m4a for this script
# Dependencies are: bento4 (https://aur.archlinux.org/packages/bento4/)
# bash, and sed
fix-audible-m4a "$m4a_file"
fi
done

View File

@ -12,7 +12,6 @@ mp4extract-bento4 moov/trak/mdia/minf/stbl/stsd/mp4a/esds \
magic=$(sed -re 's/^.*0580808002(....).*$/\1/' $t)
if [ "$magic" != "1212" ]; then
echo "no need to fix"
rm "$t"
exit 0
fi

View File

@ -55,7 +55,9 @@ while read -r first _ _ start _ end; do
# -vn = no video stream
# -metadata title= put in a chapter title
# -acodec copy = copy the audio stream
# +faststart = Relocating this moov atom to the beginning of the file can facilitate playback before the file is completely downloaded by the client.
ffmpeg -hide_banner -loglevel panic \
-movflags +faststart \
-vsync 2 -sn -dn -vn -i "$1" -ss "${start%?}" -to "$end" -metadata title="$CHAPTER_TITLE" -dn -vn -sn -acodec copy "$FILENAME" </dev/null
((CHAPTER_INDEX++))