-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathffmpeg_compress.sh
More file actions
executable file
·26 lines (20 loc) · 919 Bytes
/
ffmpeg_compress.sh
File metadata and controls
executable file
·26 lines (20 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
filename="$1"
fileextension="${filename##*.}"
# compresses video files using ffmpeg
# the idea is to set this as command inside the file manager e.g. thunar
# to quickly compress video files
# Check if the file is mp4 or mkv
if [[ "$fileextension" != "mp4" && "$fileextension" != "mkv" ]]; then
echo "Error: The file must be an mp4 or mkv file."
notify-send "Error: The file must be an mp4 or mkv file."
exit 1
fi
output=$(ffmpeg -hide_banner -loglevel error -y -i "${filename}" "${filename%.*}_compressed.$fileextension" 2>&1)
if [ $? -ne 0 ]; then
notify-send "Error: Compression failed." "$output"
echo "Error: Compression failed." "$output"
exit 1
fi
notify-send "Compression complete" "The file has been compressed and saved as ${filename%.*}_compressed.$fileextension"
echo "Compression complete" "The file has been compressed and saved as ${filename%.*}_compressed.$fileextension"