-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvertTS.py
executable file
·41 lines (36 loc) · 940 Bytes
/
convertTS.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
#!/usr/bin/env python3
# Joel Gurnett
# Converts ts files to mp4
# June 21, 2019 - edited April 29, 2020
import subprocess
import os
import globalFunc
from ffmpy import FFmpeg
from datetime import date
# save the list of all .ts files to a log
def output(files):
today = date.today()
f = open("/home/joel/Desktop/converted/converted_" + str(today) + ".txt", 'w+')
for item in files:
f.write("%s\n" % item)
f.close()
# execute program
def main():
# main path to start on
dirPath = "/home/joel/media/shows/"
# get list of ts files
vids = globalFunc.getFiles(dirPath)
output(vids)
# iterate through the list
if vids != None:
for video in vids:
filename, file_extension = os.path.splitext(video)
infile = video
outfile = filename + ".mp4"
# convert ts to mp4
p = subprocess.call(["ffmpeg", "-i", infile, "-s", "hd720", outfile])
# rmove ts file
os.remove(infile)
else:
print("no files")
main()