lib/imageio/plugins/ffmpeg.py
def _load_infos(self):
            """ reads the FFMPEG info on the file and sets size fps
            duration and nframes. """

            # Wait for the catcher to get the meta information
            etime = time.time() + 4.0
            while (not self._stderr_catcher.header) and time.time() < etime:
                time.sleep(0.01)

            # Check whether we have the information
            infos = self._stderr_catcher.header
            if not infos:
                self._terminate()
                if self.request._video:
                    ffmpeg_err = 'FFMPEG STDERR OUTPUT:\n' + \
                                 self._stderr_catcher.get_text(.1)+"\n"
                    if "darwin" in sys.platform:
                        if "Unknown input format: 'avfoundation'" in \
                                ffmpeg_err:
                            ffmpeg_err += "Try installing FFMPEG using " \
                                          "home brew to get a version with " \
                                          "support for cameras."
                    raise IndexError('No video4linux camera at %s.\n\n%s' %
                                     (self.request._video, ffmpeg_err))
                else:
                    err2 = self._stderr_catcher.get_text(0.2)
                    fmt = 'Could not load meta information\n=== stderr ===\n%s'
                    raise IOError(fmt % err2)

            if self.request.kwargs.get('print_info', False):
                # print the whole info text returned by FFMPEG
                print(infos)
                print('-'*80)
            lines = infos.splitlines()
            if "No such file or directory" in lines[-1]:
                if self.request._video:
                    raise IOError("Could not open steam %s." % self._filename)
                else:  # pragma: no cover - this is checked by Request
                    raise IOError("%s not found! Wrong path?" % self._filename)

            # Get version
            ver = lines[0].split('version', 1)[-1].split('Copyright')[0]
            self._meta['ffmpeg_version'] = ver.strip() + ' ' + lines[1].strip()

            # get the output line that speaks about video
            videolines = [l for l in lines if ' Video: ' in l]
            line = videolines[0]

            # get the frame rate
            match = re.search("( [0-9]*.| )[0-9]* (tbr|fps)", line)
            fps = float(line[match.start():match.end()].split(' ')[1])
            self._meta['fps'] = fps

            # get the size of the original stream, of the form 460x320 (w x h)
            match = re.search(" [0-9]*x[0-9]*(,| )", line)
            parts = line[match.start():match.end()-1].split('x')
            self._meta['source_size'] = tuple(map(int, parts))

            # get the size of what we receive, of the form 460x320 (w x h)
            line = videolines[-1]  # Pipe output
            match = re.search(" [0-9]*x[0-9]*(,| )", line)
            parts = line[match.start():match.end()-1].split('x')
            self._meta['size'] = tuple(map(int, parts))

            # Check the two sizes
            if self._meta['source_size'] != self._meta['size']:
                logging.warning('Warning: the frame size for reading %s is '
                                'different from the source frame size %s.' %
                                (self._meta['size'],
                                 self._meta['source_size']))

            # get duration (in seconds)
            line = [l for l in lines if 'Duration: ' in l][0]
            match = re.search(" [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9]",
                              line)
            if match is not None:
                hms = map(float, line[match.start()+1:match.end()].split(':'))
                self._meta['duration'] = duration = cvsecs(*hms)
                self._meta['nframes'] = int(round(duration*fps))
 reads the FFMPEG info on the file and sets size fps
            duration and nframes. 
reads the FFMPEG info on the file and sets size fps
duration and nframes.
reads the FFMPEG info on the file and sets size fps duration and nframes .
def _load_infos(self):
            etime = time.time() + 4.0
            while (not self._stderr_catcher.header) and time.time() < etime:
                time.sleep(0.01)
            infos = self._stderr_catcher.header
            if not infos:
                self._terminate()
                if self.request._video:
                    ffmpeg_err = 'FFMPEG STDERR OUTPUT:\n' + \
                                 self._stderr_catcher.get_text(.1)+"\n"
                    if "darwin" in sys.platform:
                        if "Unknown input format: 'avfoundation'" in \
                                ffmpeg_err:
                            ffmpeg_err += "Try installing FFMPEG using " \
                                          "home brew to get a version with " \
                                          "support for cameras."
                    raise IndexError('No video4linux camera at %s.\n\n%s' %
                                     (self.request._video, ffmpeg_err))
                else:
                    err2 = self._stderr_catcher.get_text(0.2)
                    fmt = 'Could not load meta information\n=== stderr ===\n%s'
                    raise IOError(fmt % err2)
            if self.request.kwargs.get('print_info', False):
                print(infos)
                print('-'*80)
            lines = infos.splitlines()
            if "No such file or directory" in lines[-1]:
                if self.request._video:
                    raise IOError("Could not open steam %s." % self._filename)
                else:  
                    raise IOError("%s not found! Wrong path?" % self._filename)
            ver = lines[0].split('version', 1)[-1].split('Copyright')[0]
            self._meta['ffmpeg_version'] = ver.strip() + ' ' + lines[1].strip()
            videolines = [l for l in lines if ' Video: ' in l]
            line = videolines[0]
            match = re.search("( [0-9]*.| )[0-9]* (tbr|fps)", line)
            fps = float(line[match.start():match.end()].split(' ')[1])
            self._meta['fps'] = fps
            match = re.search(" [0-9]*x[0-9]*(,| )", line)
            parts = line[match.start():match.end()-1].split('x')
            self._meta['source_size'] = tuple(map(int, parts))
            line = videolines[-1]  
            match = re.search(" [0-9]*x[0-9]*(,| )", line)
            parts = line[match.start():match.end()-1].split('x')
            self._meta['size'] = tuple(map(int, parts))
            if self._meta['source_size'] != self._meta['size']:
                logging.warning('Warning: the frame size for reading %s is '
                                'different from the source frame size %s.' %
                                (self._meta['size'],
                                 self._meta['source_size']))
            line = [l for l in lines if 'Duration: ' in l][0]
            match = re.search(" [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9]",
                              line)
            if match is not None:
                hms = map(float, line[match.start()+1:match.end()].split(':'))
                self._meta['duration'] = duration = cvsecs(*hms)
                self._meta['nframes'] = int(round(duration*fps))
