My goal is to analyze a video file (in this case an mp4 file) for the occurrence of certain features and create a new video file that just contains the video and audio from slightly before and slightly after those features occurring.
I'm using Python/OpenCV and can correctly identify the features 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 original file and I can use the wave
module to iterate over the audio frames. I'm also planning to use ffmpeg
to combine the resulting audio and video files.
My issue is extracting the audio that matches up with the frames in the new, condensed video file. The number of frames in the original video file (according to OpenCV) doesn't equal the number of frames returned from Wave.getnframes()
, so I'm not sure how to extract just the audio that I need.