Search code examples
pythonmatlabkatanamkv

How to extract keyframes from video having mkv extension


I want to extract key frames from video and for this I have tried the following approaches:

  1. Bypassing the frames
  2. Bypassing frames on Matlab
  3. Key Frames Extraction with katana
  4. Keyframes extraction using absolute histogram differencing in Python.

But I am confused about which way to proceed, as there are multiple ways!

And also the video of which I'm making the data set is in MKV format. Though I have converted the video into frames but for keyframe extraction, Matlab and Python both are unable to process the video in MKV.

So I need to convert it, to some other format like mp4 and avi. I have done this by using an online converter but still my code is unable to process that video and my computer got hanged.


Solution

  • What about using ffmpeg? It supports mkv containers.

    https://superuser.com/questions/669716/how-to-extract-all-key-frames-from-a-video-clip

    One example from there:

    ffmpeg -skip_frame nokey -i video.mkv -vsync 0 -r 30 -f image2 thumbnails-%02d.jpeg

    or .png etc.

    Then read these images and do what you want.

    There are python wrappers for ffmpeg as well: https://github.com/kkroening/ffmpeg-python