123456789101112131415161718192021222324252627282930313233 |
- import os
- def argsProcessor():
- import argparse
- parser = argparse.ArgumentParser()
- parser.add_argument("-d", "--dataPath", help="path to main data folder")
- parser.add_argument("-o", "--outputPath", help="output data")
- return parser.parse_args()
- if __name__ == '__main__':
- args = argsProcessor()
- dir = args.dataPath
- output = args.outputPath
- if (not os.path.isdir(output)):
- os.mkdir(output)
- for folder in os.listdir(dir):
- if os.path.isdir(dir + "/" + folder):
- dir_temp = dir+ "/" + folder + "/"
- for file in os.listdir(dir_temp):
- from subprocess import call
- if (file.endswith(".avi")):
- os.mkdir(output + "/" + folder)
- if (os.path.isdir(output + "/" + folder + "/" + file)):
- print("Folder already exist")
- else:
- call("cd " + output + "/" + folder + " && mkdir " + file, shell=True)
- location = dir + "/" + folder + "/" + file
- command = "ffmpeg -i " + location + " " + output + "/" + folder + "/" + file + "/%3d.jpg"
- # print(command)
- call(command, shell=True)
- print(file + "done!")
|