Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- #/home/<username>/bin/fadeinouthack.py
- # Released under a GPLv3 Licence by Clockwork PC 2012
- # www.clockworkpc.com.au
- # You are entitled to the following four freedoms:
- # Freedom 0: To run this program for any purpose
- # Freedom 1: To study how this program works and change it to make it do what you wish
- # Freedom 2: To redistribute copies so you can help your neighbour
- # Freedom 3: To distribute copies of your modified version to others
- import os
- import fileinput
- #Location of MainGTK.py, which is where the Fade In and Fade Out defaults are set
- mainGTKFile = os.getenv("HOME") + "/usr/share/pyshared/openshot/windows/MainGTK.py"
- #Location of dummy MainGTK.py
- mainGTKDummyFile = os.getenv("HOME") + "/bin/MainGTK.py"
- mainGTKDummyFileTemp = os.getenv("HOME") + "/bin/MainGTK_temp.txt"
- #Make a backup of MainGTK (of course!)
- os.system("cp " + mainGTKFile + " " + mainGTKDummyFileTemp)
- #These are the default fade speeds in OpenShot. I haven't work out how to get the default speeds from MainGTK, but maybe someone can work that out.
- oldFadeFast = "2.0"
- oldFadeSlow = "4.0"
- #Get the new fade speeds and make sure they have one decimal place. Because these numbers are being used as strings rather than data I've gone with the clumsy concatenation rather than taking integer input and using %1.f to supply the decimal place.
- newFadeFast = raw_input("How many seconds do you want the Fast Fade In/Out to be? ") + ".0"
- newFadeSlow = raw_input("How many seconds do you want the Slow Fade In/Out to be? ") + ".0"
- #Just to be on the safe side, not necessary.
- print "newFadeFast is... " + newFadeFast
- print "newFadeSlow is... " + newFadeSlow
- #Audio Fade Fast Old
- audioFadeInFastOld = "self.selected_clip.audio_fade_in_amount = " + oldFadeFast
- audioFadeOutFastOld = "self.selected_clip.audio_fade_out_amount = " + oldFadeFast
- #Audio Fade Slow Old
- audioFadeInSlowOld = "self.selected_clip.audio_fade_in_amount = " + oldFadeSlow
- audioFadeOutSlowOld = "self.selected_clip.audio_fade_out_amount = " + oldFadeSlow
- #Video Fade Fast Old
- videoFadeInFastOld = "self.selected_clip.video_fade_in_amount = " + oldFadeFast
- videoFadeOutFastOld = "self.selected_clip.video_fade_out_amount = " + oldFadeFast
- #Video Fade Slow Old
- videoFadeInSlowOld = "self.selected_clip.video_fade_in_amount = " + oldFadeSlow
- videoFadeOutSlowOld = "self.selected_clip.video_fade_out_amount = " + oldFadeSlow
- #Audio Fade Fast New
- audioFadeInFastNew = "self.selected_clip.audio_fade_in_amount = " + newFadeFast
- audioFadeOutFastNew = "self.selected_clip.audio_fade_out_amount = " + newFadeFast
- print "audioFadeInFastNew: " + audioFadeInFastNew
- print "audioFadeOutFastNew: " + audioFadeOutFastNew
- #Audio Fade Slow New
- audioFadeInSlowNew = "self.selected_clip.audio_fade_in_amount = " + newFadeSlow
- audioFadeOutSlowNew = "self.selected_clip.audio_fade_out_amount = " + newFadeSlow
- print "audioFadeInSlowNew: " + audioFadeInSlowNew
- print "audioFadeOutSlowNew: " + audioFadeOutSlowNew
- #Video Fade Fast New
- videoFadeInFastNew = "self.selected_clip.video_fade_in_amount = " + newFadeFast
- videoFadeOutFastNew = "self.selected_clip.video_fade_out_amount = " + newFadeFast
- print "videoFadeInFastNew: " + videoFadeInFastNew
- print "videoFadeOutFastNew: " + videoFadeOutFastNew
- #Video Fade Slow New
- videoFadeInSlowNew = "self.selected_clip.video_fade_in_amount = " + newFadeSlow
- videoFadeOutSlowNew = "self.selected_clip.video_fade_out_amount = " + newFadeSlow
- print "videoFadeInSlowNew: " + videoFadeInSlowNew
- print "videoFadeOutSlowNew: " + videoFadeOutSlowNew
- # Replace Audio Fast Fade In
- for line in fileinput.FileInput(mainGTKDummyFile, inplace=1):
- string_found = False
- if (not string_found) and (audioFadeInFastOld in line):
- line=line.replace(audioFadeInFastOld,audioFadeInFastNew)
- string_found = True
- print line,
- else:
- print line,
- # Replace Audio Fast Fade Out
- for line in fileinput.FileInput(mainGTKFile, inplace=1):
- string_found = False
- if (not string_found) and (audioFadeOutFastOld in line):
- line=line.replace(audioFadeOutFastOld,audioFadeOutFastNew)
- string_found = True
- print line,
- else:
- print line,
- # Replace Video Fast Fade In
- for line in fileinput.FileInput(mainGTKFile, inplace=1):
- string_found = False
- if (not string_found) and (videoFadeInFastOld in line):
- line=line.replace(videoFadeInFastOld,videoFadeInFastNew)
- string_found = True
- print line,
- else:
- print line,
- # Replace Video Fast Fade Out
- for line in fileinput.FileInput(mainGTKFile, inplace=1):
- string_found = False
- if (not string_found) and (videoFadeOutFastOld in line):
- line=line.replace(videoFadeOutFastOld,videoFadeOutFastNew)
- string_found = True
- print line,
- else:
- print line,
- # Replace Audio Slow Fade In
- for line in fileinput.FileInput(mainGTKFile, inplace=1):
- string_found = False
- if (not string_found) and (audioFadeInSlowOld in line):
- line=line.replace(audioFadeInSlowOld,audioFadeInSlowNew)
- string_found = True
- print line,
- else:
- print line,
- # Replace Audio Slow Fade Out
- for line in fileinput.FileInput(mainGTKFile, inplace=1):
- string_found = False
- if (not string_found) and (audioFadeOutSlowOld in line):
- line=line.replace(audioFadeOutSlowOld,audioFadeOutSlowNew)
- string_found = True
- print line,
- else:
- print line,
- # Replace Video Slow Fade In
- for line in fileinput.FileInput(mainGTKFile, inplace=1):
- string_found = False
- if (not string_found) and (videoFadeInSlowOld in line):
- line=line.replace(videoFadeInSlowOld,videoFadeInSlowNew)
- string_found = True
- print line,
- else:
- print line,
- # Replace Video Slow Fade Out
- for line in fileinput.FileInput(mainGTKFile, inplace=1):
- string_found = False
- if (not string_found) and (videoFadeOutSlowOld in line):
- line=line.replace(videoFadeOutSlowOld,videoFadeOutSlowNew)
- string_found = True
- print line,
- else:
- print line,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement