def verify_video(filename_or_obj, format, resolution):
    width, height = resolution
    if format in RAW_FORMATS:
        size = (
                math.ceil(width / 32) * 32
                * math.ceil(height / 16) * 16
                * RAW_FORMATS[format]
                )
        if isinstance(filename_or_obj, str):
            stream = io.open(filename_or_obj, 'rb')
        else:
            stream = filename_or_obj
        stream.seek(0, os.SEEK_END)
        assert stream.tell() > 0
        # Check the stream size is an exact multiple of the frame size
        assert stream.tell() % size == 0
    else:
        if isinstance(filename_or_obj, str):
            p = subprocess.Popen([
                'avconv',
                '-f', format,
                '-i', filename_or_obj,
                ], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        else:
            p = subprocess.Popen([
                'avconv',
                '-f', format,
                '-i', '-',
                ], stdin=filename_or_obj, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        out = p.communicate()[0]
        assert p.returncode == 1, 'avconv returned unexpected code %d' % p.returncode
        state = 'start'
        for line in out.splitlines():
            line = line.decode('utf-8').strip()
            if state == 'start' and re.match(r'^Input #0', line):
                state = 'input'
            elif state == 'input' and re.match(r'^Duration', line):
                state = 'dur'
            elif state == 'dur' and re.match(r'^Stream #0\.0', line):
                assert re.match(
                    r'^Stream #0\.0: '
                    r'Video: %s( \(.*\))?, '
                    r'yuvj?420p, '
                    r'%dx%d( \[PAR \d+:\d+ DAR \d+:\d+\])?, '
                    r'\d+ fps(, \d+ tbr)?, \d+k? tbn(, \d+k? tbc)?$' % (
                        format, width, height),
                    line
                    ), 'Unexpected avconv output: %s' % line
                return
        assert False, 'Failed to locate stream analysis in avconv output'
Verify that the video in filename_or_obj has the specified format and
dataset/ETHPy150Open waveform80/picamera/tests/verify.py/verify_video