-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvp9.sh
More file actions
47 lines (39 loc) · 1.06 KB
/
vp9.sh
File metadata and controls
47 lines (39 loc) · 1.06 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# Function to convert webm files to vp9 codec with Opus audio
convert_to_vp9_opus() {
local file="$1"
local dirname=$(dirname "$file")
local filename=$(basename "$file")
local filename_noext="${filename%.*}"
local output_file="${filename_noext}_vp9.webm"
ffmpeg -i "$file" -c:v vp9 -b:v 0 -crf 23 -c:a libopus "$output_file" -y
if [ $? -eq 0 ]; then
echo "Converted: $file"
rm "$file"
mv "$output_file" "$file"
echo "Replaced: $file"
else
echo "Failed to convert: $file"
fi
}
# Function to process directory recursively
process_directory() {
local dir="$1"
local file="$2"
if [[ $file == *.webm ]]; then
convert_to_vp9_opus "$file"
fi
}
# Main script
if [ $# -ne 1 ]; then
echo "Usage: $0 <directory>"
exit 1
fi
directory="$1"
if [ ! -d "$directory" ]; then
echo "Error: $directory is not a directory"
exit 1
fi
export -f convert_to_vp9_opus
export -f process_directory
find "$directory" -type f -name '*.webm' | parallel process_directory "$directory"