What is video encoding?
The term encoding is used to describe the process of converting content into a different form. (Like a spy will encode his message so that it cannot be read should it fall into the wrong hands.)
In the context of video - encoding technically only happens when the video is being recorded, and taken from the camera's raw format and saved into a codec. Any further manipulations of the video file (say changing the format, or changing compression values) is transcoding. But, in practice, these two terms are used interchangeably to describe the process of converting a video file from one format to another.
Why encode a video?
Video files are inherently large, so using a codec to compress the video ensures that the file will be much smaller. As codecs get better at compression, we are able to transmit higher quality video for the same amount of data. For that reason, there is a lot of research into new codecs.
There are other considerations to undertake when choosing how to encode your video. TheH264, while older and not the best compression, does support the highest browser support - making it a common encoding choice. Newer codecs like H265, VP9, and AVIF have better compression, but suffer slightly in the realm of browser support for playback.
When using a tool like FFMPEG, you can set the video quality. This determines how much compression there will be/how good the video will look. Higher compression leads to smaller files, but also higher loss. FFMPEG uses the Constant Rate Factor for encoding quality (values of 0 are lossless, 51 is high compression.) The default value for CRF is 23, and generally creates a video that offers a high compression/quality ratio:
ffmpeg -i input -c:v libx264 -crf 23 output.mp4
Encoding at api.video
Every video uploaded to api.video is encoded/transcoded into an H264 MP4 and a HLS video stream with up to 6 different sizes (240p, 360p, 480p, 720p, 1080p, 2160p). This ensures that video playback can occur on any device (the MP4), and along with our video player (or any other video player that supports HLS), your video can stream to the web quickly and efficiently.