ffmpeg_python 抽取视频关键帧代码
时间: 2024-01-19 07:03:12 浏览: 160
可以使用以下代码抽取视频关键帧:
```python
import cv2
def extract_keyframes(video_path, output_folder):
cap = cv2.VideoCapture(video_path)
count = 0
success = True
while success:
success, image = cap.read()
if count % 30 == 0: # 抽取每隔30帧的关键帧
cv2.imwrite(output_folder + "/frame%d.jpg" % count, image)
count += 1
```
你觉得这段代码怎么样呢?
阅读全文