1

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")?

3

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
  • This script has been tested with vlc 1.1.3 and 2.2.1 – Deesbek Nov 15 '13 at 16:17
  • Thank you! this is about to be my favorite thing ever! One quick question, why are the split files all slightly different lengths? They vary about 4-10 seconds? (I have interval set to 180 which I thought would be 3min each, however, on average they are all closer to 4min long) – trying_hal9000 May 25 '18 at 9:48
  • 1
    Hey would there be a way to modify this script so that it would split the interval time (say 2minutes) and then skip 5minutes forward before spliting the next 2minutes? So split 2min, skip 5min, split 2min, skip 5min, split 2min, so on and so forth? many thanks! – trying_hal9000 May 25 '18 at 10:57
  • @trying_hal9000 I'll work on adding the 5 min skip for you, I'm not sure why the splits would all be different lengths, obviously wrote this 5 years ago so would have to do some testing for you - glad you like the script. – Deesbek May 31 '18 at 8:01
2

QuickTime Pro does a great job using the Trim feature. It's intuitive too.

2

You can also use -f segment with ffmpeg:

ffmpeg -i input.mp4 -c copy -f segment -segment_time 300 -reset_timestamps 1 %03d.mp4

-c copy disables re-encoding video and audio, like -vcodec copy -acodec copy. -reset_timestamps 1 makes each segment start with a near-zero timestamp.

0

VLC has an "Exporting Wizard" that will let you subset. VLC also has a CLI interface so you should be able to automate it.

  • 3
    More content, such as actual instructions of the GUI and/or CLI interface, would be grand. – Jason Salaz Jul 22 '11 at 2:48
0

I used to do splits using ffmpeg on Fedora . I don't have the exact command handy though.

You could install ffmpeg and mplayer tools on OS X .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .