I'm new to ffmpeg (video encoding in general).
I have two videos one larger than the other. I want to rotate, resize and overlay the shorter video on the larger one at defined coordinates.
So far, I'm doing this:
- Add alpha channel to both the videos:
ffmpeg -i demo.mov -vcodec qtrle -pix_fmt argb demo.mov
- Define fadein, fadeout, scale, overlay, perspective and rotation then output the video:
ffmpeg -y -i demo.mov -i demo2.mov -filter_complex "[1:v] fade=in:10:1:alpha=1, fade=out:500:1:alpha=1, scale=80:80, perspective=x0=0:y0=0:x1=W:y1=40, rotate=-0.1745:c=none [ov]; [0:v][ov] overlay=100:100 [v]" -map "[v]" out.mov
In this process, I'm facing a few problems:
- Am I adding alpha channels the right way?
- The final output has flickering background in the place where the rotated video has margins.
- The overlay remains a square. I do not want it to be square, but of the dimension specified by
perspective
filter.
Some of the parameters in the above commands (such as perspective
,fade
) are arbitrary.
To give a better perspective of what I'm trying to do: trying to add a video as though it was being played on a phone that is moving.
I have asked about problems on IRC and got this far. I don't know how to proceed from here.
Here is the output: https://youtu.be/yd4UWq5NO5M
Any help would be great.