fourMs / MGT-python

Musical Gestures Toolbox for Python
https://www.uio.no/ritmo/english/research/labs/fourms/downloads/software/musicalgesturestoolbox/mgt-python/index.html
GNU General Public License v3.0
53 stars 11 forks source link

Skip frames based on keyframes #196

Closed alexarje closed 2 years ago

alexarje commented 3 years ago

To improve processing speed and utilize the inner potential of MP4 files, I think it would be good to include a mode "keyframes" for the skip frame function. This could be based on extracting only the keyframes of the video file, such as this:

ffmpeg -skip_frame nokey -i $filename

joachimpoutaraud commented 2 years ago

After some research on the ffmpeg documentation, I found that it was also possible to -discard the keyframes of the video (i.e. -discard nokey) in order to discard specific streams or frames of streams at the demuxer.

The -skip_frame is useful to skip the decoding of the frames but when processing the video file I found that discarding the frames was reducing even more the size of the video file. I will therefore implemented this as a new parameter for the video preprocessing.

joachimpoutaraud commented 2 years ago

I have updated the fixing function and added the possibility to extract only the keyframes of the video file in order to improve processing speed and utilize the inner potential of MP4 files. This can be achieve by setting the parameter frames=-1. More information here.

This is only available on the local repository at the moment but I will update a new version of the repository on PyPI with some other functions shortly.