Parallelism opt is now optional, bug fix for output path
This commit is contained in:
23
generator
23
generator
@@ -3,20 +3,20 @@
|
|||||||
"""Video Thumbnail Generator
|
"""Video Thumbnail Generator
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
./generator <video> <interval> <width> <height> <columns> <output> <parallelism>
|
./generator <video> <interval> <width> <height> <columns> <output> [<parallelism>]
|
||||||
./generator (-h | --help)
|
./generator (-h | --help)
|
||||||
./generator --version
|
./generator --version
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h --help Show this screen.
|
-h --help Show this screen.
|
||||||
--version Show version.
|
--version Show version.
|
||||||
<video> Video filepath.
|
<video> Video filepath.
|
||||||
<interval> Interval em seconds between frames.
|
<interval> Interval em seconds between frames.
|
||||||
<width> Width of each thumbnail.
|
<width> Width of each thumbnail.
|
||||||
<height> Height of each thumbnail.
|
<height> Height of each thumbnail.
|
||||||
<columns> Total number of thumbnails per line.
|
<columns> Total number of thumbnails per line.
|
||||||
<output> Output.
|
<output> Output.
|
||||||
<parallelism> Number of files to process in parallel
|
[<parallelism>] Number of files to process in parallel.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from docopt import docopt
|
from docopt import docopt
|
||||||
@@ -43,7 +43,7 @@ def generate_video_thumbnails(args):
|
|||||||
size = (int(args['<width>']), int(args['<height>']))
|
size = (int(args['<width>']), int(args['<height>']))
|
||||||
columns = int(args['<columns>'])
|
columns = int(args['<columns>'])
|
||||||
output_path = args['<output>']
|
output_path = args['<output>']
|
||||||
parallelism = args.get('<parallelism>', cpu_count()*2-1)
|
parallelism = args.get('[<parallelism>]', cpu_count()*2-1)
|
||||||
|
|
||||||
work_units = []
|
work_units = []
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ def generate_video_thumbnails(args):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Strip seperator so contructing output is uniform
|
# Strip seperator so contructing output is uniform
|
||||||
output_path = output_path.strip(os.sep)
|
output_path = output_path.rstrip(os.sep)
|
||||||
|
|
||||||
# Add all files in directory for processing
|
# Add all files in directory for processing
|
||||||
for file_name in os.listdir(input_path):
|
for file_name in os.listdir(input_path):
|
||||||
@@ -65,13 +65,10 @@ def generate_video_thumbnails(args):
|
|||||||
if os.path.isfile(file_path):
|
if os.path.isfile(file_path):
|
||||||
# Construct output path for thumbnail using
|
# Construct output path for thumbnail using
|
||||||
# the video files filename
|
# the video files filename
|
||||||
single_output_path = \
|
single_output_path = os.path.join(
|
||||||
"{output_path}{seperator}{file_name}.png". \
|
output_path, os.path.basename(file_path) + ".png"
|
||||||
format(
|
)
|
||||||
output_path=output_path,
|
|
||||||
seperator=os.sep,
|
|
||||||
file_name=os.path.basename(file_path)
|
|
||||||
)
|
|
||||||
work_units.append((file_path, single_output_path,
|
work_units.append((file_path, single_output_path,
|
||||||
interval, size, columns,))
|
interval, size, columns,))
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user