# Directory containing the videos | |
VIDEO_DIR="/home/tinkerspace/" | |
# Directory to store extracted frames | |
OUTPUT_DIR="/home/tinkerspace/extracted_frames" | |
# Create the output directory if it doesn't exist | |
mkdir -p "$OUTPUT_DIR" | |
# Loop through each video file in the directory | |
for video in "$VIDEO_DIR"/*.{mp4,webm}; do | |
# Check if the file exists | |
[ -e "$video" ] || continue | |
# Get the base name of the video (without extension) | |
base_name=$(basename "$video" .${video##*.}) | |
# Extract and resize frames using ffmpeg with GPU acceleration | |
ffmpeg -hwaccel cuda -i "$video" -vf "fps=5000,scale=224:224" "$OUTPUT_DIR/frame_%04d.png" | |
done | |