Created
December 9, 2017 18:03
-
-
Save gardenunez/41c85479f603bbd46007a750e86511d9 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
import os | |
import sys | |
walk_dir = os.getcwd() | |
count = 0 | |
def from_ts_to_mp4(source_file, dest_file): | |
os.system("ffmpeg -i {} -c:v copy -c:a copy {}".format(source_file, dest_file)) | |
def walk_and_convert(root_dir, convert): | |
count = 0 | |
for root, subdirs, files in os.walk(root_dir): | |
for file in files: | |
if (file.split(".")[-1].lower() == 'ts'): | |
source_file = os.path.join(root, file) | |
dest_file = os.path.join(root, os.path.splitext(source_file)[0] + ".mp4") | |
convert(source_file, dest_file) | |
count = count + 1 | |
print("{} --> {}".format(source_file, dest_file)) | |
print("total number of file converted: {}".format(count)) | |
if __name__ == '__main__': | |
walk_and_convert(sys.argv[1], convert=from_ts_to_mp4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment