Exemple #1
0
def debug_plot_CandidatesinPDF(path_to_video):
    list_candidates = perform_frame_filtration(path_to_video)

    stream = Stream(path_to_input_video=path_to_video, time_resolution=None)

    frame_id = 0

    pbar = tqdm(total=stream.num_read_iterations)

    frame = stream.readNextFrameFromVideo()
    frame_id += 1

    with PdfPages('debug_frames.pdf') as pdf:
        while (not stream.videoFinished):

            if frame_id in list_candidates:
                fig, (ax1, ax2) = plt.subplots(2, 1)
                ax1.imshow(frame)

                next_frame = stream.readNextFrameFromVideo()
                frame_id += 1
                ax2.imshow(next_frame)

                pdf.savefig()
                plt.close()

            frame = stream.readNextFrameFromVideo()
            frame_id += 1
            pbar.update(1)

    pbar.close()

    stream.close_Stream()
Exemple #2
0
    def save_video_as_shots(self, out_path_for_video):

        if not (os.path.exists(out_path_for_video)):
            os.mkdir(out_path_for_video)

        video_id = 0

        video_name = self.get_video_name_from_id(video_id)
        srt_name = self.get_srt_name(video_id)

        fReader = Stream(self.path_to_video, time_resolution=None)

        time_resolution = fReader.time_resolution

        fReader.close_Stream()

        trans_to_write = list(self.full_trans)

        trans_to_write = [-1] + trans_to_write

        trans_to_write.append(fReader.frameReader.numFrames)

        for i, j in zip(trans_to_write, trans_to_write[1:]):

            t_start = time_resolution * (i + 1)
            t_end = time_resolution * (j)

            clip = VideoFileClip(self.path_to_video).subclip(t_start, t_end)
            clip.write_videofile(os.path.join(out_path_for_video, video_name))

            if (self.path_to_video_srt is not None):
                subclip = SubtitleManager(self.path_to_video_srt).subclip(
                    t_start, t_end, 0.0)
                write_to_subtitle_file(
                    subclip, os.path.join(out_path_for_video, srt_name))

            video_id += 1
            video_name = self.get_video_name_from_id(video_id)
            srt_name = self.get_srt_name(video_id)

        return True
Exemple #3
0
def features_from_video(path_to_video):
    stream = Stream(path_to_input_video=path_to_video, time_resolution=None)

    fps = int(stream.frameReader.videoFPS)

    sqnet = get_sqnet()

    list_features = []
    pbar = tqdm(total=stream.num_read_iterations)

    frame = stream.readNextFrameFromVideo()

    while (not stream.videoFinished):
        frame = cv2.resize(frame, frame_size)
        list_features.append(squeezenet_feature_from_frame(sqnet, frame))
        frame = stream.readNextFrameFromVideo()
        pbar.update(1)

    pbar.close()

    stream.close_Stream()

    return list_features, fps