Skip to content

Instantly share code, notes, and snippets.

@maxfire2008
Created July 6, 2021 06:06
Show Gist options
  • Save maxfire2008/ce9d2d05bc499ba05fed5621b22b0e55 to your computer and use it in GitHub Desktop.
Save maxfire2008/ce9d2d05bc499ba05fed5621b22b0e55 to your computer and use it in GitHub Desktop.
Split File based on DVD chapters
import os
filetosplit = input("File To Split: >>") # Input file such as "FullMovie.mp3"
listOfTimes = open(input("times file: >>"),"rb").read().decode().split("\n") # List of times from DVD Decrypter > Information File > Chapter - OGG
zeroPadding = int(input("How much to pad with zeros: >>")) # 2 = 03, 5 = 00003 etc
def padZeros(x,p):
return ((p-len(str(x)))*"0")+str(x)
times = []
for i in range(len(listOfTimes)):
try:
if not listOfTimes[i].split("=")[0].endswith("NAME"):
times.append(listOfTimes[i].split("=")[1])
except Exception as e:
print(e,"while handling",i)
chapters = []
for i in range(len(times)):
if i+1 != len(times):
chapters.append([times[i],times[i+1]])
else:
chapters.append([times[i]])
for c in range(len(chapters)):
if len(chapters[c]) == 2:
os.system("ffmpeg -i "+filetosplit+" -acodec copy -ss "+chapters[c][0]+" -to "+chapters[c][1]+" "+padZeros(c+1,zeroPadding)+"."+filetosplit.split(".")[-1])
else:
os.system("ffmpeg -i "+filetosplit+" -acodec copy -ss "+chapters[c][0]+" "+padZeros(c+1,zeroPadding)+"."+filetosplit.split(".")[-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment