5 Replies Latest reply on Apr 17, 2017 10:40 PM by justin2taylor

    How to tell if a File is Being Rendered/Written to

    justin2taylor Level 1

      I've been trying to prevent my panel from importing files that are currently being rendered to avoid Premiere Pro throwing an "Cannot Import" error.


      I've tried:

      • Comparing the modified date of the file (File.modified) to the current date, and half the time this works, but the other half the modified date won't update enough to be a reliable indicator.
      • Getting the file size with File.length and then getting the size again after a 1 second .setTimeOut, but that also yielded inconsistent results.
      • I attempted BridgeTalk() to get the names of rendering files in After Effects or AME, but I can't return values from AE until the render is finished, which defeats the purpose.
      • I've also tried filtering files by attributes of readOnly, open, write access, rename access, path change access, and others, but nothing seems to consistently differentiate a file that is currently rendering from one that is complete.

      Does anyone have a method to use that can distinguish a file that is currently being rendered/written to from a completed file? All thoughts are appreciated.





        • 1. Re: How to tell if a File is Being Rendered/Written to
          jingtaotan Level 1

          Hey Justin,


          We also develop a panel extension which provides functionality similar to what you described. In our case, we allow users to import from our MAM (via our panel) files which are still being rendered / are growing.


          What we found is that AME will (depending on the output format you choose) encode the audio and video streams separately, then combine them together into the final output file. To fix this we resorted to creating our own codecs for AME which will encode files in a growing manner so that growing file workflows, work.


          I don't have specific details of how our custom codecs were created - but I'm sure Bruce Bullis can help you with that.


          Other than changing the way AME works, you could set a flag somewhere (in code, in a database, or in a text file next to the rendered video) to indicate that the video file is still being rendered, and unset the flag when your panel knows that the render has finished (not great, obviously). We also do this for users who don't want a growing workflow to prevent our MAM system from trying to work with the file while it is still being rendered.



          1 person found this helpful
          • 2. Re: How to tell if a File is Being Rendered/Written to
            Bruce Bullis Adobe Employee

            If your panel is in charge of those renders, then you will know when the render is complete.

            • 3. Re: How to tell if a File is Being Rendered/Written to
              justin2taylor Level 1

              jingtaotan I appreciate you explaining your workaround! I also found the split streaming with certain codecs and was able to filter those out of my auto importing, however I couldn't rely on that as an indicator since my studio and I often render ProRes files which render as one file, yet can't be imported by Premiere until they're fully saved. I'm thinking that a sidecar file would be the only reliable way between Adobe apps, but it would be nice to recognize if any file is still rendering from other programs such as Da Vinci Resolve and Cinema 4D as well.


              Bruce Bullis, this is why I'm in search of an external method, I want to filter all rendering files from all Adobe and non-Adobe applications. For now I'm just letting Premiere catch the items that slip through my catch statments, but would like to find a solid solution for this in the future.


              It seems like if Premiere can realize the file structure is incomplete (aka still rendering) and thus stops you from importing it, there must be a universal way to tell if a file is completely rendered or still rendering...

              • 4. Re: How to tell if a File is Being Rendered/Written to
                jingtaotan Level 1

                Sounds like a neat workflow you got there justin2taylor


                One thing just crossed my mind... what about using NodeJS to watch for file changes? Granted, you'll be "staring" at the file for some time before you can determine if it's actually growing or not, which means delaying your user's import operation.


                File System io.js v1.2.0 Manual & Documentation

                Here's a link to the API docs for the version of "Node" / io.js which is used in the current version of Premiere. Seems like there's some caveats mentioned there for the fs.watch and fs.watchFile functions

                1 person found this helpful
                • 5. Re: How to tell if a File is Being Rendered/Written to
                  justin2taylor Level 1

                  jingtaotan Thanks for the recommendation! I have heard a lot about NodeJS, I'll definitely take a look at that API and see if it's something that could work.