mirror of
https://github.com/bytedream/scripts.git
synced 2025-12-16 07:50:43 +01:00
Compare commits
3 Commits
01f3134586
...
22c4c5ec31
| Author | SHA1 | Date | |
|---|---|---|---|
| 22c4c5ec31 | |||
| 7fdaf08781 | |||
| 84add46936 |
@@ -7,6 +7,10 @@ This repository contains some Linux scripts I am using to simplify some of my wo
|
|||||||
- DNS
|
- DNS
|
||||||
- [clear-cache.sh](dns/clear-cache.sh) - Clear the systemd DNS cache
|
- [clear-cache.sh](dns/clear-cache.sh) - Clear the systemd DNS cache
|
||||||
|
|
||||||
|
- FFmpeg
|
||||||
|
- [compress-camera.sh](ffmpeg/compress-camera.sh) - Script to compress videos from my phone camera to an AV1 encoded 1080p video
|
||||||
|
- [compress-camera-public.sh](ffmpeg/compress-camera-public.sh) - Script to compress videos from my phone camera to AV1, VP9 and H264 videos to play them in browsers
|
||||||
|
|
||||||
- Patches
|
- Patches
|
||||||
- [spotify.sh](patches/spotify.sh) - Use [SpotX-Bash](https://github.com/SpotX-Official/SpotX-Bash) to patch a existing spotify installation
|
- [spotify.sh](patches/spotify.sh) - Use [SpotX-Bash](https://github.com/SpotX-Official/SpotX-Bash) to patch a existing spotify installation
|
||||||
|
|
||||||
|
|||||||
50
ffmpeg/compress-camera-public.sh
Executable file
50
ffmpeg/compress-camera-public.sh
Executable file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
verify_commands() {
|
||||||
|
commands=("ffmpeg" "ffprobe")
|
||||||
|
for command in "${commands[@]}"; do
|
||||||
|
which $command &> /dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "command '$command' not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
verify_commands
|
||||||
|
|
||||||
|
for arg in "$@"; do
|
||||||
|
for file in $(ls "$arg"); do
|
||||||
|
filename="${file%.*}"
|
||||||
|
extension="${file##*.}"
|
||||||
|
if [ "$extension" != "mp4" ]; then
|
||||||
|
echo "Invalid filetype: $file (expected mp4)"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
width=$(ffprobe -v error -select_streams v:0 -show_entries stream=width -of default=noprint_wrappers=1:nokey=1 "$file")
|
||||||
|
height=$(ffprobe -v error -select_streams v:0 -show_entries stream=height -of default=noprint_wrappers=1:nokey=1 "$file")
|
||||||
|
rotation=$(ffprobe -v error -select_streams v:0 -show_entries stream_side_data=rotation -of default=noprint_wrappers=1:nokey=1 "$file")
|
||||||
|
if [ "$rotation" -eq "90" ] || [ "$rotation" -eq "-90" ]; then
|
||||||
|
new_width=$height
|
||||||
|
new_height=$width
|
||||||
|
width=$new_width
|
||||||
|
height=$new_height
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$width" -gt "$height" ]; then
|
||||||
|
width=1920
|
||||||
|
height=-1
|
||||||
|
else
|
||||||
|
width=-1
|
||||||
|
height=1920
|
||||||
|
fi
|
||||||
|
|
||||||
|
ffmpeg -i "$file" -vf scale="$width:$height" -b:v 1800k -minrate 900k -maxrate 2610k -tile-columns 2 -g 240 -threads 8 -quality good -crf 31 -c:v libvpx-vp9 -c:a copy -pass 1 -passlogfile /tmp/ffmpeg2pass -speed 4 -an -f null /dev/null
|
||||||
|
ffmpeg -i "$file" -vf scale="$width:$height" -b:v 1800k -minrate 900k -maxrate 2610k -tile-columns 3 -g 240 -threads 8 -quality good -crf 32 -c:v libvpx-vp9 -c:a copy -pass 2 -passlogfile /tmp/ffmpeg2pass -speed 4 "${filename}_public.mp4"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
main $@
|
||||||
48
ffmpeg/compress-camera.sh
Executable file
48
ffmpeg/compress-camera.sh
Executable file
@@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
verify_commands() {
|
||||||
|
commands=("ffmpeg" "ffprobe")
|
||||||
|
for command in "${commands[@]}"; do
|
||||||
|
which $command &> /dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "command '$command' not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
verify_commands
|
||||||
|
|
||||||
|
for arg in "$@"; do
|
||||||
|
for file in $(ls "$arg"); do
|
||||||
|
filename="${file%.*}"
|
||||||
|
extension="${file##*.}"
|
||||||
|
if [ "$extension" != "mp4" ]; then
|
||||||
|
echo "Invalid filetype: $file (expected mp4)"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
width=$(ffprobe -v error -select_streams v:0 -show_entries stream=width -of default=noprint_wrappers=1:nokey=1 "$file")
|
||||||
|
height=$(ffprobe -v error -select_streams v:0 -show_entries stream=height -of default=noprint_wrappers=1:nokey=1 "$file")
|
||||||
|
rotation=$(ffprobe -v error -select_streams v:0 -show_entries stream_side_data=rotation -of default=noprint_wrappers=1:nokey=1 "$file")
|
||||||
|
if [ "$rotation" -eq "90" ] || [ "$rotation" -eq "-90" ]; then
|
||||||
|
new_width=$height
|
||||||
|
new_height=$width
|
||||||
|
width=$new_width
|
||||||
|
height=$new_height
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$width" -gt "$height" ]; then
|
||||||
|
width=1920
|
||||||
|
height=-1
|
||||||
|
else
|
||||||
|
width=-1
|
||||||
|
height=1920
|
||||||
|
fi
|
||||||
|
ffmpeg -i "$file" -vf scale="$width:$height" -c:v libsvtav1 -preset 4 -crf 23 -pix_fmt yuv420p10le -svtav1-params tune=0:film-grain=8 -c:a copy "${filename}_compressed.${extension}"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
main $@
|
||||||
Reference in New Issue
Block a user