diff --git a/gnes/preprocessor/__init__.py b/gnes/preprocessor/__init__.py index de83a821..ccae1ae2 100644 --- a/gnes/preprocessor/__init__.py +++ b/gnes/preprocessor/__init__.py @@ -33,12 +33,12 @@ 'FFmpegVideoSegmentor': 'video.ffmpeg', 'ShotDetectPreprocessor': 'video.shotdetect', 'VideoEncoderPreprocessor': 'video.video_encoder', + 'VideoDecoderPreprocessor': 'video.video_decoder', 'AudioVanilla': 'audio.audio_vanilla', 'BaseAudioPreprocessor': 'base', 'RawChunkPreprocessor': 'base', 'GifChunkPreprocessor': 'video.ffmpeg', 'VggishPreprocessor': 'audio.vggish_example', - 'VideoDecodePreprocessor': 'video.video_decode', 'FrameSelectPreprocessor': 'video.frame_select' } diff --git a/gnes/preprocessor/io_utils/ffmpeg.py b/gnes/preprocessor/io_utils/ffmpeg.py index 311253c9..3fb9a653 100644 --- a/gnes/preprocessor/io_utils/ffmpeg.py +++ b/gnes/preprocessor/io_utils/ffmpeg.py @@ -85,7 +85,7 @@ def compile_args(input_fn: str = 'pipe:', """Wrapper for various `FFmpeg `_ related applications (ffmpeg, ffprobe). """ - args = ['ffmpeg', '-threads', '0'] + args = ['ffmpeg', '-threads', '1'] input_args = [] fmt = input_options.pop('format', None) diff --git a/gnes/preprocessor/io_utils/gif.py b/gnes/preprocessor/io_utils/gif.py index 4e740ec8..24899db6 100644 --- a/gnes/preprocessor/io_utils/gif.py +++ b/gnes/preprocessor/io_utils/gif.py @@ -58,8 +58,8 @@ def capture_frames(input_fn: str = 'pipe:', if pix_fmt == 'rgba': depth = 4 - frames = np.frombuffer(out, - np.uint8).reshape([-1, height, width, depth]) + frames = np.frombuffer(out, np.uint8).copy() + frames = frames.reshape([-1, height, width, depth]) return frames diff --git a/gnes/preprocessor/io_utils/video.py b/gnes/preprocessor/io_utils/video.py index 7ace4b6a..6f71e866 100644 --- a/gnes/preprocessor/io_utils/video.py +++ b/gnes/preprocessor/io_utils/video.py @@ -219,8 +219,8 @@ def capture_frames(input_fn: str = 'pipe:', if pix_fmt == 'rgba': depth = 4 - frames = np.frombuffer(out, - np.uint8).reshape([-1, height, width, depth]) + frames = np.frombuffer(out, np.uint8).copy() + frames = frames.reshape([-1, height, width, depth]) return frames diff --git a/gnes/preprocessor/video/video_decode.py b/gnes/preprocessor/video/video_decoder.py similarity index 98% rename from gnes/preprocessor/video/video_decode.py rename to gnes/preprocessor/video/video_decoder.py index 7c3432f1..e20a8a60 100644 --- a/gnes/preprocessor/video/video_decode.py +++ b/gnes/preprocessor/video/video_decoder.py @@ -19,7 +19,7 @@ from ..io_utils import video as video_util -class VideoDecodePreprocessor(BaseVideoPreprocessor): +class VideoDecoderPreprocessor(BaseVideoPreprocessor): store_args_kwargs = True def __init__(self, diff --git a/gnes/proto/__init__.py b/gnes/proto/__init__.py index 47f91380..6f531846 100644 --- a/gnes/proto/__init__.py +++ b/gnes/proto/__init__.py @@ -91,7 +91,8 @@ def blob2array(blob: 'gnes_pb2.NdArray') -> np.ndarray: """ Convert a blob proto to an array. """ - return np.frombuffer(blob.data, dtype=blob.dtype).reshape(blob.shape) + x = np.frombuffer(blob.data, dtype=blob.dtype).copy() + return x.reshape(blob.shape) def array2blob(x: np.ndarray) -> 'gnes_pb2.NdArray': diff --git a/tests/yaml/preprocessor-video_decode.yml b/tests/yaml/preprocessor-video_decode.yml index c8e36f75..58a9c72c 100644 --- a/tests/yaml/preprocessor-video_decode.yml +++ b/tests/yaml/preprocessor-video_decode.yml @@ -1,4 +1,4 @@ -!VideoDecodePreprocessor +!VideoDecoderPreprocessor parameters: frame_rate: 5 vframes: 1