Skip to content

Instantly share code, notes, and snippets.

@heitara
Created July 21, 2016 08:23
Show Gist options
  • Save heitara/6e85026ef6615f55bc44ed91547fba3c to your computer and use it in GitHub Desktop.
Save heitara/6e85026ef6615f55bc44ed91547fba3c to your computer and use it in GitHub Desktop.
MP3 Splitter using ffmpeg
#!/bin/bash
#slice mp3 file to 30 sec or less starting from the passed begginning
if [ "$#" -eq 2 ] && [ -n "$1" ]
then
DURATION=30
ffmpeg -ss $2 -i "$1" -t $DURATION -acodec copy "$1.output.mp3"
else
echo
echo
if [ "$#" -ne 2 ]; then
echo "Number of arguments doesn't match!"
fi
echo "Usage:";
echo "$0 <mp3-file> <stating-second>";
echo "The output file will be named <mp3-file>.output.mp3"
echo "For example:";
echo "$0 path/to/file.mp3 42";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment