Skip to content

Instantly share code, notes, and snippets.

@vijayhardaha
Last active September 24, 2023 18:36
Show Gist options
  • Save vijayhardaha/a655079c0d6c0282686ad816601665d3 to your computer and use it in GitHub Desktop.
Save vijayhardaha/a655079c0d6c0282686ad816601665d3 to your computer and use it in GitHub Desktop.
Split a video into 30 seconds video for whatsapp video status

Split a Video into 30-Second Clips for WhatsApp Video Status

WhatsApp status updates are a popular way to share short video clips with your contacts. However, WhatsApp has a limitation where video status updates must be 30 seconds or less in duration. To make it easier to create these short video clips, you can use a simple bash script that splits a longer video into multiple 30-second segments.

Prerequisites

Before we dive into the script, ensure you have the following prerequisites:

  • A Linux or macOS system.
  • FFmpeg installed on your system. You can typically install it using your system's package manager.

The Video Splitting Script

The script below splits a video file named input.mp4 into 30-second segments named output-1.mp4, output-2.mp4, and so on, until the original video is fully split.

time=0
for i in {1..12}
do
    ffmpeg -i input.mp4 -ss $time -t 30 output-$i.mp4
    ((time = i * 30))
done

How to Use the Script

  1. Place the script code in a text editor and save it with a .sh extension, for example, split_video.sh.

  2. Open a terminal and navigate to the directory containing the script.

  3. Make the script executable by running the following command:

    chmod +x split_video.sh
  4. Place the video file you want to split in the same directory as the script and name it input.mp4.

  5. Run the script using the following command:

    ./split_video.sh
  6. The script will split the video into 30-second segments, and you'll find the resulting clips named as output-1.mp4, output-2.mp4, and so on.

  7. You can now use these segmented video clips as WhatsApp status updates without worrying about the 30-second duration limit.

Conclusion

This script simplifies the process of creating WhatsApp video status updates by automatically splitting a longer video into 30-second clips. It's a handy tool to have in your arsenal for sharing your favorite moments with friends and family through WhatsApp statuses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment