群晖AME开启脚本

稚 发布于 2024-09-10 68 次阅读


使用群晖AME可以解析IPhone的HEVC高效编码文件 在IPhone中录视频4k60帧只能为高效模式HEVC编码 而且高效模式的图片也无法显示 当安装AME之后会自动将HEVC格式编码转为JPG

结果

image-20240911151926969

操作方法

可以直接使用ssh登录之后操作

脚本

适用于7.2版本

import hashlib
import os
import subprocess

r = ['669066909066906690', 'B801000000', '30']
s = [(0x3718, 0), (0x60A5, 1), (0x60D1, 1), (0x6111, 1), (0x6137, 1), (0xB5F0, 2)]

prefix = '/var/packages/CodecPack/target/usr'
so = prefix + '/lib/libsynoame-license.so'

print("Patching")
with open(so, 'r+b') as fh:
    full = fh.read()
    if hashlib.md5(full).digest().hex() != '09e3adeafe85b353c9427d93ef0185e9':
        print("MD5 mismatch")
        exit(1)
    for x in s:
        fh.seek(x[0] + 0x8000, 0)
        fh.write(bytes.fromhex(r[x[1]]))

lic = '/usr/syno/etc/license/data/ame/offline_license.json'
os.makedirs(os.path.dirname(lic), exist_ok=True)
with open(lic, 'w') as licf:
    licf.write('[{"attribute": {"codec": "hevc", "type": "free"}, "status": "valid", "extension_gid": null, "expireTime": 0, "appName": "ame", "follow": ["device"], "duration": 1576800000, "appType": 14, "licenseContent": 1, "registered_at": 1649315995, "server_time": 1685421618, "firstActTime": 1649315995, "licenseCode": "0"}, {"attribute": {"codec": "aac", "type": "free"}, "status": "valid", "extension_gid": null, "expireTime": 0, "appName": "ame", "follow": ["device"], "duration": 1576800000, "appType": 14, "licenseContent": 1, "registered_at": 1649315995, "server_time": 1685421618, "firstActTime": 1649315995, "licenseCode": "0"}]')

subprocess.run(['/usr/syno/etc/rc.sysv/apparmor.sh', 'remove_packages_profile', '0', 'CodecPack'])

apparmor = '/var/packages/CodecPack/target/apparmor'
if os.path.exists(apparmor):
    os.rename(apparmor, apparmor + ".bak")

print("Checking whether patch is successful...")
ret = os.system(prefix + "/bin/synoame-bin-check-license")
if ret == 0:
    print("Successful, updating codecs...")
    os.system(prefix + "/bin/synoame-bin-auto-install-needed-codec")
    print("Done")
else:
    print(f"Patch is unsuccessful, retcode = {ret}")

然后 在计划任务中 设置用户自定义脚本 ROOT账户

用户执行的脚本 前边的path是你的脚本文件路径 后边为输出log路径

python /volume1/docker/acm.py > /volume1/docker/output.txt

执行结果可以去output.txt 查看

image-20240911152222332

出现此则为成功

参考链接:CSDN