ffmpeg -i input.mp4 -map 0 -c copy -f segment -segment_time 120 -reset_timestamps 1 out%02d.mp4
...will create files along the lines of 'out01.mp4 'out02.mp4', each one being 120 seconds in duration (except the last one, which may be shorter). Note that it has to split up the file on a keyframe, so you won't get 100% accurate splitting. See the segment documentation.
If you're willing to re-encode, you can get accurate splitting using -force_key_frames. To force a key frame every 120 seconds and split using segment:
ffmpeg -i input.mp4 -map 0 -c:v libx264 -preset veryfast -crf 22 -c:a libfdk_aac -vbr 3 \
-force_key_frames expr:gte(t,n_forced*120) -f segment -segment_time 120 -reset_timestamps 1 out%02d.mp4
Alternatively, you can use -g to set the GOP size - this requires you to know the frame rate of your video. If your video has a frame rate of 25 fps, then a GOP of 120*25=3000 would get one keyframe every two minutes; obviously, this is too few! Reducing it to 300 will be more reasonable, and will give you keyframes on the places you need:
ffmpeg -i input.mp4 -map 0 -c:v libx264 -preset veryfast -crf 22 -c:a libfdk_aac -vbr 3 \
-g 300 -f segment -segment_time 120 -reset_timestamps 1 out%02d.mp4
The specific codecs your version of ffmpeg supports may be different to mine (you won't have libfdk_aac unless you compiled from source).
${infile/.mpg/.$((i/120)).mpg}? – DocWiki Jul 08 '11 at 23:16.mpg, that should produce output files namedinfile.0.mpg infile.1.mpg infile.2.mpg ...– blahdiblah Jul 08 '11 at 23:36ffmpegreveals that the$?condition isn't going to hit anyways becauseffmpegdoesn't care if-ssis out of range. Changing the exit condition based on finding the length of the video or that output files aren't empty is left as an exercise for the reader. – blahdiblah Jul 09 '11 at 00:00ffmpeg -i ${1} 2>&1 | grep "Duration" | cut -d ' ' -f 4 | sed s/,// | cut -d ":" -f 2– DocWiki Jul 09 '11 at 00:36