Skip to content

jacobpclouse/Motion-Extraction

Repository files navigation

Motion-Extraction

With a very simple trick you can extract the motion of a video. Uses python3 and OpenCV to compare current frame of the video to a previous frame to see where changes have been made in the frames (and any changes indicate motion).

Inspired by this video by Posy

NOTE: Recommend to only test on shorter videos (ie: not greater than 5 minutes) -- current program converts in REAL TIME

  • IE: 5 hour video = at least 5 hours to convert

How to run this program (Easy Way):

    1. Make sure you have python 3 downloaded, installed and on path
    1. Move your target MP4 video into the same directory as the motion_Extraction.py file
    1. Run the easy install program with the command python Install_and_Run_Program.py --video 'yourVideo.mp4'
    • you NEED to provide the video title as an argument
    • this will automatically create a new virtual environment, install all the pip packages and then run the extraction program
    1. If you want to see the extraction overlay, type yes. If you do not, type no
    1. If you just want the frame compared to the previous one, then type PREVIOUS. If you want a larger delay, type CUSTOM (you will the be prompted to enter your custom frame delay)
    1. Your output will be created in a subfolder within the OUTPUTS folder, enjoy!

How to run this program (Long Way):

    1. Make sure you have python 3 downloaded, installed and on path
    1. Use the activateVirEnv.txt to create a virtual environment
    1. Make sure you pip install -r requirements.txt to install all the needed packages
    1. Move your target MP4 video into the same directory as the motion_Extraction.py file
    1. Run the program with the command python motion_Extraction.py yourVideo.mp4
    • you NEED to provide the video title as an argument
    1. If you want to see the extraction overlay, type yes. If you do not, type no
    1. If you just want the frame compared to the previous one, then type PREVIOUS. If you want a larger delay, type CUSTOM (you will the be prompted to enter your custom frame delay)
    1. Your output will be created in a subfolder within the OUTPUTS folder, enjoy!

Ideas:

  • [DONE] maybe combine the two while loops?
  • [DONE] invert then immediatly overlay?
  • [DONE] check pervious frame in one video then x frames back in another video (shows slower movement)
  • cut videos larger than like 3 minutes into chunks of 1 minutes, store in folder [check multiprocessing attempt folder]
  • then use threading to individually loop through and invert videos
  • then you can paste it together at the end

Resources used:

About

With a very simple trick you can extract the motion of a video. Uses python and OpenCV

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages