Saturday, February 26, 2022

My First macOS Shortcut - Split Video into 30s clips

 It all began with trying post videos in WhatsApps status. Each block in the status can have only 30s seconds but there is no apparently no way to split a video that is more than 30s long into segments in WhatsApp on the iPhone - not sure how it is in Android land. The very first I mainly split a video using iMovie on the phone, the second time on the Mac using iMovie again. However, my patience for this process ran out by the third time. So I went searching for an automated way to do this 30s split. FFMPEG to the rescue. A quick google search revealed some StackOverflow posts for splitting videos using FFMPEG. I copied the command out of one of the answers and edited it to have a duration of 30s instead of the original 20 minutes. 

ffmpeg -i input.mp4 -c copy -map 0 -segment_time 00:00:30 -f segment -reset_timestamps 1 output%03d.mp4

And with one easy command my video was split and saved into 30s video clips. 

I put this into a small shell script for future use https://github.com/eeshwar1/splitvideo 

And a macOS shortcut that allows you select a video and splits it. 

https://www.icloud.com/shortcuts/0b7d511f5e354aa79b294a7d73dc5876