def begining_ending_block_old(self, start): """ Method to make a block starting from the begining of the file to the current position or from the current position to the end of the file Arguments: start: Boolean - if True, then the block is from the begining to the current position, if False - from the current position to the end of the file """ try: if self.current_mark: sounds.error_sound(self.volume) self.log( 'tried to use B or E while an existing block was current - beginning_ending_block()' ) self.print_to_screen('Overlap with an existing block') else: mark = Mark(position=self.song.get_position()) if not self.check_for_overlap(self.song.get_position()): if start: mark.start = 0 mark.end = self.song.get_position() else: mark.start = self.song.get_position() mark.end = 1 self.state.marks.append(mark) self.state.marks = sorted(self.state.marks, key=itemgetter('start')) self.markItr += 1 self.print_to_screen('saved') self.write_state_information() else: self.log( 'Tried to use B or E and found an overlap with exisitng block' ) self.print_to_screen('Overlap with an existing block') except Exception as ex: self.log(ex)
def begining_ending_block(self, start): """ Method to make a block starting from the begining of the file to the current position or from the current position to the end of the file Arguments: start: Boolean - if True, then the block is from the begining to the current position, if False - from the current position to the end of the file """ try: if self.current_mark: self.print_to_screen('There is unfinished block') else: mark = Mark(position=self.song.get_position()) if start: mark.start = 0 else: mark.end = 1 self.overwriteOverlaps(mark) self.state.marks = sorted(self.state.marks, key=itemgetter('start')) self.markItr += 1 self.print_to_screen('saved') self.write_state_information() except Exception as ex: self.log(ex)
def applyEdits(self, local_marks): """ Method to create the final command for editing the original file. """ self.song.stop() self.check_for_null_blocks() # filename, file_extension = os.path.splitext(self.original_file) # edited_file = filename + "-edited" + file_extension # edited_file = self.old_file_name command = ['ffmpeg', '-i', self.original_file] select = "select='" aselect = "aselect='" # this reorganizes the marks to represent the blocks between the 'removed' # blocks last = 0 for each in local_marks: self.log(each) temp = each.end each.end = each.start each.start = last last = temp n = Mark() n.start = last n.end = 1 local_marks.append(n) # filter all the ones where start and end are equal local_marks = list( filter(lambda item: item.start != item.end, local_marks)) for i, each in enumerate(local_marks): if i == 0: select += """between(t,{},{})""".format( (self.mark_to_milliseconds(each.start) / 1000), (self.mark_to_milliseconds(each.end) / 1000), ) aselect += """between(t,{},{})""".format( (self.mark_to_milliseconds(each.start) / 1000), (self.mark_to_milliseconds(each.end) / 1000), ) else: select += """+between(t,{},{})""".format( (self.mark_to_milliseconds(each.start) / 1000), (self.mark_to_milliseconds(each.end) / 1000), ) aselect += """+between(t,{},{})""".format( (self.mark_to_milliseconds(each.start) / 1000), (self.mark_to_milliseconds(each.end) / 1000), ) select += """',setpts=N/FRAME_RATE/TB """ aselect += """',asetpts=N/SR/TB""" command.append('-vf') command.append(select) command.append('-af') command.append(aselect) command.append(self.output_file_name) self.log(command) return command