parameter- und zielordnerhandling verbessert

This commit is contained in:
fabian 2023-02-20 19:13:25 +01:00
parent e163a0a50f
commit b5d9c6263c
3 changed files with 49 additions and 27 deletions

View File

@ -1,7 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
# ensure existence of destination folder
dest=../reencode
if [[ !(-d $dest) ]]; then
mkdir $dest
fi
for file in ./*.$1; do for file in ./*.$1; do
echo "ffmpeg -i '$file' -c:a copy -map 0:0 '../reencode/$file'"; echo "ffmpeg -i '$file' -c:a copy -map 0:0 '$dest/$file'";
ffmpeg -i "$file" -c:a copy -map 0:0 "../reencode/$file"; ffmpeg -i "$file" -c:a copy -map 0:0 "$dest/$file";
done done

View File

@ -1,21 +1,29 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
for file in ./*.m4a; do # evaluate options through given arguments
map=''; map=
if [[ $# > 0 && $1 == 'map' ]]; then vbr=
map='-map 0:0'; while [[ $# > 0 ]]; do
fi case $1 in
vbr=''; -map) map='-map 0:0'; shift;;
if [[ $# > 1 && $2 == 'vbr' ]]; then -vbr) vbr='libfdk_aac -profile:a aac_he -b:a 64k'; shift;;
vbr='libfdk_aac -profile:a aac_he -b:a 64k'; * ) break ;; # Anything else stops command line processing.
else esac
done
# if no variable bitrate, just copy audio
if [[ -z $vbr ]]; then
map="$map copy" map="$map copy"
fi fi
# ensure existence of destination folder
dest=../reencode dest=../reencode
if [[ !(-d $dest) ]]; then if [[ !(-d $dest) ]]; then
mkdir $dest mkdir $dest
fi fi
for file in ./*.m4a; do
echo "ffmpeg -i '$file' -c:a $vbr $map -movflags +faststart '$dest/$file'"; echo "ffmpeg -i '$file' -c:a $vbr $map -movflags +faststart '$dest/$file'";
ffmpeg -i "$file" -c:a $vbr $map -movflags +faststart "$dest/$file"; ffmpeg -i "$file" -c:a $vbr $map -movflags +faststart "$dest/$file";
done done

View File

@ -1,16 +1,24 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
for file in ./*.$1; do # evaluate options through given arguments
map=''; file_suffix=
if [[ $# > 1 && $2 == 'map' ]]; then map=
map='-map 0:0'; while [[ $# > 0 ]]; do
fi case $1 in
-t | --type) file_suffix=$2; shift 2;;
-map ) map='-map 0:0'; shift;;
* ) break ;; # Anything else stops command line processing.
esac
done
# ensure existence of destination folder
dest=../transcode_m4a dest=../transcode_m4a
if [[ !(-d $dest) ]]; then if [[ !(-d $dest) ]]; then
mkdir $dest mkdir $dest
fi fi
echo "ffmpeg -i '$file' -c:a libfdk_aac -profile:a aac_he -b:a 64k -movflags +faststart $map '$dest/${file%$1}m4a'";
ffmpeg -i "$file" -c:a libfdk_aac -profile:a aac_he -b:a 64k -movflags +faststart $map "$dest/${file%$1}m4a";
done
for file in ./*.$file_suffix; do
echo "ffmpeg -i '$file' -c:a libfdk_aac -profile:a aac_he -b:a 64k $map -movflags +faststart '$dest/${file%$file_suffix}m4a'";
ffmpeg -i "$file" -c:a libfdk_aac -profile:a aac_he -b:a 64k $map -movflags +faststart "$dest/${file%$file_suffix}m4a";
done