Skip to content

Commit 1668097

Browse files
committed
Merge pull request #199 from cchampet/fix_pythonAppsPython2.6
Fix python apps - python2.6
2 parents c5e936f + 80e971c commit 1668097

File tree

2 files changed

+52
-18
lines changed

2 files changed

+52
-18
lines changed

app/pyProcessor/pyprocessor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import sys
1+
#!/usr/bin/env python
2+
23
import argparse # python2.7+
34

45
from pyAvTranscoder import avtranscoder as av

app/pyThumbnail/pythumbnail.py

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,56 @@
1-
import argparse # python2.7+
1+
#!/usr/bin/env python
22

33
from pyAvTranscoder import avtranscoder as av
44

5-
# Create command-line interface
6-
parser = argparse.ArgumentParser(
7-
prog='pythumbnail',
8-
description='''Generate jpeg thumbnail from video/image.''',
9-
)
10-
11-
# requirements
12-
parser.add_argument('inputFileName', help='It could be any media file with at least one video stream (video, image...). Support file without extension.')
13-
# options
14-
parser.add_argument("-o", "--outputFile", dest="outputFileName", default="thumbnail.jpg", help="Set the output filename (thumbnail.jpg by default). Must be with jpg extension!")
15-
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).")
16-
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!")
17-
parser.add_argument("-w", "--width", dest="width", type=int, default=0, help="Override the width of the thumbnail (same as input by default).")
18-
parser.add_argument("-he", "--height", dest="height", type=int, default=0, help="Override the height of the thumbnail (same as input by default).")
19-
# Parse command-line
20-
args = parser.parse_args()
5+
6+
# Get command line arguments
7+
args = []
8+
try:
9+
# python2.7+
10+
import argparse
11+
12+
# Create command-line interface
13+
parser = argparse.ArgumentParser(
14+
prog='pythumbnail',
15+
description='''Generate jpeg thumbnail from video/image.''',
16+
)
17+
18+
# requirements
19+
parser.add_argument('inputFileName', help='It could be any media file with at least one video stream (video, image...). Support file without extension.')
20+
# options
21+
parser.add_argument("-o", "--outputFile", dest="outputFileName", default="thumbnail.jpg", help="Set the output filename (thumbnail.jpg by default). Must be with jpg extension!")
22+
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).")
23+
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!")
24+
parser.add_argument("-w", "--width", dest="width", type=int, default=0, help="Override the width of the thumbnail (same as input by default).")
25+
parser.add_argument("-he", "--height", dest="height", type=int, default=0, help="Override the height of the thumbnail (same as input by default).")
26+
# Parse command-line
27+
args = parser.parse_args()
28+
29+
except ImportError:
30+
import optparse
31+
32+
# Create command-line interface
33+
parser = optparse.OptionParser(
34+
usage='usage: %prog -i <file> -t|-f <time> [options]',
35+
prog='pythumbnail',
36+
description='''Generate jpeg thumbnail from video/image.''',
37+
)
38+
39+
# requirements
40+
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.')
41+
# options
42+
parser.add_option("-o", "--outputFile", dest="outputFileName", default="thumbnail.jpg", help="Set the output filename (thumbnail.jpg by default). Must be with jpg extension!")
43+
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).")
44+
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!")
45+
parser.add_option("-w", "--width", dest="width", type="int", default=0, help="Override the width of the thumbnail (same as input by default).")
46+
parser.add_option("--height", dest="height", type="int", default=0, help="Override the height of the thumbnail (same as input by default).")
47+
# Parse command-line
48+
args, other = parser.parse_args()
49+
50+
if args.inputFileName is None:
51+
print "An input file is required. Use -i / --inputFile."
52+
exit(1)
53+
2154

2255
# setup avtranscoder
2356
logger = av.Logger().setLogLevel(av.AV_LOG_QUIET)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy