-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathffmpeg_batch.sh
27 lines (21 loc) · 924 Bytes
/
ffmpeg_batch.sh
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
#!/bin/bash
# Set the output directory (current directory + "/output")
OUTPUT_DIR="${PWD}/output"
COMPLETE_DIR="${PWD}/complete"
# Create the output and complete directories if they don't exist
mkdir -p "${OUTPUT_DIR}"
mkdir -p "${COMPLETE_DIR}"
# Loop through all video files in the current directory
for file in *.mp4 *.MP4 *.mkv *.MKV *.avi *.AVI *.mov *.MOV *.wmv *.WMV *.m4v *.M4V *.mpg *.MPG *.mpeg *.MPEG *.flv *.FLV *.webm *.WEBM *.3gp *.3GP *.ts *.TS; do
# Check if the file exists (in case no files match the pattern)
if [[ -f "$file" ]]; then
# Get the file name without extension
filename="${file%.*}"
# Set the CRF value
CRF_VALUE=26
# Run ffmpeg to convert the video
ffmpeg -i "${file}" -c:v libx264 -crf ${CRF_VALUE} -r 30 "${OUTPUT_DIR}/${filename}_batch_${CRF_VALUE}.mp4"
# Move the original file to the complete directory
mv "${file}" "${COMPLETE_DIR}/"
fi
done