Advertisement
clockworkpc

Change Default Fade In/Out in OpenShot

Feb 19th, 2013
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.88 KB | None | 0 0
  1. #!/usr/bin/python
  2. #/home/<username>/bin/fadeinouthack.py
  3.  
  4. # Released under a GPLv3 Licence by Clockwork PC 2012
  5. # www.clockworkpc.com.au
  6.  
  7. # You are entitled to the following four freedoms:
  8. # Freedom 0: To run this program for any purpose
  9. # Freedom 1: To study how this program works and change it to make it do what you wish
  10. # Freedom 2: To redistribute copies so you can help your neighbour
  11. # Freedom 3: To distribute copies of your modified version to others
  12.  
  13. import os
  14. import fileinput
  15.  
  16. #Location of MainGTK.py, which is where the Fade In and Fade Out defaults are set
  17. mainGTKFile = os.getenv("HOME") + "/usr/share/pyshared/openshot/windows/MainGTK.py"
  18.  
  19. #Location of dummy MainGTK.py
  20. mainGTKDummyFile = os.getenv("HOME") + "/bin/MainGTK.py"
  21. mainGTKDummyFileTemp = os.getenv("HOME") + "/bin/MainGTK_temp.txt"
  22.  
  23. #Make a backup of MainGTK (of course!)
  24. os.system("cp " + mainGTKFile + " " + mainGTKDummyFileTemp)
  25.  
  26. #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.
  27. oldFadeFast = "2.0"
  28. oldFadeSlow = "4.0"
  29.  
  30. #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.
  31. newFadeFast = raw_input("How many seconds do you want the Fast Fade In/Out to be? ") + ".0"
  32. newFadeSlow = raw_input("How many seconds do you want the Slow Fade In/Out to be? ") + ".0"
  33.  
  34. #Just to be on the safe side, not necessary.
  35. print "newFadeFast is... " + newFadeFast
  36. print "newFadeSlow is... " + newFadeSlow
  37.  
  38. #Audio Fade Fast Old
  39. audioFadeInFastOld = "self.selected_clip.audio_fade_in_amount = " + oldFadeFast
  40. audioFadeOutFastOld = "self.selected_clip.audio_fade_out_amount = " + oldFadeFast
  41.  
  42. #Audio Fade Slow Old
  43. audioFadeInSlowOld = "self.selected_clip.audio_fade_in_amount = " + oldFadeSlow
  44. audioFadeOutSlowOld = "self.selected_clip.audio_fade_out_amount = " + oldFadeSlow
  45.  
  46. #Video Fade Fast Old
  47. videoFadeInFastOld = "self.selected_clip.video_fade_in_amount = " + oldFadeFast
  48. videoFadeOutFastOld = "self.selected_clip.video_fade_out_amount = " + oldFadeFast
  49.  
  50. #Video Fade Slow Old
  51. videoFadeInSlowOld = "self.selected_clip.video_fade_in_amount = " + oldFadeSlow
  52. videoFadeOutSlowOld = "self.selected_clip.video_fade_out_amount = " + oldFadeSlow
  53.  
  54. #Audio Fade Fast New
  55. audioFadeInFastNew = "self.selected_clip.audio_fade_in_amount = " + newFadeFast
  56. audioFadeOutFastNew = "self.selected_clip.audio_fade_out_amount = " + newFadeFast
  57.  
  58. print "audioFadeInFastNew: " + audioFadeInFastNew
  59. print "audioFadeOutFastNew: " + audioFadeOutFastNew
  60.  
  61. #Audio Fade Slow New
  62. audioFadeInSlowNew = "self.selected_clip.audio_fade_in_amount = " + newFadeSlow
  63. audioFadeOutSlowNew = "self.selected_clip.audio_fade_out_amount = " + newFadeSlow
  64.  
  65. print "audioFadeInSlowNew: " + audioFadeInSlowNew
  66. print "audioFadeOutSlowNew: " + audioFadeOutSlowNew
  67.  
  68. #Video Fade Fast New
  69. videoFadeInFastNew = "self.selected_clip.video_fade_in_amount = " + newFadeFast
  70. videoFadeOutFastNew = "self.selected_clip.video_fade_out_amount = " + newFadeFast
  71.  
  72. print "videoFadeInFastNew: " + videoFadeInFastNew
  73. print "videoFadeOutFastNew: " + videoFadeOutFastNew
  74.  
  75. #Video Fade Slow New
  76. videoFadeInSlowNew = "self.selected_clip.video_fade_in_amount = " + newFadeSlow
  77. videoFadeOutSlowNew = "self.selected_clip.video_fade_out_amount = " + newFadeSlow
  78.  
  79. print "videoFadeInSlowNew: " + videoFadeInSlowNew
  80. print "videoFadeOutSlowNew: " + videoFadeOutSlowNew
  81.  
  82. # Replace Audio Fast Fade In
  83. for line in fileinput.FileInput(mainGTKDummyFile, inplace=1):
  84.     string_found = False
  85.     if (not string_found) and (audioFadeInFastOld in line):
  86.             line=line.replace(audioFadeInFastOld,audioFadeInFastNew)
  87.             string_found = True
  88.             print line,
  89.     else:
  90.             print line,
  91.                    
  92. # Replace Audio Fast Fade Out
  93. for line in fileinput.FileInput(mainGTKFile, inplace=1):
  94.     string_found = False
  95.     if (not string_found) and (audioFadeOutFastOld in line):
  96.             line=line.replace(audioFadeOutFastOld,audioFadeOutFastNew)
  97.             string_found = True
  98.             print line,
  99.     else:
  100.             print line,
  101.  
  102. # Replace Video Fast Fade In
  103. for line in fileinput.FileInput(mainGTKFile, inplace=1):
  104.     string_found = False
  105.     if (not string_found) and (videoFadeInFastOld in line):
  106.             line=line.replace(videoFadeInFastOld,videoFadeInFastNew)
  107.             string_found = True
  108.             print line,
  109.     else:
  110.             print line,
  111.  
  112. # Replace Video Fast Fade Out
  113. for line in fileinput.FileInput(mainGTKFile, inplace=1):
  114.     string_found = False
  115.     if (not string_found) and (videoFadeOutFastOld in line):
  116.             line=line.replace(videoFadeOutFastOld,videoFadeOutFastNew)
  117.             string_found = True
  118.             print line,
  119.     else:
  120.             print line,
  121.  
  122. # Replace Audio Slow Fade In
  123. for line in fileinput.FileInput(mainGTKFile, inplace=1):
  124.     string_found = False
  125.     if (not string_found) and (audioFadeInSlowOld in line):
  126.             line=line.replace(audioFadeInSlowOld,audioFadeInSlowNew)
  127.             string_found = True
  128.             print line,
  129.     else:
  130.             print line,
  131.  
  132. # Replace Audio Slow Fade Out
  133. for line in fileinput.FileInput(mainGTKFile, inplace=1):
  134.     string_found = False
  135.     if (not string_found) and (audioFadeOutSlowOld in line):
  136.             line=line.replace(audioFadeOutSlowOld,audioFadeOutSlowNew)
  137.             string_found = True
  138.             print line,
  139.     else:
  140.             print line,
  141.  
  142. # Replace Video Slow Fade In
  143. for line in fileinput.FileInput(mainGTKFile, inplace=1):
  144.     string_found = False
  145.     if (not string_found) and (videoFadeInSlowOld in line):
  146.             line=line.replace(videoFadeInSlowOld,videoFadeInSlowNew)
  147.             string_found = True
  148.             print line,
  149.     else:
  150.             print line,
  151.  
  152. # Replace Video Slow Fade Out
  153. for line in fileinput.FileInput(mainGTKFile, inplace=1):
  154.     string_found = False
  155.     if (not string_found) and (videoFadeOutSlowOld in line):
  156.             line=line.replace(videoFadeOutSlowOld,videoFadeOutSlowNew)
  157.             string_found = True
  158.             print line,
  159.     else:
  160.             print line,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement