Redid ffmpeg scripts

This commit is contained in:
Jan Jastrow 2023-02-11 01:30:25 +01:00
parent 28651d4311
commit be9442ddbf

View File

@ -7,13 +7,16 @@
function ff-mp4() { function ff-mp4() {
findpath=$1 findpath=$1
: "${findpath:="."}" : "${findpath:="."}"
find "$findpath" \( -iname '*.mkv' -o -iname '*.flv' -o -iname '*.mov' \) | while read -r f ; do find "$findpath" \( -iname '*.mkv' -o -iname '*.flv' -o -iname '*.mov' -o -iname '*.mp4*' \) | while read -r f ; do
dir=$(dirname "$f"); dir=$(dirname "$f");
file=$(basename "$f"); file=$(basename "$f");
# ext="${filename##*.}";
name="${file%.*}"; name="${file%.*}";
ffmpeg -i "$f" -map 0 -c copy -movflags faststart "$dir/$name.mp4" </dev/null; ext="${file##*.}";
# rm -f "$f";
ffmpeg -hide_banner -loglevel error -i "$f" -map 0 -c copy -movflags faststart "$dir/temp_$name.mp4";
mv "$f" "$dir/_$file";
mv "$dir/temp_$name.mp4" "$dir/$file";
done done
} }
@ -25,36 +28,44 @@ function ff-ac3-to-stereo() {
find "$findpath" \( -iname '*.mkv' -o -iname '*.flv' -o -iname '*.mov' -o -iname '*.mp4' \) | while read -r f ; do find "$findpath" \( -iname '*.mkv' -o -iname '*.flv' -o -iname '*.mov' -o -iname '*.mp4' \) | while read -r f ; do
dir=$(dirname "$f"); dir=$(dirname "$f");
file=$(basename "$f"); file=$(basename "$f");
# ext="${filename##*.}";
name="${file%.*}"; name="${file%.*}";
ffmpeg -i "$f" -map 0 -c:v copy -c:a libfdk_aac -b:a 192k -ac 2 -af volume=2 -movflags faststart "$dir/$name.mp4" </dev/null; ext="${file##*.}";
# rm -f "$f";
ffmpeg -hide_banner -loglevel error -i "$f" -map 0 -c:v copy -c:a libfdk_aac -b:a 192k -ac 2 -af volume=2 -movflags faststart "$dir/temp_$name.mp4";
mv "$f" "$dir/_$file";
mv "$dir/temp_$name.mp4" "$dir/$file";
done done
} }
# ffmpeg audio-to-ac3 # ffmpeg audio-to-ac3
function ff-input-to-ac3() { function ff-input-to-ac3() {
ffmpeg -i "$1" -movflags faststart -map 0 -c:v copy -c:s copy -c:a ac3 -b:a 448k "_$1" ffmpeg -i "$1" -movflags faststart -map 0 -c:v copy -c:s copy -c:a ac3 -b:a 448k "temp_$1"
mv "$1" "_$1" && mv "temp_$1" "$1"
} }
# ffmpeg fix 16:9 AR # ffmpeg fix 16:9 AR
function ff-ar16-9() { function ff-ar16-9() {
ffmpeg -i "$1" -c copy -map 0 -bsf:v "h264_metadata=sample_aspect_ratio=4/3" -aspect 16:9 -movflags faststart "_$1" ffmpeg -i "$1" -c copy -map 0 -bsf:v "h264_metadata=sample_aspect_ratio=4/3" -aspect 16:9 -movflags faststart "temp_$1"
mv "$1" "_$1" && mv "temp_$1" "$1"
} }
# ffmpeg fix 5:4 AR # ffmpeg fix 5:4 AR
function ff-ar5-4() { function ff-ar5-4() {
ffmpeg -i "$1" -c copy -map 0 -bsf:v "h264_metadata=sample_aspect_ratio=1/1" -aspect 5:4 -movflags faststart "_$1" ffmpeg -i "$1" -c copy -map 0 -bsf:v "h264_metadata=sample_aspect_ratio=1/1" -aspect 5:4 -movflags faststart "temp_$1"
mv "$1" "_$1" && mv "temp_$1" "$1"
} }
# ffmpeg fix 4:3 AR # ffmpeg fix 4:3 AR
function ff-ar4-3() { function ff-ar4-3() {
ffmpeg -i "$1" -c copy -map 0 -bsf:v "h264_metadata=sample_aspect_ratio=1/1" -aspect 4:3 -movflags faststart "_$1" ffmpeg -i "$1" -c copy -map 0 -bsf:v "h264_metadata=sample_aspect_ratio=1/1" -aspect 4:3 -movflags faststart "temp_$1"
mv "$1" "_$1" && mv "temp_$1" "$1"
} }
# ffmpeg fix Non-monotonous DTS # ffmpeg fix Non-monotonous DTS
function ff-dts() { function ff-dts() {
ffmpeg -fflags +igndts -i "$1" -c copy -movflags faststart "_$1" ffmpeg -fflags +igndts -i "$1" -c copy -movflags faststart "temp_$1"
mv "$1" "_$1" && mv "temp_$1" "$1"
} }
## ffmpeg wma-to-m4a ## ffmpeg wma-to-m4a
@ -64,9 +75,12 @@ function ff-wma-m4a() {
find "$findpath" -name '*.wma' | while read -r f ; do find "$findpath" -name '*.wma' | while read -r f ; do
dir=$(dirname "$f"); dir=$(dirname "$f");
file=$(basename "$f"); file=$(basename "$f");
# ext="${filename##*.}";
name="${file%.*}"; name="${file%.*}";
ffmpeg -i "$f" -map 0 -vn -b:a 160k -c:a libfdk_aac "$dir/$name.m4a" </dev/null; ext="${file##*.}";
# rm -f "$f";
ffmpeg -hide_banner -loglevel error -i "$f" -map 0 -vn -b:a 192k -c:a libfdk_aac "$dir/temp_$name.mp4";
mv "$f" "$dir/_$file";
mv "$dir/temp_$name.mp4" "$dir/$file";
done done
} }