Last active
July 15, 2018 09:45
-
-
Save ranlix/8332191 to your computer and use it in GitHub Desktop.
将同一目录下所有.ts文件合并到一个新的.ts文件(PS: .ts文件是可以直接合并的视频文件,因此可以这样合并)
This file contains 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
# -*-coding: utf-8 -*- | |
import sys | |
import os | |
num = sys.argv[1] # num is the amount of *.ts files | |
def add(x): | |
"""'x' is the amount of *.ts | |
This function should add all other .ts combined into '1.ts' | |
""" | |
os.popen("touch all.ts") | |
x = int(x) | |
i = 1 | |
while i <= x: | |
command = "cat " + str(i) + ".ts " + ">> all.ts" | |
try: | |
os.popen(command) | |
except: # 如果没有当前.ts, 打印出错误并跳过 | |
print "There is no " + i + ".ts" | |
i += 1 | |
return True | |
if __name__ == '__main__': | |
add(num) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
也可以