Exemplo n.º 1
0
 def create(self, arguments={}, invert=False):
     from maskgen.zip_tools import AudioPositions
     from maskgen.tool_set import getMilliSecondsAndFrameCount
     from maskgen.video_tools import FileMetaDataLocator, \
         create_segment
     fps = float(getValue(arguments, 'sample rate', 0))
     # use AudioPostions to determine duration and rate
     positions = AudioPositions(FileMetaDataLocator(
         self.startFileName).get_filename(),
                                fps=fps)
     duration = positions.get_total_duration()
     rate = positions.fps
     end_time_tuple = getMilliSecondsAndFrameCount(
         getValue(arguments, 'End Time', "00:00:00"))
     start_time_tuple = getMilliSecondsAndFrameCount(
         getValue(arguments, 'Start Time', '00:00:00'))
     if end_time_tuple[0] <= start_time_tuple[0]:
         end_time_tuple = (duration, 0)
     return [
         create_segment(
             starttime=float(start_time_tuple[0]),
             startframe=int(start_time_tuple[0] * rate / 1000.0) + 1,
             endtime=float(end_time_tuple[0]),
             endframe=int(end_time_tuple[0] * rate / 1000.0) + 1,
             type='audio',
             rate=rate)
     ]
Exemplo n.º 2
0
def transform(img, source, target, **kwargs):
    if 'Final Media' in kwargs:
        shutil.copy(kwargs['Final Media'], target)
        mask_set = FileMetaDataLocator(
            kwargs['donor']).getMaskSetForEntireVideo(media_types=['audio'])
        return {
            'rename_target': os.path.split(kwargs['Final Media'])[1],
            'startframe': mask_set[0]['startframe'],
            'endframe': mask_set[0]['endframe']
        }, None
    else:
        return None, None
Exemplo n.º 3
0
 def create(self, arguments={}, invert=False):
     from maskgen.video_tools import getMaskSetForEntireVideoForTuples, FileMetaDataLocator
     from maskgen.tool_set import getMilliSecondsAndFrameCount
     end_time_tuple = getMilliSecondsAndFrameCount(
         getValue(arguments, 'End Time', "00:00:00"))
     start_time_tuple = getMilliSecondsAndFrameCount(
         getValue(arguments, 'Start Time', '00:00:00'))
     return getMaskSetForEntireVideoForTuples(
         FileMetaDataLocator(self.startFileName),
         start_time_tuple=start_time_tuple,
         end_time_tuple=end_time_tuple if end_time_tuple[0] > 0 else None,
         media_types=self.media_types())
Exemplo n.º 4
0
    def create(self, arguments={}, invert=False):
        from maskgen.tool_set import getMilliSecondsAndFrameCount
        media_types = ['video', 'audio'] if getValue(
            arguments, 'include audio', 'no') == 'yes' else ['video']

        from maskgen.video_tools import FileMetaDataLocator
        end_time_tuple = getMilliSecondsAndFrameCount(
            getValue(arguments, 'End Time', "00:00:00"))
        start_time_tuple = getMilliSecondsAndFrameCount(
            getValue(arguments, 'Start Time', '00:00:00'))
        video_set = FileMetaDataLocator(
            self.startFileName).getMaskSetForEntireVideoForTuples(
                start_time_tuple=start_time_tuple,
                end_time_tuple=end_time_tuple
                if end_time_tuple[1] > start_time_tuple[1] else None,
                media_types=media_types)
        audio_segments = [
            x for x in video_set if get_type_of_segment(x) == 'audio'
        ]
        video_segments = [
            x for x in video_set if get_type_of_segment(x) == 'video'
        ]

        if getValue(arguments, 'include audio', 'no') == 'yes':
            for audio_segment in audio_segments:
                video_segment = video_segments[0] if len(
                    video_segments) > 0 else audio_segment
                update_segment(
                    audio_segment,
                    type='audio',
                    starttime=get_start_time_from_segment(video_segment),
                    endtime=get_end_time_from_segment(video_segment),
                    startframe=int(
                        get_start_time_from_segment(video_segment) *
                        get_rate_from_segment(audio_segment) / 1000.0),
                    endframe=int(
                        get_end_time_from_segment(video_segment) *
                        get_rate_from_segment(audio_segment) / 1000.0) + 1)
        return video_set
Exemplo n.º 5
0
 def __init__(self, filename):
     FileMetaDataLocator.__init__(self, filename)