def parse_options(): parser = argparse.ArgumentParser( description="Splits a video into chunks of length L as specified by the user and saves them to output/name", usage="%(prog)s [-h] [-v] [Filename] [length] [-o offset] [-l limit]\n*Logs generated to log.txt * ", formatter_class=argparse.RawDescriptionHelpFormatter, epilog=listVideoFiles(), ) parser.add_argument("filename", metavar="v", nargs="?", default=None, help="the video to split") parser.add_argument("length", metavar="length", nargs="?", default=10, help="the length for each chunk") parser.add_argument( "-o", "--offset", type=int, required=False, default=0, help="the seconds to offset the clip trimming" ) parser.add_argument("-l", "--limit", dest="limit", type=int, required=False, help="the max number of clips") parser.add_argument( "-v", "--verbose", action="store_true", required=False, default=False, help="Displays all the output videos and exits if True", ) args = parser.parse_args() print args video = args.filename length = int(args.length) offset = int(args.offset) limit = args.limit if not video: print ("ERROR: Did not input value for video name") print listVideoFiles() exit() else: videoPath = INPUT_FOLDER + video if not os.path.isfile(videoPath): print ("ERROR: File '%s' is not on path '%s'" % (video, INPUT_FOLDER)) print listVideoFiles() exit() if args.verbose: print listOutputVideoFiles() exit() if limit: limit = int(limit) return video, length, offset, limit
def parse_cmd_options(): parser = argparse.ArgumentParser( description="Dynamically creates a supercut from a video and subtitle pairing\nwhere the keyword(s) of interest are spoken", usage="%(prog)s [-h] [-v] [-p | -w | -s] [videoName] [keywords]", formatter_class=argparse.RawDescriptionHelpFormatter, epilog=listVideoFiles(), ) parser.add_argument("filename", metavar="video", nargs="?", default=None, help="The video to process") parser.add_argument("keywords", nargs="+", default=["the"], help="The words to find in the video") parser.add_argument( "-v", "--verbose", action="store_true", required=False, default=False, help="Displays the phrases that contain the keyword(s) if True", ) group = parser.add_mutually_exclusive_group() group.add_argument( "-p", "--phrase", action="store_true", required=False, default=False, help="Captures the entire phrase" ) group.add_argument( "-w", "--word", action="store_true", required=False, default=False, help="Refines the bounds to include just the word", ) group.add_argument( "-s", "--speech", action="store_true", required=False, default=False, help="Creates a fake speech from the keywords", ) args = parser.parse_args() print args global VERBOSE global WORDS global MODE_NAME videoName = args.filename WORDS = args.keywords options = [args.phrase, args.word, args.speech] # Check if input arguments are valid # valid = testUserInput(videoName) if not valid: print "Try a video file from the list [%s] " % listVideoFiles() exit() # End input validation # # Handling Options # VERBOSE = args.verbose if True in options: MODE = options.index(True) else: MODE = 0 optionNames = ["phrases", "words", "speech"] MODE_NAME = optionNames[MODE] print "Finding the words: %s\nVideo Name: %s\nOption: %s" % (WORDS, videoName, MODE_NAME) # End Handling Options # return videoName, WORDS, MODE_NAME