ffmpeg Script
This module contains the various ways of writing the commands for the operating systems that are supported by ffmpeg.
Open and write the ffmpeg command for Windows
Open and write the ffmpeg command for OS and Linux
#ffmpeg_scripts.py
#This module contains the various ways of writing the commands for the operating
#systems that are supported by ffmpeg.
import os.path
import os
import stat
#-------------------------------------------------------------------
def WIN_convert_seq_to_mpeg(parent_dir, bat_name, image_name, image_type):
outf = open(os.path.join(parent_dir, bat_name), 'w')
outf.write('ffmpeg.exe -i ')
outf.write('"%s/%s.%s%s" ' % (parent_dir, image_name, '%%04d', image_type) )
outf.write('-s 960x540 -codec:v libx264 -r 30 -pix_fmt yuv420p ')
outf.write('"./%s.mp4"' % image_name)
outf.write("\n")
outf.write('pause')
outf.close()
#-------------------------------------------------------------------
def UNIX_convert_seq_to_mpeg(parent_dir, script_name, image_name, image_type):
fullpath = os.path.join(parent_dir, script_name)
outf = open(fullpath), 'w'
outf.write('ffmpeg -pattern_type glob -i ')
outf.write('"%s/%s.%s.%s" ' % (parent_dir, image_name, '%%04d', image_type) )
outf.write('-s 960x540 -codec:v libx264 -r 30 -pix_fmt yuv420p ')
outf.write('"./%s.mp4"' % image_name)
outf.close()
os.chmod(fullpath, stat.S_IRWXU)
#-------------------------------------------------------------------