mirror of
https://github.com/JanJastrow/.dotfiles.git
synced 2024-10-31 16:44:50 +01:00
Compare commits
3 Commits
7ef54e6c82
...
5c867976f4
Author | SHA1 | Date | |
---|---|---|---|
5c867976f4 | |||
3b79a61b19 | |||
f6efcf2c4d |
40
zsh/ffmpeg
40
zsh/ffmpeg
@ -36,9 +36,8 @@ function ff-mp4 () {
|
||||
|
||||
# Rename the original file and move the new mp4 file to its place
|
||||
mv -n "$file" "$dir/_$file_name"
|
||||
mv -n "$dir/temp_$name.mp4" "$dir/$file_name"
|
||||
|
||||
done
|
||||
mv -n "$dir/temp_$name.mp4" "$dir/$file_name.mp4"
|
||||
done
|
||||
}
|
||||
|
||||
# Recompress input MP4 to 720p MP4 (copy audio)
|
||||
@ -56,7 +55,24 @@ ff-recompress720p() {
|
||||
echo "Conversion failed for: $input"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# Recompress input MP4 to 540p MP4 (copy audio)
|
||||
ff-recompress540p() {
|
||||
for input in *.mp4; do
|
||||
if [[ -f "$input" ]]; then
|
||||
tempfile="temp_${input%.mp4}"
|
||||
ffmpeg -hide_banner -i "$input" -map 0 -c:v libx264 -crf 18 -vf scale=960:-2 -preset slow -tune film -x264-params "ref=5:bframes=5:crf-max=25:qpmax=34:level=3.1:b-adapt=2:direct=auto:deblock=-1,-1:analyse=all:me=umh:subme=9:trellis=2:psy-rd=1,0.15:vbv-bufsize=17500:vbv-maxrate=17500:rc-lookahead=60" -c:a copy -movflags faststart "$tempfile.mp4"
|
||||
if [[ $? -eq 0 ]]; then
|
||||
mv "$input" "_$input"
|
||||
mv "$tempfile.mp4" "$input"
|
||||
echo "Conversion successful: $input"
|
||||
else
|
||||
echo "Conversion failed for: $input"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# ffmpeg-convert
|
||||
@ -79,25 +95,25 @@ function ff-ac3-to-stereo() {
|
||||
|
||||
# ffmpeg audio-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 "temp_$1"
|
||||
ffmpeg -hide_banner -loglevel error -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
|
||||
function ff-ar16-9() {
|
||||
ffmpeg -i "$1" -c copy -map 0 -bsf:v "h264_metadata=sample_aspect_ratio=4/3" -aspect 16:9 -pix_fmt yuv420p -movflags faststart "temp_$1"
|
||||
ffmpeg -hide_banner -loglevel error -i "$1" -c copy -map 0 -bsf:v "h264_metadata=sample_aspect_ratio=4/3" -aspect 16:9 -pix_fmt yuv420p -movflags faststart "temp_$1"
|
||||
mv "$1" "_$1" && mv "temp_$1" "$1"
|
||||
}
|
||||
|
||||
# ffmpeg fix 5:4 AR
|
||||
function ff-ar5-4() {
|
||||
ffmpeg -i "$1" -c copy -map 0 -bsf:v "h264_metadata=sample_aspect_ratio=1/1" -aspect 5:4 -pix_fmt yuv420p -movflags faststart "temp_$1"
|
||||
ffmpeg -hide_banner -loglevel error -i "$1" -c copy -map 0 -bsf:v "h264_metadata=sample_aspect_ratio=1/1" -aspect 5:4 -pix_fmt yuv420p -movflags faststart "temp_$1"
|
||||
mv "$1" "_$1" && mv "temp_$1" "$1"
|
||||
}
|
||||
|
||||
# ffmpeg fix 4:3 AR
|
||||
function ff-ar4-3() {
|
||||
ffmpeg -i "$1" -c copy -map 0 -bsf:v "h264_metadata=sample_aspect_ratio=1/1" -aspect 4:3 -pix_fmt yuv420p -movflags faststart "temp_$1"
|
||||
ffmpeg -hide_banner -loglevel error -i "$1" -c copy -map 0 -bsf:v "h264_metadata=sample_aspect_ratio=1/1" -aspect 4:3 -pix_fmt yuv420p -movflags faststart "temp_$1"
|
||||
mv "$1" "_$1" && mv "temp_$1" "$1"
|
||||
}
|
||||
|
||||
@ -107,13 +123,13 @@ function ff-ar-custom() {
|
||||
>&2 echo "Not enough arguments (\$1 = 'file', \$2 '1/1', \$3 '4:3')"
|
||||
return 0
|
||||
else
|
||||
ffmpeg -i "$1" -c copy -map 0 -bsf:v "h264_metadata=sample_aspect_ratio=$2" -aspect $3 -pix_fmt yuv420p -movflags faststart "_$1"
|
||||
ffmpeg -hide_banner -loglevel error -i "$1" -c copy -map 0 -bsf:v "h264_metadata=sample_aspect_ratio=$2" -aspect $3 -pix_fmt yuv420p -movflags faststart "_$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# ffmpeg fix Non-monotonous DTS
|
||||
function ff-dts() {
|
||||
ffmpeg -fflags +igndts -i "$1" -c copy -pix_fmt yuv420p -movflags faststart "temp_$1"
|
||||
ffmpeg -hide_banner -loglevel error -fflags +igndts -i "$1" -c copy -pix_fmt yuv420p -movflags faststart "temp_$1"
|
||||
mv "$1" "_$1" && mv "temp_$1" "$1"
|
||||
}
|
||||
|
||||
@ -138,7 +154,7 @@ function ff-wma-m4a() {
|
||||
function ff-cutstart {
|
||||
local time="${2:-00:00:08.590}"
|
||||
mv "$1" "_$1"
|
||||
ffmpeg -ss $time -i "_$1" -map 0 -c copy -movflags faststart "$1"
|
||||
ffmpeg -hide_banner -loglevel error -ss $time -i "_$1" -map 0 -c copy -movflags faststart "$1"
|
||||
}
|
||||
|
||||
## ffmpeg cut X seconds from start
|
||||
@ -147,5 +163,5 @@ function ff-cutend {
|
||||
duration=`ffprobe -v error -show_entries format=duration -of csv=p=0 "$1"`
|
||||
duration=`bc --expression=$duration-$time`
|
||||
mv "$1" "_$1"
|
||||
ffmpeg -ss 00:00:00 -to $duration -i "_$1" -map 0 -c copy -movflags faststart "$1"
|
||||
ffmpeg -hide_banner -loglevel error -ss 00:00:00 -to $duration -i "_$1" -map 0 -c copy -movflags faststart "$1"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user