22 Replies Latest reply on Nov 25, 2016 8:41 AM by jacko14594222

    SCRIPTING for Premiere Pro

    johnt53984649 Level 2

      So there are plenty of tutorials for scripting in Adobe After Effects and lots of documentation.  But, as I understand, this isn't the situation for Adobe Premiere Pro.  I presume scripting is possible considering:

      69447b12e961459f9058620ab6164927.png

      But I have absolutely no idea how to get started.

       

      The end goal is to create a script that will look throughout all of my imported project files (for the current open Premiere Pro project) and then use the "replace footage" command to swap every file that meets a certain file name criteria with other files in a specified directory that meet the same criteria.  So, for example, if I have:

       

      DSTCNarration(1.1).flac

      DSTCNarration(1.2).flac

      DSTCBattle(BLURRED).mxf

      SlowYellowMotion(BACK).mxf

      DSTC(PREV).psd

       

      imported into my project, then, when the script is run, it should prompt the user for a new file directory, which I would then enter manually, and then the script should automatically replace the five files above with five different files in the new specified directory by searching for files names based on certain file name criteria:

       

      ARBITRARYNarration(1.1).flac

      ARBITRARYNarration(1.2).flac

      ARBITRARY(BLURRED).mxf

      ARBITRARY(BACK).mxf

      ARBITRARY(PREV).psd

       

      And then if there are two files that meet the criteria or there isn't a file that meets the criteria, it could just return an error while still carrying out whatever other replacements that it can.

       

      A script like this could save me tons of time.  Rather than having to use "replace footage" for every clip individually and constantly navigating back to the same folder, it could all be done in one go for all of the files (as long as my new files are named appropriately).

       

      So, is this even possible?  Is scripting in Premiere Pro this advanced even possible?  If so, how should I go about figuring out how to get a script to do this?  Would creating a plugin be more suitable for something like this?  Can any of you write a script that would do this?

        • 1. Re: SCRIPTING for Premiere Pro
          Jim_Simon Level 8

          I presume scripting is possible

           

          I don't believe it is in PP, only in AE.

          • 2. Re: SCRIPTING for Premiere Pro
            johnt53984649 Level 2

            I've found some forums saying that scripting is possible in Premiere but there's just minimal documentation.  Even if this is possible with a script, how difficult would it be to develop a plugin that does this?

            • 3. Re: SCRIPTING for Premiere Pro
              R Neil Haugen Adobe Community Professional & MVP

              I've never heard of  someone actually pulling off scripting in PrPro ... not that I'm a great expert, but having been around these forums quite a bit over the last few years, and getting some fascinating time at NAB listening to heavy AE fellas comparing scripts and lamenting they couldn't do this within PrPro, I don't know that it is feasible.

               

              As to developing a plug-in, well ... for that you'd need a decent coder who can decipher the PrPro programming, the released SDK's I suppose, anything like that, and take a guesstimate.

               

              Good luck  ... not sure anyone here has the tool-set and the interest, however.

               

              Neil

              • 4. Re: SCRIPTING for Premiere Pro
                Thomas_Szabo Level 3

                Hi, scripting in Premiere is possible.

                Therefore you would have to use Adobe´s Panel APIs. You basically create an HTML5 file with some buttons that trigger some scripting.

                 

                Once you have the HTML Panel with some buttons running, you start to communicate with Premiere using ExtendScript (which is the actual API to Premiere). ExtendScript is very similar to JavaScript. I´ve put a sample Panel together for you which should get you pretty far:

                GitHub - ThomasSzabo/Minimalistic-Adobe-Premiere-Pro-Panel: This Premiere extension is a minimum in order to run a Panel…

                 

                You can read about this here: CEP 6 HTML Extension Cookbook for CC 2015 · Adobe-CEP/CEP-Resources Wiki · GitHub

                Also please check the PPro Sample extension here: Samples/PProPanel at master · Adobe-CEP/Samples · GitHub

                1 person found this helpful
                • 5. Re: SCRIPTING for Premiere Pro
                  Ann Bens Adobe Community Professional & MVP

                  moving thread to Premiere SDK

                  • 6. Re: SCRIPTING for Premiere Pro
                    johnt53984649 Level 2

                    Thank you.  I was able to get the panel into Premiere, so now it's just a matter of making it do what I want to.  I haven't had too much time to play around with it yet.  In the meantime, do you know of any documentation whatsoever of Premiere Pro, perhaps similar to (not necessarily official) what we have for After Effects?

                    http://blogs.adobe.com/wp-content/blogs.dir/48/files/2012/06/After-Effects-CS6-Scripting-G uide.pdf?file=2012/06/After-Ef…

                    Even if somebody else put it together, something like that for Premiere would be extremely helpful for me.

                    • 7. Re: SCRIPTING for Premiere Pro
                      Thomas_Szabo Level 3

                      There is no documentation but the CEP Cookbook and the Samples.

                      I recommend to read through the Cookbook to get a basic understanding (even if  some of this stuff doesn´t make sense yet). Then focus on what you want to achieve and search the PPro Sample Code for examples. The Sample Panel covers 70-80% of the APIs in practical way.

                       

                      In your case it´s a combination of using

                      • getMediaPath() - returns a media file´s path
                      • canChangeMediaPath()
                      • changeMediaPath()

                       

                      In the PProPanel Sample, there is a function that you should take a closer look: "replaceMedia"

                      I hope this helps.

                      Thomas

                      1 person found this helpful
                      • 8. Re: SCRIPTING for Premiere Pro
                        johnt53984649 Level 2

                        Would it be possible to create a script that only does one function so that it could be assigned to a keyboard shortcut?  I'm not sure that I want to go through all the trouble of creating a panel for a script designed to only do one thing.

                        • 9. Re: SCRIPTING for Premiere Pro
                          johnt53984649 Level 2

                          I have successfully created the script I was looking for thanks to your help.  If interested, here's the final version:

                           

                          var BCV_File_Suffix = ["(PREV).psd", "(BACK).mxf", "(BATT).mxf", "1.1(NARR)_Fixed.flac", "2.1(NARR)_Fixed.flac"];

                           

                          for (j = 0; j <= 4; j++)

                          {

                             

                          for (i = 0; i <= app.project.rootItem.children.numItems; i++)

                          {

                               var BCVchild = app.project.rootItem.children[i];

                               if (!BCVchild) continue;

                               var mediaPath = BCVchild.getMediaPath();

                           

                               if (mediaPath && mediaPath.length > 0 && mediaPath.indexOf(BCV_File_Suffix[j]) > -1)

                               {

                                  var BCVpath = (app.project.path).toString().replace(/\\/g, '\\').replace('\\\\?\\','').replace('(PROJ).prproj',BCV_File_Suffix[j])

                                  app.project.rootItem.children[i].changeMediaPath(BCVpath);

                                  app.project.rootItem.children[i].name = app.project.name.replace('(PROJ).prproj',BCV_File_Suffix[j])

                               }

                          }

                          }

                           

                          Thank you so much!  The only downside to what I have here is that it requires the prefix of every file's name to be the same as the prefix of the name of the Premiere Project File, but I guess that's a good thing in terms of keeping me organized.  I don't think a wildcard would work in place of the prefix of every file since that would require the script to search through the directory to use any file containing the specified suffix.  Maybe I'm wrong, but I'm happy with what I have.

                           

                          Now the question is, it is possible to assign this script to a keyboard shortcut within Premiere Pro?

                          • 10. Re: SCRIPTING for Premiere Pro
                            jingtaotan Level 1
                            Now the question is, it is possible to assign this script to a keyboard shortcut within Premiere Pro?

                             

                            I don't think you can directly assign an ExtendScript to a keyboard shortcut in Premiere. Bruce Bullis would be able to confirm that.

                             

                            But, here is another way you may be able to achieve it.

                             

                            You will need to create a CEP HTML extension. This extension can either provide some UI for your user (in the form of a dockable panel, or a floating window), or it can also have no visible UI. Probably what you want will be an invisible extension. You can refer to these samples:

                             

                            The famous PProPanel maintained by Bruce Bullis, which demonstrates the many Premiere APIs that you can use:

                            Samples/PProPanel at master · Adobe-CEP/Samples · GitHub

                             

                            Sample of an invisible extension with no UI (this one runs a mini HTTP server on Premiere launch):

                            Samples/CEP_HTML_Invisible_Extension at master · Adobe-CEP/Samples · GitHub

                            This invisible extension will auto-start when Premiere starts, load up a HTML page and execute the JavaScript in it.

                             

                            In your invisible extension, call the CEP API function described here:

                            CEP-Resources/CEP_6.1_HTML_Extension_Cookbook.pdf at master · Adobe-CEP/CEP-Resources · GitHub

                            Search for "Register an interest in specific key events"

                            1 person found this helpful
                            • 11. Re: SCRIPTING for Premiere Pro
                              Bruce Bullis Adobe Employee

                              Jing Tao Tan wrote:

                               

                              Now the question is, it is possible to assign this script to a keyboard shortcut within Premiere Pro?

                               

                              I don't think you can directly assign an ExtendScript to a keyboard shortcut in Premiere. Bruce Bullis would be able to confirm that.

                              I can confirm; no, you cannot.

                               

                              Thomas Szabo's answers [above] are excellent.

                               

                              PProPanel sample code is the best documentation; feel free to ask specific questions.

                              • 12. Re: SCRIPTING for Premiere Pro
                                johnt53984649 Level 2

                                Well it looks like I'll have to teach myself how to build that panel if I want to make the script I wrote easily accessible during my regular editing sessions.  Oh boy!  I appreciate all the help I've received from everybody so far.  I'll let you know how building the panel goes when I get around to it.

                                • 13. Re: SCRIPTING for Premiere Pro
                                  jacko14594222 Level 1

                                  Hello everybody !

                                   

                                  I'm just discovering how hazardous it is to try some scripting with Premiere Pro but maybe some of you can give me a hand on my issue ?

                                   

                                  For the needs of documentary series, I'm trying to figure if a Version Up plugin is something which can be scripted.

                                  I mean, imagine that I got a project window full of shots named like this.

                                   

                                  E02_100_v001

                                  E02_255_v004

                                  E02_300_v002

                                   

                                  Each of those shots are individuals folders (E02_100_V001 is in the E02_100's folder, E02_255_V004 in the E02_255's folder...)

                                  I want to create a script/plugin that allows me to, when I select those, replace them with the next version if there is one.

                                  In the example above, my artists just uploaded me a new version for E02_255 and E02_300, in the same folders. So when I select all of my shots in my project windows and run my Script, my shots are now...

                                   

                                  E02_100_v001

                                  E02_255_v005

                                  E02_300_v003

                                   

                                  Does it sound possible to you ?

                                   

                                  Sorry for my english, I'm trying to make myself as clear as I can...

                                  • 14. Re: SCRIPTING for Premiere Pro
                                    Bruce Bullis Adobe Employee

                                    Sounds possible. A panel can

                                     

                                    • get the path of any projectItem
                                    • look around in the file system, for directories with interesting names
                                    • make new bins with interesting names
                                    • import updated footage into new bins
                                    • Replace the usage of projectItem[original] with projectItem[updated], in sequences
                                    • 15. Re: SCRIPTING for Premiere Pro
                                      jacko14594222 Level 1

                                      Hi Bruce !

                                       

                                      Thanks for the tips ! I succeeded in installing the ProPanel and I'm using this, the CEP 6 and the api_doc to write what I want to do.

                                      However, I'm a little stuck when it comes to look around in the file system.

                                       

                                      For the moment, I'm asking him to take each selected media, isolate their extension (v003 for an example) but how can I say :
                                      "Get in its MediaPath Folder and look if there is the same file name with an updated extension"

                                       

                                      Any ideas ?

                                      • 16. Re: SCRIPTING for Premiere Pro
                                        Bruce Bullis Adobe Employee

                                        Yes!

                                         

                                        You can do OS path manipulation from within JavaScript; Node.js also has helpful path processing tools.

                                         

                                        ExtendScript's File and Folder objects can be useful as well; search for "JavaScript Tools Guide CC.pdf", in ExtendScript Toolkit's /SDK directory.

                                        1 person found this helpful
                                        • 17. Re: SCRIPTING for Premiere Pro
                                          jacko14594222 Level 1

                                          I'll have a look ! Thanks ! Keep you posted.

                                          • 18. Re: SCRIPTING for Premiere Pro
                                            jacko14594222 Level 1

                                            So ! I've done a first version of what I wanted to do but....Even if my code don't crash, if my button is there and if Extendscript don't find any mistakes, I must have made one anywhere cause when I hit the button....nothing happens. Can I have your opinion ?

                                             

                                            Here's my Script.

                                             

                                            --------------------------------------------------------------------------

                                             

                                            $._VERSIONUP_={

                                               

                                                    VersionUp : function() {

                                                       

                                                        var SelectedItems = app.project.SelectedItems;

                                                       

                                                        for (i=0; i <= SelectedItems-1; i++)

                                                       

                                                        {

                                                            currentItem = SelectedItems[i];

                                                            var lastIndex = currentItem.MediaPath.lastIndexOf("_");

                                                            var extension = currentItem.MediaPath.substr(lastIndex + 1);

                                                            var UpItem = File.(currentItem.MediaPath.slice(0,(lastIndex+1))+(escape(extension)+1) + ".mov");

                                                           

                                                            if (currentItem &&

                                                                currentItem.canChangeMediaPath() &&

                                                                UpItem.exists)

                                                                {                       

                                                                    currentItem.changeMediaPath(UpItem);

                                                                    currentItem.name = UpItem.name;

                                                                    }

                                                            else {

                                                                alert("No Version above" + currentItem.name);

                                                                }

                                                            }

                                                        }   

                                            }                      

                                             

                                            -------------------------------------------------------------------------

                                            Maybe I've made some beginner's mistake...Has I said, I'm pretty new to the coding stuff...              

                                            • 19. Re: SCRIPTING for Premiere Pro
                                              jacko14594222 Level 1

                                              I've got some news !

                                               

                                              I succeed in creating a script that takes all the Items of the Project, looks at the source folder and their version number, and then replace them and their names if an up version is available. Otherwise, it's telling a little alert "No Up Version available for *name of the shot*

                                               

                                              The last little thing I want to do is to play this script only for some selected Media. And not all of them. Is there any command to do the trick ?

                                              • 20. Re: SCRIPTING for Premiere Pro
                                                Bruce Bullis Adobe Employee

                                                There is currently no API for determining what the selection is, in the project panel. [It's been requested; I'm adding your vote.]

                                                 

                                                Workaround = User puts projectItems to be processed into a bin with a magical name; "ProcessWithJack'sScript' or something.

                                                • 21. Re: SCRIPTING for Premiere Pro
                                                  jacko14594222 Level 1

                                                  Hi Bruce !

                                                   

                                                  Actualy, using a code found in the PProPanel, I scripted what I wanted but working on the Clips.

                                                   

                                                  So if one or more clips are selected and the VersionUp button is hit, all those clips will be updated with the next v+1 version.

                                                  My very last challenge is to make sort of a loop to tell to Premiere : if v002 doesn't exists, check for v003, v004,v005 without creating an infinite loop. Seems easier than the previous challenges but it's early in the morning so....well...I'm still searching.

                                                  • 22. Re: SCRIPTING for Premiere Pro
                                                    jacko14594222 Level 1

                                                    All done !

                                                     

                                                    Finally !

                                                     

                                                    Thanks to Thomas Szabo for his useful tips !