# Creating Instagram Videos from Images

Uploading Videos in Instagram is tricky, not every format is supported and the format needs to fulfil some video specifications. Here we get into the recipe for creating a proper video for instagram from a sequence of images.

In order to create a mp4 slideshow or video from a sequence of frames you can use ffmpeg, which is a common multimedia framework and command-line tool for decoding, encoding, converting and other functions usefull for working with various media formats. The command for creating a slideshow from a set of frames is

ffmpeg -i frame_%04d.png output.mp4


which creates a mp4 from images enumerated as (frame_0000, frame_0001, …), where %04d or %4d specifies enumerations prepended with zeros. Enumerations without zeros are specified by %d. This output video cannot be used for instagram, so we need to add further specifications to our command in order to be able to upload it on instagram. The resulting command is

ffmpeg -r 30 -i frame_%04d.png -c:v libx264 -c:a aac -ar 44100 -pix_fmt yuv420p output.mp4


In this command we specify the video codec with -c:v libx246 the H.264 codec. The audio codec is denoted with -c:a aac -ar 44100 which applies the AAC codec with 44100 Hz audio sampling frequency. The framerate can be specified with the -framerate or -r and is by default 25 fps. The -pix_fmt flag specifies the pixel format where we need the yuv420p format which is specifies a color sampling in YUV. A list of requirements can be found in the Instagram Video Requirements.

Image from New Old Stock