Skip to content

Commit

Permalink
Merge pull request #199 from cchampet/fix_pythonAppsPython2.6
Browse files Browse the repository at this point in the history
Fix python apps - python2.6
  • Loading branch information
valnoel committed Jun 8, 2015
2 parents c5e936f + 80e971c commit 1668097
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 18 deletions.
3 changes: 2 additions & 1 deletion app/pyProcessor/pyprocessor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
#!/usr/bin/env python

import argparse # python2.7+

from pyAvTranscoder import avtranscoder as av
Expand Down
67 changes: 50 additions & 17 deletions app/pyThumbnail/pythumbnail.py
Original file line number Diff line number Diff line change
@@ -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 <file> -t|-f <time> [options]',
prog='pythumbnail',
description='''Generate jpeg thumbnail from video/image.''',
)

# requirements
parser.add_option("-i", "--inputFile", dest='inputFileName', help='It could be any media file with at least one video stream (video, image...). Support file without extension.')
# options
parser.add_option("-o", "--outputFile", dest="outputFileName", default="thumbnail.jpg", help="Set the output filename (thumbnail.jpg by default). Must be with jpg extension!")
parser.add_option("-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_option("-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_option("-w", "--width", dest="width", type="int", default=0, help="Override the width of the thumbnail (same as input by default).")
parser.add_option("--height", dest="height", type="int", default=0, help="Override the height of the thumbnail (same as input by default).")
# Parse command-line
args, other = parser.parse_args()

if args.inputFileName is None:
print "An input file is required. Use -i / --inputFile."
exit(1)


# setup avtranscoder
logger = av.Logger().setLogLevel(av.AV_LOG_QUIET)
Expand Down

0 comments on commit 1668097

Please sign in to comment.