diff --git a/app/pyProcessor/pyprocessor.py b/app/pyProcessor/pyprocessor.py index f2c9f567..e9eaca96 100644 --- a/app/pyProcessor/pyprocessor.py +++ b/app/pyProcessor/pyprocessor.py @@ -1,4 +1,5 @@ -import sys +#!/usr/bin/env python + import argparse # python2.7+ from pyAvTranscoder import avtranscoder as av diff --git a/app/pyThumbnail/pythumbnail.py b/app/pyThumbnail/pythumbnail.py index afd9148d..fbc70faa 100644 --- a/app/pyThumbnail/pythumbnail.py +++ b/app/pyThumbnail/pythumbnail.py @@ -1,23 +1,56 @@ -import argparse # python2.7+ +#!/usr/bin/env python from pyAvTranscoder import avtranscoder as av -# Create command-line interface -parser = argparse.ArgumentParser( - prog='pythumbnail', - description='''Generate jpeg thumbnail from video/image.''', -) - -# requirements -parser.add_argument('inputFileName', help='It could be any media file with at least one video stream (video, image...). Support file without extension.') -# options -parser.add_argument("-o", "--outputFile", dest="outputFileName", default="thumbnail.jpg", help="Set the output filename (thumbnail.jpg by default). Must be with jpg extension!") -parser.add_argument("-t", "--time", dest="time", type=float, default=0, help="Set time (in seconds) of where to seek in the video stream to generate the thumbnail (0 by default).") -parser.add_argument("-f", "--frame", dest="frame", type=int, default=0, help="Set time (in frames) of where to seek in the video stream to generate the thumbnail (0 by default). Warning: priority to frame if user indicates both frame and time!") -parser.add_argument("-w", "--width", dest="width", type=int, default=0, help="Override the width of the thumbnail (same as input by default).") -parser.add_argument("-he", "--height", dest="height", type=int, default=0, help="Override the height of the thumbnail (same as input by default).") -# Parse command-line -args = parser.parse_args() + +# Get command line arguments +args = [] +try: + # python2.7+ + import argparse + + # Create command-line interface + parser = argparse.ArgumentParser( + prog='pythumbnail', + description='''Generate jpeg thumbnail from video/image.''', + ) + + # requirements + parser.add_argument('inputFileName', help='It could be any media file with at least one video stream (video, image...). Support file without extension.') + # options + parser.add_argument("-o", "--outputFile", dest="outputFileName", default="thumbnail.jpg", help="Set the output filename (thumbnail.jpg by default). Must be with jpg extension!") + parser.add_argument("-t", "--time", dest="time", type=float, default=0, help="Set time (in seconds) of where to seek in the video stream to generate the thumbnail (0 by default).") + parser.add_argument("-f", "--frame", dest="frame", type=int, default=0, help="Set time (in frames) of where to seek in the video stream to generate the thumbnail (0 by default). Warning: priority to frame if user indicates both frame and time!") + parser.add_argument("-w", "--width", dest="width", type=int, default=0, help="Override the width of the thumbnail (same as input by default).") + parser.add_argument("-he", "--height", dest="height", type=int, default=0, help="Override the height of the thumbnail (same as input by default).") + # Parse command-line + args = parser.parse_args() + +except ImportError: + import optparse + + # Create command-line interface + parser = optparse.OptionParser( + usage='usage: %prog -i -t|-f