Understand codecs Supported by Python MoviePy – Python MoviePy Tutorial

By | October 9, 2020

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.

A Full List of codecs Supported by ffmpeg

Common codecs used in python moviepy

There are some common used codecs in moviepy, they are:

codec file extension description
libx264

(default in moviepy)

.mp4 makes well-compressed videos (quality tunable using ‘bitrate’)
mpeg4 .mp4 an alternative
to ‘libx264’, and produces higher quality videos by default
rawvideo .avi produce
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.

Leave a Reply