from __future__ import print_function
This commit is contained in:
parent
588bca3311
commit
4c30c356c7
2 changed files with 19 additions and 19 deletions
|
@ -2,7 +2,7 @@
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
# GPL 2014
|
# GPL 2014
|
||||||
|
|
||||||
from __future__ import division, with_statement
|
from __future__ import division, with_statement, print_function
|
||||||
|
|
||||||
import fractions
|
import fractions
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -18,7 +18,7 @@ for cmd in ('ffmpeg', 'avconv'):
|
||||||
FFMPEG = cmd
|
FFMPEG = cmd
|
||||||
break
|
break
|
||||||
if not FFMPEG:
|
if not FFMPEG:
|
||||||
print "could not find ffmpeg, make sure its installed and available in PATH"
|
print("could not find ffmpeg, make sure its installed and available in PATH")
|
||||||
FPS = 25
|
FPS = 25
|
||||||
|
|
||||||
class Video(object):
|
class Video(object):
|
||||||
|
@ -108,7 +108,7 @@ def video(path, height=96, info=None, framerate=FPS):
|
||||||
'-r', str(framerate),
|
'-r', str(framerate),
|
||||||
'-'
|
'-'
|
||||||
]
|
]
|
||||||
#print ' '.join(cmd)
|
#print(' '.join(cmd))
|
||||||
p = subprocess.Popen(cmd,
|
p = subprocess.Popen(cmd,
|
||||||
bufsize=bufsize,
|
bufsize=bufsize,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
|
@ -148,7 +148,7 @@ def audio(path, info=None, samplerate=48000, framerate=FPS):
|
||||||
'-f', 'wav',
|
'-f', 'wav',
|
||||||
'-'
|
'-'
|
||||||
]
|
]
|
||||||
#print ' '.join(cmd)
|
#print(' '.join(cmd))
|
||||||
p = subprocess.Popen(cmd,
|
p = subprocess.Popen(cmd,
|
||||||
bufsize=bufsize,
|
bufsize=bufsize,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
# GPL 2008-2014
|
# GPL 2008-2014
|
||||||
|
|
||||||
from __future__ import division, with_statement
|
from __future__ import division, with_statement, print_function
|
||||||
|
|
||||||
from glob import glob
|
from glob import glob
|
||||||
import Image
|
import Image
|
||||||
|
@ -166,7 +166,7 @@ class Timelines():
|
||||||
self.log and self.profiler.set_task('_video_callback()')
|
self.log and self.profiler.set_task('_video_callback()')
|
||||||
'''
|
'''
|
||||||
if timestamp != None and self.frame_i != int(round(timestamp * FPS)):
|
if timestamp != None and self.frame_i != int(round(timestamp * FPS)):
|
||||||
print 'WARNING: i is', self.frame_i, 'timestamp is', timestamp, '(', int(round(timestamp * FPS)), ')'
|
print('WARNING: i is', self.frame_i, 'timestamp is', timestamp, '(', int(round(timestamp * FPS)), ')')
|
||||||
'''
|
'''
|
||||||
self.is_last_frame = self.frame_i == self.frame_n - 1
|
self.is_last_frame = self.frame_i == self.frame_n - 1
|
||||||
large_tile_x = self.frame_i % self.large_tile_w
|
large_tile_x = self.frame_i % self.large_tile_w
|
||||||
|
@ -239,7 +239,7 @@ class Timelines():
|
||||||
try:
|
try:
|
||||||
self.large_tile_image['cuts'].putpixel((large_tile_x, y), rgb)
|
self.large_tile_image['cuts'].putpixel((large_tile_x, y), rgb)
|
||||||
except:
|
except:
|
||||||
print 'ERROR x y rgb', large_tile_x, y, rgb
|
print('ERROR x y rgb', large_tile_x, y, rgb)
|
||||||
self.previous_distance = distance
|
self.previous_distance = distance
|
||||||
self.previous_frame_data = frame_data
|
self.previous_frame_data = frame_data
|
||||||
# render keyframes tile
|
# render keyframes tile
|
||||||
|
@ -271,7 +271,7 @@ class Timelines():
|
||||||
frame_ratio = self.frame_ratio * wide
|
frame_ratio = self.frame_ratio * wide
|
||||||
cut_images = int(math.ceil(cut_width / (frame_ratio * self.large_tile_h)))
|
cut_images = int(math.ceil(cut_width / (frame_ratio * self.large_tile_h)))
|
||||||
if cut_images == 0:
|
if cut_images == 0:
|
||||||
print 'ERROR division by zero', cut_width, cut_images
|
print('ERROR division by zero', cut_width, cut_images)
|
||||||
index = -1
|
index = -1
|
||||||
image_widths = self._divide(cut_width, cut_images)
|
image_widths = self._divide(cut_width, cut_images)
|
||||||
image_i = self.cuts[-2]
|
image_i = self.cuts[-2]
|
||||||
|
@ -401,7 +401,7 @@ class Timelines():
|
||||||
)
|
)
|
||||||
self.full_tile_image.save(tile_file)
|
self.full_tile_image.save(tile_file)
|
||||||
if self.log:
|
if self.log:
|
||||||
print tile_file
|
print(tile_file)
|
||||||
if self.render_small_tiles:
|
if self.render_small_tiles:
|
||||||
resize = (self.full_tile_w, self.small_tile_h)
|
resize = (self.full_tile_w, self.small_tile_h)
|
||||||
self.full_tile_image = self.full_tile_image.resize(resize, Image.ANTIALIAS)
|
self.full_tile_image = self.full_tile_image.resize(resize, Image.ANTIALIAS)
|
||||||
|
@ -410,7 +410,7 @@ class Timelines():
|
||||||
)
|
)
|
||||||
self.full_tile_image.save(tile_file)
|
self.full_tile_image.save(tile_file)
|
||||||
if self.log:
|
if self.log:
|
||||||
print tile_file
|
print(tile_file)
|
||||||
self.log and self.profiler.unset_task()
|
self.log and self.profiler.unset_task()
|
||||||
|
|
||||||
def _save_tile(self, mode, index):
|
def _save_tile(self, mode, index):
|
||||||
|
@ -424,7 +424,7 @@ class Timelines():
|
||||||
)
|
)
|
||||||
self.large_tile_image[mode].save(tile_file)
|
self.large_tile_image[mode].save(tile_file)
|
||||||
if self.log:
|
if self.log:
|
||||||
print tile_file
|
print(tile_file)
|
||||||
if self.render_small_tiles and mode in ['antialias', 'slitscan', 'keyframeswide', 'audio']:
|
if self.render_small_tiles and mode in ['antialias', 'slitscan', 'keyframeswide', 'audio']:
|
||||||
small_mode = 'keyframes' if mode == 'keyframeswide' else mode
|
small_mode = 'keyframes' if mode == 'keyframeswide' else mode
|
||||||
small_tile_x = (index % 60) * 60
|
small_tile_x = (index % 60) * 60
|
||||||
|
@ -454,20 +454,20 @@ class Timelines():
|
||||||
)
|
)
|
||||||
self.small_tile_image[small_mode].save(tile_file)
|
self.small_tile_image[small_mode].save(tile_file)
|
||||||
if self.log:
|
if self.log:
|
||||||
print tile_file
|
print(tile_file)
|
||||||
self.log and self.profiler.unset_task()
|
self.log and self.profiler.unset_task()
|
||||||
|
|
||||||
def _done_callback(self, volume):
|
def _done_callback(self, volume):
|
||||||
if self.render_audio:
|
if self.render_audio:
|
||||||
volume = volume[:self.file_frame_n[self.video_i]]
|
volume = volume[:self.file_frame_n[self.video_i]]
|
||||||
if self.log and len(volume) < self.file_frame_n[self.video_i] - 1:
|
if self.log and len(volume) < self.file_frame_n[self.video_i] - 1:
|
||||||
print 'WARNING: Only got', len(volume), 'of', self.file_frame_n[self.video_i], 'audio samples.'
|
print('WARNING: Only got', len(volume), 'of', self.file_frame_n[self.video_i], 'audio samples.')
|
||||||
while len(volume) < self.file_frame_n[self.video_i]:
|
while len(volume) < self.file_frame_n[self.video_i]:
|
||||||
volume.append((0, 0))
|
volume.append((0, 0))
|
||||||
self.volume += volume
|
self.volume += volume
|
||||||
if self.render_video:
|
if self.render_video:
|
||||||
if self.log and self.frame_i - self.frame_offset < self.file_frame_n[self.video_i]:
|
if self.log and self.frame_i - self.frame_offset < self.file_frame_n[self.video_i]:
|
||||||
print 'WARNING: Only got', self.frame_i + 1 - self.frame_offset, 'of', self.file_frame_n[self.video_i], 'video samples.'
|
print('WARNING: Only got', self.frame_i + 1 - self.frame_offset, 'of', self.file_frame_n[self.video_i], 'video samples.')
|
||||||
while self.frame_i - self.frame_offset < self.file_frame_n[self.video_i]:
|
while self.frame_i - self.frame_offset < self.file_frame_n[self.video_i]:
|
||||||
self._video_callback(
|
self._video_callback(
|
||||||
Image.new('RGB', (self.frame_w, self.large_tile_h)), None
|
Image.new('RGB', (self.frame_w, self.large_tile_h)), None
|
||||||
|
@ -498,14 +498,14 @@ class Timelines():
|
||||||
length = self.cuts[i] - self.cuts[i - 1]
|
length = self.cuts[i] - self.cuts[i - 1]
|
||||||
if length > maximum:
|
if length > maximum:
|
||||||
maximum = length
|
maximum = length
|
||||||
print 'Number of frames:', self.frame_n
|
print('Number of frames:', self.frame_n)
|
||||||
print 'Number of cuts:', len(self.cuts) - 2
|
print('Number of cuts:', len(self.cuts) - 2)
|
||||||
print 'Most frames per cut:', maximum
|
print('Most frames per cut:', maximum)
|
||||||
for task in self.profiler.get_profile():
|
for task in self.profiler.get_profile():
|
||||||
print '%10.6f sec/hr' % (task['time'] / self.frame_n * 90000), task['task']
|
print('%10.6f sec/hr' % (task['time'] / self.frame_n * 90000), task['task'])
|
||||||
files = filter(lambda x: x.endswith('.jpg'), os.listdir(self.tile_path))
|
files = filter(lambda x: x.endswith('.jpg'), os.listdir(self.tile_path))
|
||||||
size = sum(map(lambda x: os.path.getsize(self.tile_path + x), files))
|
size = sum(map(lambda x: os.path.getsize(self.tile_path + x), files))
|
||||||
print '%10.6f MB/hr' % (size / self.frame_n * 90000 / 1000000), 'timeline tiles'
|
print('%10.6f MB/hr' % (size / self.frame_n * 90000 / 1000000), 'timeline tiles')
|
||||||
|
|
||||||
|
|
||||||
class Profiler():
|
class Profiler():
|
||||||
|
|
Loading…
Reference in a new issue