| #!/bin/bash |
|
|
| |
| VIDEO_DIR="predefined" |
|
|
| |
| TARGET_WIDTH=720 |
| TARGET_HEIGHT=640 |
|
|
| |
| for video in "$VIDEO_DIR"/*.mov; do |
| if [ -f "$video" ]; then |
| echo "Processing: $video" |
| |
| |
| width=$(ffprobe -v error -select_streams v:0 -show_entries stream=width -of default=noprint_wrappers=1:nokey=1 "$video") |
| height=$(ffprobe -v error -select_streams v:0 -show_entries stream=height -of default=noprint_wrappers=1:nokey=1 "$video") |
| |
| |
| if [ "$width" -gt "$height" ]; then |
| |
| crop_width=$(( height * TARGET_WIDTH / TARGET_HEIGHT )) |
| crop_height=$height |
| x_offset=$(( (width - crop_width) / 2 )) |
| y_offset=0 |
| else |
| |
| crop_width=$width |
| crop_height=$(( width * TARGET_HEIGHT / TARGET_WIDTH )) |
| x_offset=0 |
| y_offset=$(( (height - crop_height) / 2 )) |
| fi |
| |
| |
| ffmpeg -i "$video" \ |
| -af "aresample=48000" \ |
| -vf "crop=$crop_width:$crop_height:$x_offset:$y_offset,scale=$TARGET_WIDTH:$TARGET_HEIGHT" \ |
| -c:v libx264 \ |
| -c:a aac \ |
| -y \ |
| "${video%.*}_processed.mov" |
| |
| echo "Completed: $video" |
| fi |
| done |
|
|
| echo "All videos processed!" |