Glad to have you looking at the SDK. You may be able to find an external code library on the internet that supports motion blur and other effects. But the Premiere Pro API doesn't provide such functionality for you - that's your job as the plug-in developer! If you do find such a library that you can reuse, that would definitely speed up your development time, and then you would be left to focusing on integrating that library into a transition plug-in.
You can start from the transition sample in the SDK, by modifying the RenderDissolve32f() function. RenderDissolve32f() is a plugin-defined function that does the actual rendering when the transition is asked to render at 32-bit floating point precision. Each channel of VUYA or BGRA is represented by a 32-bit float value. You'll notice there is no RenderDissolve8u() function for 8-bit rendering. That's because the StretchBits() callback defined in the PPro API works quite nicely for doing a simple blend at 8-bits per channel, and this takes care of the 8-bit render code path.
For effects like blurs, your render code will need to look at multiple source pixels just to calculate a single pixel in the destination or output buffer. If for example your transition uses a horizontal blur, each output pixel will be based on input pixels to the left and right of that pixel in the input. To access these pixels, you'll want to be familiar with how video frames are represented in PPro, which is described in chapter 3 of the SDK Guide, in the subheading "Video Frames".
For effects like motion blurs, you can ask PPro to give you frames at times other than the current frame being rendered. See the DemoUsingCallback() function for an example of that.
Hope this helps,
Great summary Zac.
Jaap, I’d google to see if you can find some open source motion estimation code. A motion estimation is required to know along what vector you want to blur the pixels. For accuracy you’ll probably need to look at more than frame n & n-1. When the motion estimation numbers become too large you have probably detected a scene change and can dump the motion blur for that frame.
I looked at doing this in silicon back in the mid 90’s because I noticed that a friend that did TV commercials using animation badly needed it to look real. Back then there wasn’t enough processing power to do it at more than fractional frames per second (ie 1:100 of real-time) even in Standard Definition so it was basically unusable. Anyhow their wasn’t motion estimation code available at that time and I didn’t commit to developing it and putting it into silicon so the project died.
Needing silicon to do it is not the case these days. You should be able to do real-time HD or 2k or 4k. if it turns out that the motion estimation code is highly computational and parallel’able I’d look at using the nVidia CUDA SDK to accelerate the calculations. If it’s not highly computational I’d look at using the Intel SSE,SSE2,SSE3 etc intrinsics to do some SIMD calculations that way otherwise it’s going to run 4 to 8 times slower than it should.
Hi Zac and Rallymax,
Thank you for your answers.
I was affraid PP SDK doesn't supply the sourcecode for doing effects like blur and motionblur.
But I understand it's probably better to have the plugin developer write them theirselves for speed and effective usability.
The reason I'm asking because I'm used to FX-Script in Final Cut Pro. This makes it possible to make plugins or transition with a fairly easy scripting language.
This way there is more time for designing, rather than getting into C++ and rewriting all kinds of effects, that are written by many before.
But I still think it's fun to write plugins for PP. Because while I'm getting into it, I find it not that hard to write effects.
I found this article that really helps me to get a fast and smooth blur function to my future plugins.
An efficient algorithm for Gaussian blur using finite-state machines