diff --git a/oxtimelines/ffmpeg.py b/oxtimelines/ffmpeg.py index b07a24e..23e4cc4 100644 --- a/oxtimelines/ffmpeg.py +++ b/oxtimelines/ffmpeg.py @@ -2,7 +2,7 @@ # vi:si:et:sw=4:sts=4:ts=4 # GPL 2014 -from __future__ import division, with_statement +from __future__ import division, with_statement, print_function import fractions import subprocess @@ -18,7 +18,7 @@ for cmd in ('ffmpeg', 'avconv'): FFMPEG = cmd break 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 class Video(object): @@ -108,7 +108,7 @@ def video(path, height=96, info=None, framerate=FPS): '-r', str(framerate), '-' ] - #print ' '.join(cmd) + #print(' '.join(cmd)) p = subprocess.Popen(cmd, bufsize=bufsize, stdout=subprocess.PIPE, @@ -148,7 +148,7 @@ def audio(path, info=None, samplerate=48000, framerate=FPS): '-f', 'wav', '-' ] - #print ' '.join(cmd) + #print(' '.join(cmd)) p = subprocess.Popen(cmd, bufsize=bufsize, stdout=subprocess.PIPE, diff --git a/oxtimelines/timeline.py b/oxtimelines/timeline.py index 286a5b8..a56319e 100644 --- a/oxtimelines/timeline.py +++ b/oxtimelines/timeline.py @@ -2,7 +2,7 @@ # vi:si:et:sw=4:sts=4:ts=4 # GPL 2008-2014 -from __future__ import division, with_statement +from __future__ import division, with_statement, print_function from glob import glob import Image @@ -166,7 +166,7 @@ class Timelines(): self.log and self.profiler.set_task('_video_callback()') ''' 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 large_tile_x = self.frame_i % self.large_tile_w @@ -239,7 +239,7 @@ class Timelines(): try: self.large_tile_image['cuts'].putpixel((large_tile_x, y), rgb) 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_frame_data = frame_data # render keyframes tile @@ -271,7 +271,7 @@ class Timelines(): frame_ratio = self.frame_ratio * wide cut_images = int(math.ceil(cut_width / (frame_ratio * self.large_tile_h))) if cut_images == 0: - print 'ERROR division by zero', cut_width, cut_images + print('ERROR division by zero', cut_width, cut_images) index = -1 image_widths = self._divide(cut_width, cut_images) image_i = self.cuts[-2] @@ -401,7 +401,7 @@ class Timelines(): ) self.full_tile_image.save(tile_file) if self.log: - print tile_file + print(tile_file) if self.render_small_tiles: resize = (self.full_tile_w, self.small_tile_h) 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) if self.log: - print tile_file + print(tile_file) self.log and self.profiler.unset_task() def _save_tile(self, mode, index): @@ -424,7 +424,7 @@ class Timelines(): ) self.large_tile_image[mode].save(tile_file) if self.log: - print tile_file + print(tile_file) if self.render_small_tiles and mode in ['antialias', 'slitscan', 'keyframeswide', 'audio']: small_mode = 'keyframes' if mode == 'keyframeswide' else mode small_tile_x = (index % 60) * 60 @@ -454,20 +454,20 @@ class Timelines(): ) self.small_tile_image[small_mode].save(tile_file) if self.log: - print tile_file + print(tile_file) self.log and self.profiler.unset_task() def _done_callback(self, volume): if self.render_audio: volume = volume[:self.file_frame_n[self.video_i]] 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]: volume.append((0, 0)) self.volume += volume if self.render_video: 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]: self._video_callback( 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] if length > maximum: maximum = length - print 'Number of frames:', self.frame_n - print 'Number of cuts:', len(self.cuts) - 2 - print 'Most frames per cut:', maximum + print('Number of frames:', self.frame_n) + print('Number of cuts:', len(self.cuts) - 2) + print('Most frames per cut:', maximum) 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)) 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():