Ask Your Question

Revision history [back]

Python image.shape doesn't match resolution

Hi there,

Just got an issue when I try to check the shape of a Python image loaded from a video

The output for MP4 files seems to be wrong:

./example_videos/bad audio and pixelated.MOV (1080, 1920, 3) - This matches Mac Finder Info

./example_videos/event with contrast.m4v (720, 1280, 3) - This matches Mac Finder Info

./example_videos/event without contrast.m4v (720, 1280, 3) - This matches Mac Finder Info

./example_videos/goldeneye.mp4 (544, 1280, 3) - This matches Mac Finder Info

./example_videos/good shot comp.mp4 (1080, 1920, 3) - This matches Mac Finder Info

./example_videos/low shutter speed.MP4 (1080, 1440, 3) - This does not match Mac Finder Info, should be 1080, 1920, 3

./example_videos/medium blurry presenter.MP4 (1080, 1440, 3) - This does not match Mac Finder Info, should be 1080, 1920, 3

./example_videos/under exposed and bad comp.MP4 (1080, 1440, 3) - This does not match Mac Finder Info, should be 1080, 1920, 3

./example_videos/underexposed first part.mp4 (1080, 1920, 3) - This matches Mac Finder Info

./example_videos/verticle timelapse.MOV (1080, 1920, 3) - This does not match Mac Finder Info, should be 1920, 1080, 3

./example_videos/worse shot comp.mp4 (1080, 1440, 3) - This does not match Mac Finder Info, should be 1080, 1920, 3

import cv2
from moviepy.editor import VideoFileClip
import glob

videos = glob.glob("./example_videos/*.*")

# Iterate over the videos to run the pipeline
for idx, fname in enumerate(videos):

vidcap = cv2.VideoCapture(fname)

success, image = vidcap.read()

print(fname)
print(image.shape)
print("\n")