My goal is to analyze the video file (in this case the mp4 file) for the presence of certain functions and create a new video file that simply contains the video and audio from a little earlier and a little after these functions appear.
I am using Python / OpenCV and can correctly identify the functions in the video and can create the new video file that I want.
I can also use the subprocess module and ffmpeg to extract the full audio from the source file, and I can use the wave module to repeat the sound frames. I also plan to use ffmpeg to combine the resulting audio and video files.
My problem is to extract the sound that matches the frames in the new compressed video file. The number of frames in the original video file (according to OpenCV) is not equal to the number of frames returned from Wave.getnframes() , so I'm not sure how to extract only the sound that I need.
mplis source share