Код: Выделить всё
import cv2
video_path = '/Users/aravind/Downloads/test.avi'
cap = cv2.VideoCapture(video_path)
print(cap.get(cv2.CAP_PROP_FOURCC))
print("FPS:", cap.get(cv2.CAP_PROP_FPS))
print("Frame count:", cap.get(cv2.CAP_PROP_FRAME_COUNT))
print("Width:", cap.get(cv2.CAP_PROP_FRAME_WIDTH))
print("Height:", cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
while cap.isOpened():
print("Working here")
ret, frame = cap.read() # crashes here
Выполняется
Код: Выделить всё
ffprobe -v quiet -print_format json -show_streams /Users/aravind/Downloads/test.aviКод: Выделить всё
{
"streams": [
{
"index": 0,
"codec_name": "rawvideo",
"codec_long_name": "raw video",
"codec_type": "video",
"codec_tag_string": "[0][0][0][0]",
"codec_tag": "0x0000",
"width": 192,
"height": 192,
"coded_width": 192,
"coded_height": 192,
"has_b_frames": 0,
"pix_fmt": "bgr24",
"level": -99,
"r_frame_rate": "30/1",
"avg_frame_rate": "30/1",
"time_base": "1/30",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 60,
"duration": "2.000000",
"bit_rate": "26991946",
"nb_frames": "60",
"extradata_size": 9,
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0,
"non_diegetic": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0,
"multilayer": 0
}
}
]
}
Код: Выделить всё
ffmpeg -i /Users/aravind/Downloads/test.avi -vframes 1 /tmp/test_frame.png 2>&1Код: Выделить всё
ffmpeg version 8.1 Copyright (c) 2000-2026 the FFmpeg developers
built with Apple clang version 21.0.0 (clang-2100.0.123.102)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/8.1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libsvtav1 --enable-libopus --enable-libx264 --enable-libmp3lame --enable-libdav1d --enable-libvmaf --enable-libvpx --enable-libx265 --enable-openssl --enable-videotoolbox --enable-audiotoolbox --enable-neon
libavutil 60. 26.100 / 60. 26.100
libavcodec 62. 28.100 / 62. 28.100
libavformat 62. 12.100 / 62. 12.100
libavdevice 62. 3.100 / 62. 3.100
libavfilter 11. 14.100 / 11. 14.100
libswscale 9. 5.100 / 9. 5.100
libswresample 6. 3.100 / 6. 3.100
Input #0, avi, from '/Users/aravind/Downloads/test.avi':
Duration: 00:00:02.00, start: 0.000000, bitrate: 26813 kb/s
Stream #0:0: Video: rawvideo, bgr24, 192x192, 26991 kb/s, 30 fps, 30 tbr, 30 tbn
File '/tmp/test_frame.png' already exists. Overwrite? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> png (native))
Press [q] to stop, [?] for help
Output #0, image2, to '/tmp/test_frame.png':
Metadata:
encoder : Lavf62.12.100
Stream #0:0: Video: png, rgb24(pc, gbr/unknown/unknown, progressive), 192x192, q=2-31, 200 kb/s, 30 fps, 30 tbn
Metadata:
encoder : Lavc62.28.100 png
[image2 @ 0xbe7018280] The specified filename '/tmp/test_frame.png' does not contain an image sequence pattern or a pattern is invalid.
[image2 @ 0xbe7018280] Use a pattern such as %03d for an image sequence or use the -update option (with -frames:v 1 if needed) to write a single image.
[out#0/image2 @ 0xbe6c54180] video:2KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: unknown
frame= 1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.03 bitrate=N/A speed=7.15x elapsed=0:00:00.00
Прикрепил ссылку на видео, которая не работает: ссылка Jumpshare
и ссылку на видео, которая работает: примеры файлов