#!/bin/bash # Check if a file was dragged and dropped onto the script if [ -z "$1" ]; then echo "Drag and drop a video file onto this script to split it into segments." read -p "Press [Enter] key to continue..." exit 1 fi # Prompt the user for the segment time in seconds read -p "Time in seconds per segment: " time # Set input file and output folder variables input_file="$1" output_folder="${input_file%.*}_segments" # Create the output folder mkdir -p "$output_folder" # Split the video into segments using ffmpeg ffmpeg -i "$input_file" -force_key_frames "expr:gte(t,n_forced*5)" -c copy -f segment -segment_time "$time" -reset_timestamps 1 -copyts "$output_folder/segment_%03d.mp4" # Change to the output folder cd "$output_folder" # Create a file list for the segments and move each segment to its own folder counter=0 for segment in segment_*.mp4; do segment_folder="segment_$counter" mkdir -p "$segment_folder" mv "$segment" "$segment_folder/" echo "file '$segment_folder/$segment'" >> file_list.txt counter=$((counter + 1)) done echo "Video has been split into segments." read -p "Press [Enter] key to continue..."