コード例 #1
0
 def frame_copy(n: int, f: VideoFrame) -> VideoFrame:
     fout = f.copy()
     frame_data, frame_props = self.get_frame(n, pipe=False)
     if self.compression_method == 'lzo':
         frame_data = pickle.loads(lzo.decompress(frame_data))
     for p in range(fout.format.num_planes):
         np.asarray(fout.get_write_array(p))[:] = frame_data[p]
     for i in frame_props:
         fout.props[i] = frame_props[i]
     return fout
コード例 #2
0
    def _wrap_frame(frame: VideoFrame) -> VideoNode:
        core = get_proxy_or_core()

        bc = core.std.BlankClip(width=frame.width,
                                height=frame.height,
                                length=1,
                                fpsnum=1,
                                fpsden=1,
                                format=frame.format.id)

        return bc.std.ModifyFrame([bc], lambda n, f: frame.copy())
コード例 #3
0
 def np_to_frame(array: np.ndarray, frame: vs.VideoFrame, order: tuple = (2, 1, 0)) -> vs.VideoFrame:
     """
     Copies each channel from a numpy array into a vs.VideoFrame.
     It expects the numpy array to be BGR, with the dimension count (C) last in the shape, so HWC or WHC.
     :param array: Numpy array to retrieve planes from.
     :param frame: VapourSynth frame to store retrieved planes.
     :param order: Specify input order of the numpy array color dimensions. It is most likely 2,1,0 (BGR).
     :returns: New frame with planes from numpy array
     """
     frame = frame.copy()
     if list(order) != [0, 1, 2]:
         array = np.transpose(array[:, :, order], (0, 1, 2))  # `order` to RGB
     for plane in range(array.shape[-1]):
         np.copyto(
             np.asarray(frame.get_write_array(plane)),
             array[:, :, plane],
             casting="unsafe"
         )
     return frame
コード例 #4
0
 def disable_rff(n: int, f: vs.VideoFrame) -> vs.VideoFrame:
     f = f.copy()
     f.props["PVSFlagRff"] = 0
     return f