

I’m assuming here that your shell knows the complete path to it. Let’s break down this command and its constituent arguments. $ ffmpeg -i benji.gif -f mp4 -pix_fmt yuv420p benji.mp4 Say you have a gif of my ancient, computer illiterate pug, Benji, and you want to convert it to a video format. The easiest way to do that is to go here and find a static build for whatever platform you’re working on. To follow along you’ll need FFmpeg installed. In that light, I wrote this post to share and explain some of its functionality, especially as it relates to GIF transcoding. Maybe you can read the documentation and make some sense of it, or maybe you feel the same way about reading words as me. It’s packed with an enormous amount of functionality. It supports the most obscure ancient formats up to the cutting edge.” “FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. For those of you who are unfamiliar, in their words: If you’ve worked with media encoding in the past decade it’s likely that you’ve come across FFmpeg. The next 420x360x3 bytes afer that will represent the second frame, etc.To follow along, download media files here:

If the video has a size of 420x320 pixels, then the first 420x360x3 bytes outputed byįFMPEG will give the RGB values of the pixels of the first frame, line by line, top to bottom. Now we just have to read the output of FFMPEG. It can be omitted most of the time in Python 2 but not in Python 3 where its default value is pretty small. In sp.Popen, the bufsize parameter must be bigger than the size of one frame (see below).

The format image2pipe and the - at the end tell FFMPEG that it is being used with a pipe by another program. In the code above -i myHolidays.mp4 indicates the input file, while rawvideo/rgb24 asks for a raw RGB output. Import subprocess as sp command = pipe = sp.
