Skip to content

Instantly share code, notes, and snippets.

@ptrv
Created November 22, 2015 21:47
Show Gist options
  • Save ptrv/c3ae653bd5b031a35a02 to your computer and use it in GitHub Desktop.
Save ptrv/c3ae653bd5b031a35a02 to your computer and use it in GitHub Desktop.
split audio file into multiple pieces
import sys
import subprocess
input_file = sys.argv[1]
seconds = sys.argv[2]
num_pieces = sys.argv[3]
for i in range(num_pieces):
num = i * seconds
output = "output/{0}.wav".format(i)
s = ["ffmpeg", "-i", str(input_file), "-ss", str(num), "-t", str(seconds), "-acodec", "copy", output]
subprocess.call(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment