How to extract slides from video using python

I have a training course for videos that comes in the form of AVI files. Most screens are displayed as slides with the mouse moving over them.

I want to take a screenshot of the slide automatically when the screen changes (ignoring when the image changes a small amount due to the movement of the mouse pointer.)

I want to do this so that I can embed images in a word or html document that I can add to my notes, as I will learn how I am taking screenshots at the moment, but it is very slow and tiring, and the course is very long (about 24 hours of total playing time).

I know python well, but I'm not sure how I am going to extract frames from a video file, and then how to compare them to another, to see how different they are, to decide what to keep and discard.

Can anyone suggest how to do this?

+5
source share
2 answers

A tool like ffmpeg is suitable for extracting images from a video. From the manual:

 ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg

This will allow you to extract one video clip per second from the video and output them to files with a name foo-001.jpeg, foo-002.jpegetc. Images will be rescaled to match the new WxH values.

Comparing them for differences can then be performed by PIL and / or OpenCV .

EDIT: , , , ( ), . google :

ffmpeg -i foo.avi -vsync 0 -vf select="eq(pict_type\,PICT_TYPE_I)" -s WxH -f image2 foo-%03d.jpeg
+10

, , - . framedifferenceanalyzer Python, .

, ffmpeg - , , Python.

, , ImageMagick ( , compare). ImageMagick Python, PythonMagick magickwand, .

OpenCV, . OpenCV - , , , , , . , , / , .

+5

All Articles