Zooming animation in FFMPEG - ffmpeg

I need to make a zooming animation for a video input.
Making a panning animation is possible with the crop filter with something like this:
"crop=320:240:max(0\\,min(iw-ow\\,n)):0"
Where the first two parameters, width and height, are fixed, and the second two parameters, accept frame number n or timestamp t as expression parameters.
But width and height are evaluated only once (and cannot use n or t), so I cannot crop a size in function of time and then apply a scale filter to the original size.
I know I can:
Change the filter after pulling each frame from the buffersink (I'm not in the command line, I'm using the libraries in my software). I'm doing that already, but no for every frame, only by user request in an online application.
Use geq filter to "apply a generic equation to each frame".
Both approaches seem expensive. Is there another filter or approach I could use?
Note that I'm using zeranoe FFMPEG libraries in Windows. I'd rather not develop my own filters or modify FFMPEG source.

You can apply a simple zoom by adding
"zoompan=z='zoom+0.001'"
to your video filters. It will, by default, zoom in to the top left corner slowly. If you want to do something a little more advanced, you can add the x and y arguments to start getting a zoom in other directions and variable speeds. An example of
"zoompan=z='zoom+0.001':x='if(gte(zoom,1.5),x,x+1)':y='y'"
would go to the top right and
"zoompan=z='zoom+0.001':y='if(gte(zoom,1.5),y,y+1)':x='x'"
would go to the bottom left.

Related

Is it possible to draw a box into a video with the position specified for every single frame?

With this and this I know that it's possible to set filters that draw something on specific frames or with some simple function of the frame number, but what if I have a lookup table for x and y positions (and width and height) of a box I want to draw, one set for each frame?
Drawbox filter can accept all options as commands, so you could send these parameters to the filter with frame times, either with some pre-computed sendcmd filter, or from externally using the zmq filter.

How to not change other attributes while animating in Maya?

I am trying to change the scale and rotation of my object in specific key frames but it changes the object attributes throughout the animation and I do not want that,how do I resolve this problem?
I know its a stupid question but could not figure it out on my own ,so here we go...
Thinking about your question, without much information to go by, there could be a few reasons for your unexpected results.
attributes in question have no keyframe, changing the value is static during the animation and therefore will reflect on the whole time range. If an attribute is not highlighted with a red color in the channel box, then no keyframes exist on that channel.
your previous and next keyframe could be very far apart and the blend could therefore be creating undesired results. Add keyframes closer to the frame you keyed to have a shorter blend from one value to the other.
if you are looking for very quick and not blended changes in values, try setting the curves to stepped instead of linear blend. Even there you will have to have at least more than one key to have a change of value during the animation.
if you are working with animation layers, check whether you you are in additive or overwrite mode. In both cases you might have to create multiple keys.
in the bottom right of Maya there is a button called "Auto Keyframe". This one will create keyframes automatically when you change values, but will do so only on already keyed channels.
use the graph editor to see what's going on with your curves for the attributes in question (Windows - Animation - Graph Editor). Don't rely on the red ticks in the main timeline, as you can only see whether a keyframe exists but you can't tell for which attribute(s).

Is there a way to apply a curve bend in ffmpeg?

I have four cameras each feeding me a different portion of a basketball court. Due to the slight offset of the cameras physical locations and lens distortion around the edges of the camera, I cannot simply stitch the videos together without some kind of correction.
I've looked into ffmpeg's perspective filter, as well as the lenscorrection filter. In the former case it was only able to create a trapezoid, not the curved image I want. In the latter case using negative values to k1 and k2 seemed to be heading in the right direction, but it either disorted the top and bottom of the image to the point of being nonsensical noise, or it zoomed in to the image so much that I lost important details.
For the sample picture below, ultimately I want the midcourt line (the blue vertical line on the right side) to be vertical, and I want the mess of wires on the white desk at the bottom to remain visible and identifiable.
Given a video which looks like the following:
I wish to produce something like the following:
This image was made using the "Curve Bend" filter in GIMP, but I just eye-balled it - so it's not perfect. Ideally once I get the exact parameters the midcourt line will be perfectly vertical
When using the lenscorrection filter, no values for k1 and k2 seemed to get the effect I want:
Negative k1, negative k2:
Negative k1, positive k2:
Positive k1, negative k2:
Positive k1, positive k2:
In general:
negative / negative distorted the image beyond recognition
negative / positive looked alright, but the midcourt line was off the screen and it wasn't clear if any distortion had been applied
positive / negative looked the best, but while the top and bottom curved in the middle of the left and right actually bulged out, leaving the midcourt line distorted
positive / positive was the opposite of the desired effect
I wrote a post about this subject. Strangely enough I was also trying to undistort video of a basketball court.
There's a few options:
Try to find a standard projection (e.g. fisheye, stereographic, etc) that roughly matches the projection that your camera produces, and look up or measure the field of view of your camera. At that point you can use the new v360 filter to correct the image to a rectilinear projection (which is the one where straight lines in real life remain straight in the image).
Either find a database entry in lensfun for your camera, or create one (there are instructions in their documentation), or send pictures and ask the maintainers to do it. Then you can use the lensfun filter to accurately correct the distortion.
Lensfun is probably the best option if you want it to be accurate, but depending on your camera you might find v360 produces good enough results, and its significantly faster.
Short answer: No. FFMPEG does not have a curve bend function. That said, curve bend is not the proper solution, anyway. A lens correction is necessary, the parameters supplied were just way off.
Ultimately I just wrote a script to dump thousands of images using lensfun with different lenses, then skimmed them for one that looked good

How to get perspective coordinates from file for image overlay with ffmpeg?

Is it possible to do something like this purely with ffmpeg?
Lets say we have a text file with the frame by frame coordinates for the 4 corners where the image should go. ffmpeg has a perspective filter, but how would one get ffmpeg to pull the frame coordinates from the text file? I'm guessing with a pipe of sorts?
The perspective filter corrects the input's perspective, it doesn't apply a perspective effect. Applied to an overlay it results in a rectangular overlay with a corrected perspective.
The closest you can get with the already implemented filters is via the frei0r perspective module.
You can write your own filter for ffmpeg or a frei0r module.
Update: using #Mulvya's tip you can use timeline editing with perspective:
perspective=enable='eq(n,0)':x0=...,perspective=enable='eq(n,1)':x0=...
where n is the current frame number.
This will result in an impossibly long command line which may go over the system limit. You're still better writing your own filter.
You can alternatively do one frame at a time with a different command, save the output as an image and re-assemble the video at the end.

Adobe After Effects CC Transformation Speed

I have a logo, moving center of the screen to the left hand side of the screen. It's a fairly smooth transformation however I want the motion to start slowly, speed up to a maximum then slow back down before completing it's transformation. How can this be achieved? I have Googled but not found any luck, I think I'm just not using the correct search criteria
Thanks, Nick
Right click on a keyframe. You have a number of options available, including Keyframe Assistant> "Easy Ease". This gives you "slow-ins" and "slow-outs" to your keyframes. To increase the eases, right click on a keyframe, select "Keyframe Velocity...", and if the keyframe is the outgoing one (the first one), enter a greater value in the "outgoing influence" (like, say, 70%). Play around with these values. As usual, for anything in AE, there are several ways to accomplish a task. Two other ways of doing this are a) using the tangent controls in the Comp Viewer window, and b) using the graph editor (see graphic).

Resources