Skip to content

Fix python apps - python2.6 #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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