def getFrameRate(self): """ Extracts the FPS from the physical file on first call and returns the cached value thereafter as a float. Requires ffmpeg """ if not self._fps: ffmpegParser = FFMPEG( ffmpeg=self.settings.get('paths_ffmpeg'), closeFDs=(type(self._platform) != util.WindowsPlatform)) # close_fds borked on windows try: metadata = ffmpegParser.get_metadata(self.getLocalPath()) except: log.exception('ffmpeg parsing failed') metadata = None log.debug('ffmpeg metadata for %s = %s' % (self.getLocalPath(), metadata)) if metadata: self._fps = float(metadata.frame_rate) else: self._fps = 29.97 log.error("""Could not determine FPS for file %s so defaulting to %s FPS. Make sure you have the ffmpeg executable in your path. Commercial skipping may be inaccurate""" % (self._fps, self.getLocalPath())) ui.showPopup('Error', 'FFMpeg could not determine framerate. Comm skip may be inaccurate') return self._fps