forked from d-evil0per/mts2mp4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mts2mp4.py
61 lines (48 loc) · 1.71 KB
/
mts2mp4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# ffmpeg -i input.m2ts -c:v copy -c:a aac -strict experimental -b:a 128k output.mp4
# /home/d-eviloper/Videos/PRIVATE/AVCHD/BDMV/STREAM
#!/usr/bin/python
from pathlib import Path
import os
import sys
def banner():
print('\n\n')
print('## ## ######## ###### ####### ## ## ######## ## ')
print('### ### ## ## ## ## ## ### ### ## ## ## ## ')
print('#### #### ## ## ## #### #### ## ## ## ## ')
print('## ### ## ## ###### ####### ## ### ## ######## ## ## ')
print('## ## ## ## ## ## ## ## ######### ')
print('## ## ## ## ## ## ## ## ## ## ')
print('## ## ## ###### ######### ## ## ## ## ')
print('\n\n')
# Conversion Function
def convert(file,folder,count):
filename, file_extension = os.path.splitext(file)
ext=['.MTS']
if file_extension in ext:
ot_folder=os.path.join(folder,mp4)
output=os.path.join(ot_folder, os.path.basename(folder)+"_"+str(count)+".mp4")
print("Converting "+str(file))
try:
os.system("ffmpeg -i "+str(file)+" -c:v copy -c:a aac -strict experimental -b:a 128k "+str(output)+"> /dev/null 2>&1")
except:
print("Something went wrong when Processing the file")
# File Seeker
def recur(folder_path):
p=Path(folder_path)
dirs=p.glob("*")
i=0
for folder in dirs:
# print(folder)
if folder.is_dir():
recur(folder)
else:
i+=1
convert(folder,folder_path,i)
# calling the seeker function with input directory
banner()
# Input directory
directory = input("Enter the Directory Path: ")
# Output Directory
mp4="mp4"
os.system("mkdir "+os.path.join(directory,mp4))
recur(directory)