Welcome folks today in this blog post we will be using the moviepy
library to mirror
mp4 video file in x
and y
axis. All the full source code of the application is shown below.
Get Started
First of all we need to install the below moviepy
library using the pip
command as shown below
pip install moviepy
In order to get started you need to make an app.py
file and copy paste the following code
app.py
Mirroring MP4 Video in X-Axis & Y-Axis Direction
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# Import everything needed to edit video clips from moviepy.editor import * # loading video dsa gfg intro video clip = VideoFileClip("video.mp4") # getting subclip from the original video clip = clip.subclip(0, 10) # mirroring image according to the x axis clip = clip.fx(vfx.mirror_x) # showing final clip clip.ipython_display() |
As you can see we are importing the moviepy
library at the very top and then we are only taking the first 9
seconds of the input video using the subclip()
method and then we are applying the mirroring effect
on the video in the x-axis
direction using the fx()
method and inside it we are passing the constant which is vfx.mirror_x
for x direction. For Y-Axis you just need to write vfx.mirror_y
instead as shown below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# Import everything needed to edit video clips from moviepy.editor import * # loading video dsa gfg intro video clip = VideoFileClip("video.mp4") # getting subclip from the original video clip = clip.subclip(0, 10) # mirroring image according to the x axis clip = clip.fx(vfx.mirror_y) # showing final clip clip.ipython_display() |