def _load_infos ( self ) : etime = time . time ( ) + 4.0 while ( not self . _stderr_catcher . header ) and time . time ( ) < etime : time . sleep ( 0.01 ) infos = self . _stderr_catcher . header if not infos : self . _terminate ( ) if self . request . _video : ffmpeg_err = 'FFMPEG STDERR OUTPUT:\n' + self . _stderr_catcher . get_text ( .1 ) + "\n" if "darwin" in sys . platform : if "Unknown input format: 'avfoundation'" in ffmpeg_err : ffmpeg_err += "Try installing FFMPEG using " "home brew to get a version with " "support for cameras." raise IndexError ( 'No video4linux camera at %s.\n\n%s' % ( self . request . _video , ffmpeg_err ) ) else : err2 = self . _stderr_catcher . get_text ( 0.2 ) fmt = 'Could not load meta information\n=== stderr ===\n%s' raise IOError ( fmt % err2 ) if self . request . kwargs . get ( 'print_info' , False ) : print ( infos ) print ( '-' * 80 ) lines = infos . splitlines ( ) if "No such file or directory" in lines [ - 1 ] : if self . request . _video : raise IOError ( "Could not open steam %s." % self . _filename ) else : raise IOError ( "%s not found! Wrong path?" % self . _filename ) ver = lines [ 0 ] . split ( 'version' , 1 ) [ - 1 ] . split ( 'Copyright' ) [ 0 ] self . _meta [ 'ffmpeg_version' ] = ver . strip ( ) + ' ' + lines [ 1 ] . strip ( ) videolines = [ l for l in lines if ' Video: ' in l ] line = videolines [ 0 ] match = re . search ( "( [0-9]*.| )[0-9]* (tbr|fps)" , line ) fps = float ( line [ match . start ( ) : match . end ( ) ] . split ( ' ' ) [ 1 ] ) self . _meta [ 'fps' ] = fps match = re . search ( " [0-9]*x[0-9]*(,| )" , line ) parts = line [ match . start ( ) : match . end ( ) - 1 ] . split ( 'x' ) self . _meta [ 'source_size' ] = tuple ( map ( int , parts ) ) line = videolines [ - 1 ] match = re . search ( " [0-9]*x[0-9]*(,| )" , line ) parts = line [ match . start ( ) : match . end ( ) - 1 ] . split ( 'x' ) self . _meta [ 'size' ] = tuple ( map ( int , parts ) ) if self . _meta [ 'source_size' ] != self . _meta [ 'size' ] : logging . warning ( 'Warning: the frame size for reading %s is ' 'different from the source frame size %s.' % ( self . _meta [ 'size' ] , self . _meta [ 'source_size' ] ) ) line = [ l for l in lines if 'Duration: ' in l ] [ 0 ] match = re . search ( " [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9]" , line ) if match is not None : hms = map ( float , line [ match . start ( ) + 1 : match . end ( ) ] . split ( ':' ) ) self . _meta [ 'duration' ] = duration = cvsecs ( * hms ) self . _meta [ 'nframes' ] = int ( round ( duration * fps ) )
reads the FFMPEG info on the file and sets size fps
duration and nframes.
reads the FFMPEG info on the file and sets size fps duration and nframes .
""" reads the FFMPEG info on the file and sets size fps
            duration and nframes. """ # Wait for the catcher to get the meta information # Check whether we have the information # print the whole info text returned by FFMPEG # pragma: no cover - this is checked by Request # Get version # get the output line that speaks about video # get the frame rate # get the size of the original stream, of the form 460x320 (w x h) # get the size of what we receive, of the form 460x320 (w x h) # Pipe output # Check the two sizes # get duration (in seconds)
self