def missingVideo(scModel):
    import copy
    """
    :param scModel:
    :return:
    @type scModel: ImageProjectModel
    """
    for edge in scModel.getGraph().get_edges():
        currentLink = scModel.getGraph().get_edge(edge[0], edge[1])
        successors = scModel.getGraph().successors(edge[1])
        predecessors = scModel.getGraph().predecessors(edge[1])
        if currentLink['op'] == 'AddAudioSample':
            sourceim, source = scModel.getGraph().get_image(edge[0])
            im, dest = scModel.getGraph().get_image(edge[1])
            sourcemetadata = ffmpeg_api.get_meta_from_video(source, show_streams=True)[0]
            destmetadata = ffmpeg_api.get_meta_from_video(dest, show_streams=True)[0]
            if len(sourcemetadata) > 0:
                sourcevidcount = len([idx for idx, val in enumerate(sourcemetadata) if val['codec_type'] != 'audio'])
            if len(destmetadata) > 0:
                destvidcount = len([x for x in (idx for idx, val in enumerate(destmetadata) if val['codec_type'] != 'audio')])
            if sourcevidcount != destvidcount:
                if not isSuccessor(scModel, successors, edge[1], ['AntiForensicCopyExif', 'OutputMP4', 'Donor']):
                    raise ValueError('Cannot correct AddAudioSample for edge {} to {} due to successor node'.format(
                        edge[0], edge[1]
                    ))
                predecessors = [pred for pred in predecessors if pred != edge[0]]
                if len(predecessors) == 0:
                    donor = scModel.getBaseNode(edge[1])
                else:
                    donor = predecessors[0]
                args= dict() if 'arguments' not  in currentLink else copy.copy(currentLink['arguments'])
                args['donor'] = donor
                plugins.callPlugin('OverwriteAudioStream',sourceim,source,dest,donor=donor)
Example #2
0
 def test_drop_then_add(self):
     filename = self.locateFile('tests/videos/sample1.mov')
     filename_output1 = os.path.join(
         os.path.dirname(os.path.abspath(filename)), 'sample_out1a.avi')
     kwargs = {
         'Start Time': 100,
         'seconds to drop': 2,
         'codec': 'XVID',
         'save histograms': 'yes'
     }
     args, error = plugins.callPlugin('FlowDrivenVideoFrameDrop', None,
                                      filename, filename_output1, **kwargs)
     self.filesToKill.append(filename_output1)
     self.assertTrue(error is None)
     frames1 = int(
         get_channel_data(
             ffmpeg_api.get_meta_from_video(filename, show_streams=True)[0],
             'video')[0]['nb_frames'])
     frames2 = int(
         get_channel_data(
             ffmpeg_api.get_meta_from_video(filename_output1,
                                            show_streams=True)[0],
             'video')[0]['nb_frames'])
     diff = frames1 - frames2
     self.assertTrue(diff > 0)
     diff_time = int(args['End Time']) - int(args['Start Time']) + 1
     self.assertEqual(diff, diff_time)
     filename_output2 = os.path.join(
         os.path.dirname(os.path.abspath(filename)), 'sample_out2a.avi')
     args['codec'] = 'XVID'
     if getValue(args, 'Frames to Add', 0) < 1:
         args['Frames to Add'] = 1
     print str(args)
     args, error = plugins.callPlugin('FlowDrivenVideoTimeWarp', None,
                                      filename_output1, filename_output2,
                                      **args)
     self.filesToKill.append(filename_output2)
     self.assertTrue(error is None)
     frames1 = int(
         get_channel_data(
             ffmpeg_api.get_meta_from_video(filename_output1,
                                            show_streams=True)[0],
             'video')[0]['nb_frames'])
     frames2 = int(
         get_channel_data(
             ffmpeg_api.get_meta_from_video(filename_output2,
                                            show_streams=True)[0],
             'video')[0]['nb_frames'])
     diff = frames2 - frames1
     self.assertTrue(diff > 0)
     diff_time = int(args['End Time']) - int(args['Start Time']) + 1
     print str(args)
     self.assertEqual(diff, diff_time)
Example #3
0
 def getVideoMeta(self, source, with_frames=False, show_streams=True, media_types=['video', 'audio']):
     """
     Featch meta data, overwriting any keys from the cache in the instance graph's node identified by source.
     :param source: source node id
     :param with_frames:
     :param show_streams:
     :param media_types:
     :return:
     """
     source_file = self.graph.get_image_path(source)
     meta, frames = ffmpeg_api.get_meta_from_video(source_file, with_frames=with_frames, show_streams=show_streams,
                                                   media_types=media_types)
     node_meta = self.__get_cache_from_graph(source)
     for item in meta:
         match = _match_stream(item, node_meta)
         if match is not None:
             item.update(match)
     return meta, frames
Example #4
0
def transform(img, source, target, **kwargs):
    meta = get_meta_from_video(source, show_streams=True)
    video_data = __get_channel_data(meta[0], 'video')
    return video_data, None