title: Python - How do I extract audio and video from the same parts of a file?
body: <p>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. </p>
  
  <p>I'm using Python/OpenCV and can correctly identify the features in the video and can create the new video file that I want.</p>
  
  <p>I can also use the <code>subprocess</code> module and <code>ffmpeg</code> to extract the full audio from the original file and I can use the <code>wave</code> module to iterate over the audio frames. I'm also planning to use <code>ffmpeg</code> to combine the resulting audio and video files.</p>
  
  <p>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 <code>Wave.getnframes()</code>, so I'm not sure how to extract just the audio that I need.</p>