When we are using python moviepy to convert videos, we should notice the codecs supported by moviepy. In this tutorial, we will introduce these codecs supported by moviepy.
codecs supported by python moviepy
Python moviepy calls ffmpeg to convert or write video files. Any codec supported by ffmpeg can be used in python moviepy.
In order to know these codecs, you can view this full list.
Common codecs used in python moviepy
There are some common used codecs in moviepy, they are:
(default in moviepy)
|.mp4||makes well-compressed videos (quality tunable using ‘bitrate’)|
to ‘libx264’, and produces higher quality videos by default
a video of perfect quality, of possibly very huge size
|png||.avi||produce a video
of perfect quality, of smaller size than with’ rawvideo’
|libvorbis||.ogv||a nice video
format, which is completely free/ open source. However not
everyone has the codecs installed by default on their machine
|libvpx||.webm||tiny a video
format well indicated for web videos (with HTML5)
How to use codec in python moviepy?
Here is an example:
import moviepy.editor as mp clip = mp.VideoFileClip("1.gif") clip.write_videofile("1.avi", codec='rawvideo') clip.close()
We can run a moviepy function by passing codec.