import os, zipfile, sys
src, out = sys.argv[1], sys.argv[2]
with zipfile.ZipFile(out, 'w', zipfile.ZIP_DEFLATED, compresslevel=6) as z:
    for root, dirs, files in os.walk(src):
        for f in files:
            full = os.path.join(root, f)
            arc = os.path.relpath(full, src).replace(os.sep, '/')
            zi = zipfile.ZipInfo.from_file(full, arc)
            zi.compress_type = zipfile.ZIP_DEFLATED
            mode = 0o755 if arc.endswith('ffmpeg-static/ffmpeg') else 0o644
            zi.external_attr = (0o100000 | mode) << 16
            with open(full, 'rb') as fh:
                z.writestr(zi, fh.read())
print(round(os.path.getsize(out) / 1e6), 'MB zip')
