Created
November 2, 2020 14:56
-
-
Save xhlove/b11568cb6ef5b5f9167b93022bfbf71e to your computer and use it in GitHub Desktop.
合并amp4为eac3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
作者: weimo | |
创建日期: 2020-11-02 22:35:31 | |
上次编辑时间: 2020-11-02 22:55:12 | |
一个人的命运啊,当然要靠自我奋斗,但是... | |
''' | |
import sys | |
import gzip | |
from pathlib import Path | |
def decompress(binary: bytes): | |
try: | |
_ret = gzip.decompress(binary) | |
except Exception as e: | |
print("解压出错") | |
return | |
return _ret | |
def concat(path: str): | |
amp4s = [] | |
_path: Path | |
for _path in Path(path).iterdir(): | |
if _path.suffix == ".amp4": | |
amp4s.append(_path) | |
amp4s = sorted(amp4s, key=lambda _path: int(_path.stem)) | |
flag = False | |
amp4: Path | |
ret = [] | |
for amp4 in amp4s: | |
if flag is False: | |
_ret = decompress(amp4.read_bytes()) | |
if _ret is None: | |
print("分段有问题") | |
return | |
flag = True | |
ret.append(_ret) | |
else: | |
ret.append(amp4.read_bytes()) | |
Path(path, "output_yue").with_suffix(".eac3").write_bytes(b"".join(ret)) | |
print("合并完成") | |
if __name__ == "__main__": | |
_path = sys.argv[1] | |
concat(_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment