def grab(infile, outfile, buff_size = 0x200000, debug = True):
    #flv format http://wuyuans.com/2012/08/flv-format/
    _in = open(infile, 'rb')
    _in.seek(0xe40000) # 第一个flv似乎总是在这个位置开始
    _out = None
    idx = 0xe40000 # 当前偏移量
    cnt = 1
    _ = '\x00' * 11 # setup
    while _:
        if _ == '\x00' * 11:
            if _out: # 不是第一次
                _out.close()
                _out = None
            idx = math.ceil(idx / 0x40000) * 0x40000 # flv的起始位置是0x40000对齐的
            _in.seek(idx)
            _h = _in.read(9 + 4) # 头 9b,前一个tag 4b
            if _h.strip('\x00') != '' and _h[:3] == 'FLV': # 看开头是不是FLV
                _out = open(outfile[:-4] + '_%d.flv' % cnt, 'wb')
                print('New flv(%dp) @0x%08X%s' % (cnt, idx, ' ' * 20))
                _out.write(_h)
                idx += 9 + 4
                cnt += 1
        else:
            tagtype, length = struct.unpack('b3s7x', _) # 我们只关心tag类型(其实也可以不用关系)和数据长度
            length = _byte2ui24(length) # 3字节转uint24
            if debug:
                print('TAG:%6s 0x%06X @0x%08X-0x%08X%s' % (TAG_TYPE[tagtype], length, idx, idx + length + 4, '\b' * 42), end = '')
            idx += length + 4
            _ = _in.read(length + 4) #data, pre tag size
            _out.write(_)
 
        #next tag
        _ = _in.read(11)
        if _out:
            _out.write(_)
        idx += 11
 
    _in.close()
    #_out.close()# out is already closed
    return cnt - 1