↑ Return to Applied Digital Studies

A Supercut using Videogrep in Python

In recent years it has become increasing popular to have a video made from another that only plays certain parts. Whether it be for entertainment or research purposes, the most common way to create this type of video is by cutting the necessary parts from one video and make another manually.

However, recently a quicker way has been developed using Python. By using this method the desired word is written into the command line and the program looks for it and created the video itself. For my final project I learned this method and applied it to another video to demonstrate how it works.

There were many challenges with this type of program since it appears to be written more for Mac than PC, in addition to that there are several other programs that are necessary to download. For the purpose of this project I used the project as a module through qtconsole in Python. I have taken several screen shots to show my process.

More information can be found at the main webpage where the author explains in more detail the various ways and different techniques that this program can be used for.

Naturally you have to have the video you want to work with already saved on your computer along with the subtitles. An important thing to remember is that the subtitle file needs to be saved as an srt and must be saved in the same location as the video file.

present1Because this is being used as a module all of the information has to be imported. To invoke this command you have to first type import videogrep

After that, you need to type videogrep.videogrep to specify the type of file that is being imported. Once that is complete, all that is needed is to type the path, the name of the output file (that new one that will be created), the word you want to look for, and finally the type of word. For instance, ‘re’ would be used if it were a regular expression and ‘pos’ if it were a specific part of speech. The command should look like this

videogrep.videogrep([‘C:/Users/Sharla/Desktop/ADS/the_great_gatsby.mp4′],’out.mp4′,’Gatsby’,’re’)

Once this line is entered the program will begin followed by several progress bars that will resemble the example below.

present2During this phase the program looks for the word and begins to compile it in separate parts until it is completed.

 

 

 

 

 

present4Once it is finished, the final bar will indicate the new video has been created and at this part, all you have to do is search for the file name created for the output. In this particular the case the file was simply called “output.mp4” .

 

 

 

 

There may be several attempts necessary, this is still fairly new, but if everything was accurate the final result will play as in the example below.