Compress MP4 Script

#compress_mp4.py
  
import inspect
import os.path
import glob
import os
  
  
filesDB = {}
  
#-------------------------------------------------------------------
  
def get_filename(fullpath):
    filename = os.path.basename(fullpath)
    filename, ext = os.path.splitext(filename)
    filename, num = os.path.splitext(filename)
    filename = filename
    return [filename, ext]
#-------------------------------------------------------------------
  
def add_name_to_DB(name):
    if name in filesDB:
        num = filesDB[name]
        filesDB[name] = num + 1
    else:
        filesDB[name] = 1
#-------------------------------------------------------------------
  
scriptpath = inspect.getframeinfo(inspect.currentframe()).filename
parent_dir = os.path.dirname(os.path.abspath(scriptpath))
  
glob_pattern = os.path.join(parent_dir, "*.MP4")
files = glob.glob(glob_pattern)
  
for fullpath in files:
    filename, ext = get_filename(fullpath)
    add_name_to_DB(filename)
#-------------------------------------------------------------------
  
#A hack to get python to recognize custom modules when running from Cutter
import sys
sys.path.append(parent_dir)
import ffmpeg_script
  
parent_dir = parent_dir.replace("\\","/")
#-------------------------------------------------------------------
  
#Get the names of image files that have been added to the DB
names = filesDB.keys()
  
if os.name == 'nt':
    bat_name ='compressed.bat'
    ffmpeg_script.WIN_convert_seq_to_mpeg(parent_dir, bat_name, names, ext)
else:
    pass