예제 #1
0
    def new_input(self):
        """
        Careful for video_split_duration...shouldn't add it
        since we condition on it

        NOTE here we have self.parent_input available
        as stored on Video Preprocess class but parent_input is not available
        on a generic input object see notes in Input class
        """

        self.input = Input.new(parent_input_id=self.parent_input.id,
                               project=self.project,
                               media_type="video",
                               type="from_video_split",
                               job_id=self.parent_input.job_id,
                               directory_id=self.parent_input.directory_id)

        self.session.add(self.input)
        self.session.flush()

        # Do we need .mp4 on end here?
        self.input.raw_data_blob_path = settings.PROJECT_VIDEOS_BASE_DIR + \
                                        str(self.project.id) + "/raw/" + str(self.input.id)

        self.extension = ".mp4"
예제 #2
0
    def __format_frame_for_update(self, frame_number: int,
                                  parent_input: Input):
        """
        frame may or may not exist yet

        """
        input = Input.new(
            project=
            None,  # required, but see project_id  detached session below.
            media_type="frame")

        frame_number = int(frame_number)  # cast to avoid future problems

        input.project_id = self.project.id  # Avoids detached session issues for parallel processing
        input.mode = "update"
        if parent_input.mode == 'update_with_existing':
            input.mode = 'update_with_existing'
        input.parent_input_id = parent_input.id
        input.parent_file_id = parent_input.file.id  # Assume downstream process will use this to get frame
        input.frame_number = frame_number
        input.video_parent_length = self.highest_frame_encountered

        # Returns input because it does formatting too, TODO adjust function name
        input = self.get_instance_list_from_packet_map(
            input=input, frame_number=frame_number)

        return input
예제 #3
0
파일: upload.py 프로젝트: svirmi/diffgram
    def create_input(
            self,
            project,
            request,
            filename
    ):

        self.input = Input.new(
            project=project,
            media_type=None,
            job_id=request.form.get('job_id'),
            directory_id=request.form.get('directory_id'),  # Not trusted
            video_split_duration=request.form.get('video_split_duration')
        )

        self.session.add(self.input)

        self.input = Upload.upload_limits(
            input=self.input,
            file_size=self.dztotalfilesize)

        self.input.original_filename = secure_filename(
            filename)  # http://flask.pocoo.org/docs/0.12/patterns/fileuploads/
        self.input.extension = os.path.splitext(self.input.original_filename)[1].lower()
        self.input.original_filename = os.path.split(self.input.original_filename)[1]

        # At somepoint should really declare
        # From UI here...
        self.input.type = "from_resumable"
        self.input.dzuuid = self.dzuuid
        self.input.action_flow_id = request.headers.get('flow_id')

        if self.input.action_flow_id:

            if self.input.flow is None:
                self.input.status = "failed"
                self.input.status_text = "No flow found"
                return

        self.input.mode = request.headers.get('mode')

        self.input.media_type = Process_Media.determine_media_type(
            extension=self.input.extension)

        if not self.input.media_type:
            self.input.status = "failed"
            self.input.status_text = "Invalid file type: " + self.input.extension

        # self.input.user =

        self.session.flush()  # For ID for path

        self.input.raw_data_blob_path = settings.PROJECT_RAW_IMPORT_BASE_DIR + \
                                        str(self.input.project.id) + "/raw/" + str(self.input.id)

        data_tools.create_resumable_upload_session(
            blob_path=self.input.raw_data_blob_path,
            content_type=None,
            input = self.input
        )
예제 #4
0
    def push_frames_for_copy_to_queue(self, source_video_parent_file_id,
                                      destination_video_parent_file_id):
        """
            Give the current data at self.input, get the video frame of the existing file
            and push them to the ProcessMedia Queue.
        :return:
        """

        source_video_frames = WorkingDirFileLink.image_file_list_from_video(
            session=self.session,
            video_parent_file_id=source_video_parent_file_id,
            order_by_frame=True)
        frame_completion_controller = FrameCompletionControl()
        for frame in source_video_frames:
            frame_completion_controller.add_pending_frame(frame.frame_number)

        for frame in source_video_frames:
            ### HOW TOD AVOID DETACHED SESSION
            ### Must only pass IDs and not pass any other objects

            # Actually the add remove link thing could be different too...

            # Careful the file id is the newly copied video
            # The previous video id should come from the NEW file id not the previous one
            frame_input = Input.new(
                parent_input_id=self.input.id,
                sequence_map=self.input.sequence_map,
                file_id=frame.id,  # existing
                video_parent_length=len(source_video_frames),
                directory_id=self.input.directory_id,
                source_directory_id=self.input.source_directory_id,
                remove_link=self.input.remove_link,
                add_link=self.input.add_link,
                copy_instance_list=self.input.copy_instance_list,
                parent_file_id=destination_video_parent_file_id,
                # This is the parent video file where all data is going to be copied.
                project_id=self.input.project_id,
                mode='copy_file',
                type=None,
                media_type='frame',
            )

            item = process_media.PrioritizedItem(
                input=frame_input,
                frame_completion_controller=frame_completion_controller,
                total_frames=source_video_frames[len(source_video_frames) -
                                                 1].frame_number,
                num_frames_to_update=len(source_video_frames),
                media_type=frame_input.
                media_type,  # declaring here helps with routing
                priority=100 + frame.frame_number,  # Process in frame priority
                frame_number=frame.
                frame_number  # Careful, downstream process currently expects it
            )

            process_media.add_item_to_queue(item)
        return source_video_frames