How we can store an image or video digitally

ffmpeg is a well known command line tool that allow you to edit videos. You can edit not only a video file but also a video stream.

Probably its main function is to convert video format/codec.

There are many video codes and formats. But why?

A video is a sequence of images.

You can see objects in the images moving if an application shows these images in a proper order within a short time.

Ultimately the information a video requires is images and their order. (raw video)

A video normally contains a lot of information and its size is huge.

Because a image is a 2-dimendion array of pixels which consists of 3 (or 4) kinds of numbers (such as RGB, YUV).

For example, a 1080p image has 1920 pixels in width and 1080 pixels in height. It means that it has 2,073,600 (= 1920 x 1080) pixels.

A video contains a lot of images.

For example, a 5-minute 24-fps (frame per second) video contains 7,200 (5 *60 * 24) images which includes 14,929,920,000 pixels.

We usually compress a raw video by various compression algorithms which are called codec.

When we use a video “format”, (not codec) it includes subtitles, metadata(such as title) and audio data.

Examples of video format are “flv”, “avi”, “gif”, “mp4” and etc.

Examples of video codec are “H.264”, “WMV”, “VP9” and etc.