Skip to content

Instantly share code, notes, and snippets.

@nhtera
Created April 9, 2017 18:42
Show Gist options
  • Save nhtera/d2a78f607019570d48152ce72fccabd4 to your computer and use it in GitHub Desktop.
Save nhtera/d2a78f607019570d48152ce72fccabd4 to your computer and use it in GitHub Desktop.
Convert all videos .ts to .mp4 using ffmpeg
#!/usr/local/opt/python/bin/python2.7
# Required ffmpeg
import os
import sys
walk_dir = os.getcwd()
count = 0
for root, subdirs, files in os.walk(walk_dir):
for file in files:
if (file.split(".")[-1].lower() == 'ts'):
filePath = os.path.join(root, file)
mp4FilePath = os.path.join(root, os.path.splitext(file)[0] + ".mp4")
if os.path.isfile(mp4FilePath):
continue
os.system("ffmpeg -i " + "\"" + filePath + "\"" + " \"" + mp4FilePath + "\"")
count = count + 1
print "\"" + filePath + "\""
print "Done the total number of file was be converted: ", count
@AbdullahAhmed6859
Copy link

This was really helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment