ffmpeg-python icon indicating copy to clipboard operation
ffmpeg-python copied to clipboard

how can i calculate the dimensions of a compressed video?

Open xro7 opened this issue 6 years ago • 0 comments

I use the following code to compress a video and extract its frames

        output_args = {
            "vcodec": "libx265",
            "crf": 24,
        }
        out, err = (
            ffmpeg
            .input(in_filename)
            .output('pipe:', format='rawvideo', pix_fmt='rgb24',**output_args)
            .run(capture_stdout=True)
        )
        frames = np.frombuffer(out, np.uint8).reshape(-1,width,height,3)

When i try to reshape the output buffer to original video dimensions I get the following error: cannot reshape array of size 436567 into shape (1920,1080,3) Is there a way to calculate the number of frames, width, and height of the resulting video?

xro7 avatar Jan 29 '20 11:01 xro7