Image to MP4 Script
#convert_to_mp4
import inspect
import os.path
import glob
import os
#We are using a directory to store out image file names because
#it will ensure we get a unique list of names - hence, database.
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, "*.jpg")
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_scripts2
parent_dir = parent_dir.replace("\\","/")
#-------------------------------------------------------------------
#Get the names of image files that have been added to the DB
names = filesDB.keys()
for name in names:
print('File "%s" occured %d times' % (name, filesDB[name]) )
if os.name == 'nt':
bat_name = name + '.bat'
ffmpeg_scripts2.WIN_convert_seq_to_mpeg(parent_dir, bat_name, name, ext)
else:
script_name = name
ffmpeg_scripts2.UNIX_convert_seq_to_mpeg(parent_dir, script_name, name, ext)