12 Replies Latest reply on Jun 28, 2013 10:43 AM by walczakb

    Dummy importer

    walczakb Level 1

      Hi folks,

       

      I'm trying to write a dummy importer that would essentially only put a file pointer in the project for reference and archival purposes, like FCP XML translations results text file which gets imported into the project.

       

      I thought that perhaps setting hasVideo and hasAudio as false would do the job, but I keep getting the "Importer returned generic error" in Premiere and "file cannot be imported - this file is damaged or unsupported".

       

      Currently the entry function looks like this:

           switch (selector)
           {
                case imInit:
                     result =     SDKInit(stdParms, 
                                              reinterpret_cast(param1));
                     break;
      
                case imGetInfo8:
                     result =     SDKGetInfo8(stdParms, 
                                                   reinterpret_cast(param1), 
                                                   reinterpret_cast(param2));
                     break;
      
                case imGetIndFormat:
                     result =     SDKGetIndFormat(stdParms, 
                                                        reinterpret_cast(param1),
                                                        reinterpret_cast(param2));
                     break;
      
                case imGetIndPixelFormat:
                     result = imUnsupported;
                     break;
      
                // Importers that support the Premiere Pro 2.0 API must return malSupports8 for this selector
                case imGetSupports8:
                     result = malSupports8;
                     break;
      
           }
      
           return result;
      }

       

      And only these 3 selectors are supported:

      imInit

      imGetFormat

      imGetIndFormat

       

      imInit and imGetIndFormat work fine, because the importer is added to the list, and attempts to open the file. And the imGetFormat looks like this:

       

                prMALError                         result                    = malNoError;
      
           SDKFileInfo8->hasAudio               = kPrFalse;
           SDKFileInfo8->hasVideo               = kPrFalse;
      
      
           return result;
      

       

      Obviously I'm missing something, can anyone help me?

        • 1. Re: Dummy importer
          Rallymax-forum Level 3

          IIRC you have to have one or both of hasVideo and hasAudio true.

          • 2. Re: Dummy importer
            Zac Lam Adobe Employee

            Hi walczakb,

             

            That's an interesting concept to add an importer for these files, but as Rallymax points out, the importer API is for video and/or audio.  Since you can just drag-and-drop a .txt file into the Project panel, it's possible you could make a script that sends .txt files to PPro.  Does that fit what you're trying to do?

             

            See this thread for importing a file using scripting - http://forums.adobe.com/thread/1177191

             

            Zac

            • 3. Re: Dummy importer
              walczakb Level 1

              Actually I'm trying to import a number of various files with various extensions, the txt file was an example on how it would work. The files are 3d models and scenes, doc files, etc., and this plugin is going to be used mostly in After Effects, not in Premiere.

               

              Something like a dummy OBJ file that you can import with Trapcode 2.0, just for other formats.

               

              Will it be enough then to set hasVideo to true and create imGetSourceVideo selector, or is there more to it? Can I use Drawbot to create the dummy frame?

               

              Thanks.

              • 4. Re: Dummy importer
                walczakb Level 1

                OK, I tried to copy parts of the synthethic importer to give Premiere/AE a black frame for the video. I keep getting the error.

                 

                Here's the whole code with the exception of all cases in imGetIndFormat. I have no idea what is wrong:

                 
                #include "SDK_File_Import.h"
                
                PREMPLUGENTRY DllExport xImportEntry (
                     csSDK_int32          selector, 
                     imStdParms          *stdParms, 
                     void               *param1, 
                     void               *param2)
                {
                     prMALError     result                    = imUnsupported;
                
                     switch (selector)
                     {
                          case imInit:
                               result =     SDKInit(stdParms, 
                                                        reinterpret_cast(param1));
                               break;
                
                          case imImportImage:
                               result =     SDKImportImage     (stdParms, reinterpret_cast(param1), reinterpret_cast(param2));
                               break;
                
                          case imGetInfo8:
                               result =     SDKGetInfo8(stdParms, 
                                                             reinterpret_cast(param1), 
                                                             reinterpret_cast(param2));
                               break;
                
                          case imGetIndFormat:
                               result =     SDKGetIndFormat(stdParms, 
                                                                  reinterpret_cast(param1),
                                                                  reinterpret_cast(param2));
                               break;
                
                          case imGetIndPixelFormat:
                               result =     SDKGetIndPixelFormat(stdParms,
                                                                       reinterpret_cast(param1),
                                                                       reinterpret_cast(param2));
                               break;
                
                          case imGetSupports8:
                               result = malSupports8;
                               break;
                
                     }
                
                     return result;
                }
                
                prMALError 
                SDKInit(
                     imStdParms          *stdParms, 
                     imImportInfoRec     *importInfo)
                {
                     importInfo->setupOnDblClk          = kPrFalse;          
                     importInfo->keepLoaded               = kPrFalse;
                     importInfo->priority               = 0;
                     return malNoError;
                }
                
                prMALError 
                SDKGetIndFormat(
                     imStdParms          *stdParms, 
                     csSDK_size_t     index, 
                     imIndFormatRec     *SDKIndFormatRec)
                {
                     prMALError     result          = malNoError;
                     char formatname[255]     = "Reference File";
                     char shortname[32]          = "Reference";
                     char platformXten[256];
                     SDKIndFormatRec->filetype               = 'CIR_';
                
                     switch(index)
                     {
                     case 0:          
                
                               #ifdef PRWIN_ENV
                               strcpy_s(platformXten,sizeof(platformXten), "doc\0\0");
                               strcpy_s(SDKIndFormatRec->FormatName, sizeof (SDKIndFormatRec->FormatName), formatname);                    // The long name of the importer
                               strcpy_s(SDKIndFormatRec->FormatShortName, sizeof (SDKIndFormatRec->FormatShortName), shortname);          // The short (menu name) of the importer
                               strcpy_s(SDKIndFormatRec->PlatformExtension, sizeof (SDKIndFormatRec->PlatformExtension), platformXten);     // The 3 letter extension
                               #else
                               strcpy(platformXten,"doc\0\0");
                               strcpy(SDKIndFormatRec->FormatName, formatname);               // The Long name of the importer
                               strcpy(SDKIndFormatRec->FormatShortName, shortname);          // The short (menu name) of the importer
                               strcpy(SDKIndFormatRec->PlatformExtension, platformXten);     // The 3 letter extension
                               #endif
                
                               break;
                     
                     default:
                          result = imBadFormatIndex;
                     }
                     return result;
                }
                
                
                prMALError 
                SDKGetInfo8(
                     imStdParms               *stdParms, 
                     imFileAccessRec8     *fileAccessInfo8, 
                     imFileInfoRec8          *SDKFileInfo8)
                {
                     prMALError                         result                    = malNoError;
                     ImporterLocalRec8H               ldataH                    = NULL;
                
                     SDKFileInfo8->hasAudio                    = kPrFalse;
                     SDKFileInfo8->hasVideo                    = kPrTrue;
                     SDKFileInfo8->vidInfo.depth               = 32;          // bits per pixel
                     SDKFileInfo8->vidInfo.noDuration     = imNoDurationStillDefault;          // A file with 'no duration' can be stretched in the timeline
                     SDKFileInfo8->vidInfo.isStill          = kPrTrue;     // A synth importer or still file importer might set this kPrTrue     
                     SDKFileInfo8->vidInfo.dontObscure     = kPrTrue;
                
                     if(SDKFileInfo8->privatedata)
                     {
                          ldataH = reinterpret_cast(SDKFileInfo8->privatedata);
                     }
                     else
                     {
                          ldataH                              = reinterpret_cast(stdParms->piSuites->memFuncs->newHandle(sizeof(ImporterLocalRec8)));
                          SDKFileInfo8->privatedata     = reinterpret_cast(ldataH);
                     }
                
                     return result;
                }
                
                prMALError
                SDKImportImage(
                     imStdParms               *stdParms, 
                     imFileRef               SDKfileRef, 
                     imImportImageRec     *imageRec)
                {
                     char*               src      = imageRec->pix;
                     csSDK_int32          high      = imageRec->dstHeight;
                     csSDK_int32          skip      = imageRec->rowbytes - (imageRec->dstWidth * 4);
                     csSDK_int32          wide     = 0;
                     prColor               pixel;
                
                     while(high)
                     {
                          wide  = imageRec->dstWidth;
                          pixel = 0xff000000;          
                
                          while(wide)
                          {
                               *(csSDK_int32 *)src      = pixel;
                               src                += 4;
                               wide--;
                          }
                          src += skip;
                          high--;
                     }
                     return imNoErr;
                
                }
                
                prMALError 
                SDKGetIndPixelFormat (
                     imStdParms *stdParms, 
                     csSDK_size_t index, 
                     imIndPixelFormatRec *pixelRec)
                {
                     prMALError resultS = imNoErr;
                
                     switch(index)
                     {
                          case 0:
                               pixelRec->outPixelFormat = PrPixelFormat_VUYA_4444_8u;
                               break;
                     
                          case 1:
                               pixelRec->outPixelFormat = PrPixelFormat_BGRA_4444_8u;
                               break;
                     
                          default:
                               resultS = imBadFormatIndex;
                               break;
                     }
                     return resultS;
                }
                
                
                • 5. Re: Dummy importer
                  Zac Lam Adobe Employee

                  I believe Trapcode Form's .obj support is implemented using an AEIO plug-in (from the After Effects SDK).  The AEIO probably exposes the 3D info via aux data, and the effect gets the aux data via PF_ChannelSuite which it uses for rendering.  The Premiere importer API doesn't support aux data, so I'm not sure if you were thinking of another mechanism in mind to pass non-visible frame data from the importer to an effect...?

                  • 6. Re: Dummy importer
                    walczakb Level 1

                    I don't want to pass anything to any effects.

                     

                    I only want to import a file to the project as a reference, so that it is later seen by the project manager/consolidate options.

                     

                    Premiere/AE should do no processing of the file at all. I don't even want it to read or touch the file.

                     

                    If I must, I will display the black frame, or ideally the plate with the text "Reference file".

                     

                    I tried modifying the synthethic importer to this effect, but it also gives me the generic error.

                    • 7. Re: Dummy importer
                      Zac Lam Adobe Employee

                      Oh I see.  The Synth_Importer is used for stuff like Color Mattes and Universal Counting Leaders, which reference no actual file on disk.  Since you want to reference a file, it'd be better to start from the SDK_File_Importer sample.  Granted, there will be more code to trim out for your purposes, but you'll be working with actual files on disk.

                      • 8. Re: Dummy importer
                        walczakb Level 1

                        Thanks, Zac, but I first started with SDK_File_Importer, and got the error.

                         

                        I then decided to approach the problem from the other end, thinking that perhaps I was missing something. But I got the same error.

                        • 9. Re: Dummy importer
                          Zac Lam Adobe Employee

                          One missing piece is in SDKGetInfo8, it doesn't specify the dimensions of the video. (This is not needed in Synth_Import because that defaults to the dimensions of the current sequence)  GetInfo8 is where the importer tells PPro details about the file it is about to import.

                          1 person found this helpful
                          • 10. Re: Dummy importer
                            walczakb Level 1

                            Thanks Zac. I added imageHeight and imageWidth, but unfortunately the problem still persists. Could the fact that I'm not referencing the file at all be problematic?

                             

                            I will try with AEIO, although it doesn't have the priority mechanism which would be perfect for this importer.

                            • 11. Re: Dummy importer
                              Zac Lam Adobe Employee

                              True, you'd need to handle opening the file in imOpenFile8, as well as imQuietFile and imCloseFile.

                              • 12. Re: Dummy importer
                                walczakb Level 1

                                OK, I'll give it a go as well, although it seems like the AEIO route proved to be much easier.