How to split a video every X minutes

imovievideo

How can I split a video every X minutes using iMovie or some other Mac software, outputting the split videos to a folder, named by section (e.g. "video1of4", "video2of4")?

Best Answer

Split a video with VLC from the command line

Open Terminal and run the following script:

It determines the length of the original file and splits it into 2 min intervals.

You can change this by changing the $interval variable, which is in seconds.

You will also need to change the $filename variable to whatever file you want to split.

#!/bin/bash
filename=test.mkv
duration=`ffprobe -show_format $filename | sed -n '/duration/s/.*=//p'`
duration=${duration/.*}
interval=120
start=0
n=$start
stop=$interval
while [ $duration -ge 0 ]; do
    /Applications/VLC.app/Contents/MacOS/VLC -Idummy $filename --start-time $start --stop-time $stop --sout=#file{dst=$n-out-$filename} vlc://quit
    let start=stop
    let stop=stop+interval
    let duration=duration-interval
    echo "Number of seconds left to process: $duration"
    let n=n+1
done