Back

Blog details

What Is Video Encoding? Codecs, Containers and Bitrate

AIOZ Network
8 min readNovember 05, 2026
aioz-streamguide
AIOZ Stream knowledge hub cover: What Is Video Encoding? Codecs, Containers and Bitrate

Video encoding is the process of compressing raw video with a codec so it is small enough to store and stream, then packaging the result in a container that a player can open. Every encode comes down to three choices: codec, container and bitrate.

The numbers show why. One second of uncompressed 1080p video at 30 frames per second, with 8-bit 4:2:0 color, is about 93 MB, or roughly 746 Mbit/s. AIOZ Stream caps a 1080p rendition at 6 Mbit/s, so the encoder must discard more than 99% of those bits while you still see a sharp picture. This page maps that whole area of our hub and points you to the deep post for each stage.

TL;DR:

  • Video encoding compresses raw frames with a codec (H.264, H.265, VP9, AV1) into a much smaller bitstream that the viewer's device decodes.
  • A container (MP4, MPEG-TS, fMP4) holds the encoded streams plus timing data; changing it is fast, while changing the codec means a new encode.
  • Bitrate sets how many bits each second of video gets, and rate control (CBR, VBR, CRF) decides how the encoder spends them.
  • AIOZ Stream encodes H.264 video up to 4K, H.265 up to 8K and AAC audio, set per rendition in a qualities array.

What is video encoding?

Video encoding is lossy compression of video to a published standard, the codec (short for coder-decoder), so that any compliant decoder can rebuild the picture. Cloudflare gives two reasons it's needed: raw video is far too large to send online, and it must arrive in a format any phone or laptop can read.

Encoding starts from raw or lightly compressed footage in a camera, an editor or a live encoder such as OBS. Transcoding decodes encoded video and encodes it again, usually at several sizes, as our guide to H.264, H.265 and VP9 transcoding shows. It's most of what a platform does after you upload.

Labelled diagram of the video encoding pipeline: raw 1080p frames at about 746 Mbit/s go through an encoder (codec), become a compressed bitstream, are wrapped by a muxer in a container, then split into HLS or DASH segments with a manifest that the player decodes
From raw frames to a playable stream. Transcoding repeats the encode step, while transmuxing repeats only the container step.

How does video encoding work?

Codecs from H.264 to AV1 share one four-stage recipe, and each stage maps to settings you can change.

  • Prediction. Most frames look almost like the one before, so the encoder stores a block as "that block from the previous frame, moved a few pixels" plus the difference. In Cloudflare's example, a blue sky behind a speaker barely changes, so it isn't resent every frame.
  • Transform. The leftover differences are converted into frequency coefficients, which separates flat areas from fine detail.
  • Quantization. The coefficients are rounded, and coarser rounding means a smaller file with more visible loss. This is the lossy stage, and it's the one your bitrate setting controls.
  • Entropy coding. The remaining numbers are packed losslessly, with short bit patterns for the most common values.

Prediction creates three frame types: an I-frame (keyframe) is coded on its own, a P-frame predicts from earlier frames and a B-frame predicts from frames on both sides. A group of pictures, or GOP, runs from one keyframe to the next. The keyframe interval matters to you because HLS and DASH segments normally start on a keyframe, and a player joins or switches quality at those points. That's why AIOZ Stream's OBS guide asks for a 1-second keyframe interval, as our OBS encoder settings guide explains.

Codecs: which compression standard to pick

A codec decides how efficient the compression is and which devices can play the result, and these five come up in most streaming decisions you'll make:

CodecStandardizedRoyalty-freeWhat to know
H.264 / AVCITU-T, 2003NoPlays on almost every device; the safe default
H.265 / HEVCITU-T, 2013NoDesigned to need about half the bitrate of H.264, per ITU
VP9GoogleYesRoyalty-free alternative used widely on the web
AV1AOMedia, 2018YesBetter compression, but slower to encode
H.266 / VVCITU-T, 2020NoTargets 50% less bitrate than HEVC; limited playback support so far

Our codec basics guide covers licensing and device support for the three older codecs, and What Is AV1 covers the newer royalty-free option with the numbers Netflix has published. If you want 8K, the choice is made for you: the 4K and 8K encoding walkthrough shows why 4320p output on AIOZ Stream has to use H.265.

Audio has codecs too: AAC is the usual choice for HLS and MP4, Opus is common in WebM and WebRTC, and our podcast hosting guide applies AAC to audio-only files.

What is the difference between a codec and a container?

A codec compresses the pictures and sound, while a container stores those compressed streams in one file along with timestamps, track information and metadata. One MP4 file can hold H.264, H.265 or AV1 video, and the same H.264 stream can sit inside MP4, MKV or MPEG-TS. Our container formats guide traces how MP4, MOV, WebM and MKV are related.

Streaming then cuts the encoded video into short segments listed in a manifest. HLS segments use MPEG-TS, which carries everything in fixed 188-byte packets, or fragmented MP4 (fMP4), and DASH uses fMP4. Our M3U8 and segmentation guide shows how segments and playlists fit together, and the video streaming protocols overview compares the protocols that carry them.

Swapping the container without touching the codec is called transmuxing, or remuxing, and it's fast and lossless because no frame is encoded again. Importing an existing HLS video goes one step further, since AIOZ Stream copies every rendition and segment byte for byte.

Bitrate, resolution and rate control

Bitrate is the number of bits per second the encoded stream uses. More bits mean less visible loss until viewers stop seeing a difference, and past that point you pay for bandwidth nobody notices. Find that point with a perceptual score like VMAF.

Rate control decides how the encoder spends that budget over time:

  • CBR (constant bitrate) holds the rate steady, which keeps a fixed uplink predictable, so live ingest uses it.
  • VBR (variable bitrate) spends more bits on complex scenes and fewer on static ones, around an average target.
  • CRF (constant rate factor) in x264 and x265 targets a constant quality level and lets file size vary; adding a maximum rate gives capped CRF, a common VOD setting.

Streaming services encode a ladder of renditions, each pairing a resolution with a bitrate, and the player moves between them as your connection changes. Our bitrate ladder guide shows how to choose the rungs, and the adaptive bitrate streaming explainer covers how the player decides when to switch.

Encoding a file with FFmpeg: a worked example

We ran this on October 28, 2026 with FFmpeg 7.1, encoding a 720p rendition from a 30-second 1080p clip of our own:

ffmpeg -hide_banner -loglevel error -i source.mp4 -vf scale=-2:720 \
  -c:v libx264 -b:v 1500k -maxrate 1500k -bufsize 3000k -g 60 \
  -c:a aac -b:a 128k -ar 48000 out-720p.mp4

ffprobe -v error -show_entries stream=codec_name,width,height,r_frame_rate,bit_rate \
  -of compact out-720p.mp4
stream|codec_name=h264|width=1280|height=720|r_frame_rate=30/1|bit_rate=962661|
stream|codec_name=aac|r_frame_rate=0/0|bit_rate=2277

Here -c:v libx264 picks the codec, -b:v sets the target bitrate, and -maxrate with -bufsize caps it. The -g 60 flag places a keyframe every 60 frames (2 seconds at 30 fps), and ffprobe counted 15 keyframes in the 30-second output. On this simple motion-graphics clip, the video averaged about 963 kbit/s against a 1,500 kbit/s target, and the clip's silent soundtrack explains the tiny audio figure. Check the output with ffprobe before you trust a target.

Next, the same streams moved into an MPEG-TS container without re-encoding:

ffmpeg -hide_banner -loglevel error -i out-720p.mp4 -c copy out-720p.ts

stat -c "%s %n" out-720p.mp4 out-720p.ts
3653328 out-720p.mp4
3949880 out-720p.ts

The copy took 0.01 seconds and ffprobe still reports h264 and aac, yet the TS file is about 8% larger. Since the streams inside are identical, those extra 296,552 bytes are MPEG-TS container overhead.

How AIOZ Stream handles it

When you upload a video to AIOZ Stream, we run the transcoding, and you choose the outputs in the qualities array of the create-video request. Each entry sets a resolution, a streaming type (hls or dash), a container_type and the video and audio codec settings. This entry is quoted from the Video API docs (not run here):

{
  "resolution": "1080p",
  "type": "hls",
  "container_type": "mpegts",
  "video_config": { "codec": "h264", "bitrate": 5000000, "index": 0 },
  "audio_config": { "codec": "aac", "bitrate": 192000, "channels": "2",
                    "sample_rate": 48000, "language": "en", "index": 0 }
}

What the docs commit to:

  • Codecs: video is h264 or h265, with H.264 capped at 4K and H.265 at 8K, and audio is AAC only.
  • Containers: HLS takes mpegts or mp4 and DASH takes fmp4. On Safari, iOS and tvOS, HEVC in HLS plays only from fMP4/CMAF segments, not MPEG-TS.
  • Bitrate caps: from 700,000 bps at 240p through 6 Mbit/s at 1080p, 30 Mbit/s at 2160p and 60 Mbit/s at 4320p.
  • Source limits: a rendition above the source resolution is ignored.
  • Cost: GET /api/media/cost estimates the transcoding price for a duration and a set of qualities before you commit.

The docs don't say which rate-control mode or keyframe interval the VOD transcoder uses, and they list no VP9 or AV1 output. Next step: read the AIOZ Stream Video API reference and build your first qualities array.

In this pillar: codecs, containers and encoding

Frequently Asked Questions

What is the difference between encoding and transcoding?
Encoding compresses raw or lightly compressed footage, while transcoding decodes video that is already encoded and encodes it again, usually into several resolutions and bitrates for streaming.

Does re-encoding a video lower its quality?
Yes, because each lossy encode discards more detail, whereas transmuxing to a new container copies the compressed frames unchanged.

Is MP4 a codec?
No, MP4 is a container, and the video inside an MP4 file is usually H.264, H.265 or AV1 with AAC audio.

Which codec should you use for streaming?
Start with H.264 for the widest playback, then add H.265 or AV1 renditions when your audience's devices can decode them.

What does AIOZ Stream encode video to?
AIOZ Stream encodes H.264 up to 4K or H.265 up to 8K with AAC audio, packaged as HLS (MPEG-TS or MP4 segments) or DASH (fMP4).

References

We only send updates when meaningful changes ship, and you can unsubscribe anytime

Related Content

blog thumbnail

What Is Video Encoding? Codecs, Containers and Bitrate

Video encoding compresses raw video with a codec, then a container packages it for playback. See how codecs, containers, bitrate and rate control fit together.

aioz-streamguide
8 min readNovember 05, 2026
blog thumbnail

Video Streaming Protocols: HLS, DASH, WebRTC, RTMP and SRT

Video streaming protocols move video from encoder to viewer. See how RTMP, SRT, HLS, DASH and WebRTC differ in latency, transport and where each one fits.

aioz-streamguide
7 min readNovember 04, 2026
blog thumbnail

What Is Decentralized Live Streaming and How Does It Work?

Decentralized live streaming sends a real-time broadcast through independently run nodes instead of one company's servers. Here's how each stage of it works.

aioz-streamguide
6 min readNovember 03, 2026
blog thumbnail

Video Streaming Glossary: Codecs, Protocols and Delivery A-Z

A video streaming glossary of 114 terms, from AAC and ABR to WebRTC and Widevine, each defined in plain English with sources and links to the deep posts.

aioz-stream
23 min readOctober 31, 2026
blog thumbnail

Monitor Livestream Health With Bitrate, FPS and Viewer Count

Read the AIOZ Stream Statistics panel: bitrate in and out, FPS in and out and current viewers, plus the documented rules for each and what the docs leave out.

aioz-streamguide
6 min readOctober 30, 2026
blog thumbnail

How to Embed a Livestream on Your Website (Link or iFrame)

Embed an AIOZ Stream livestream with the Share button's iframe or send the Public Playback URL as a link. Covers API fields, public access limits and doc gaps.

aioz-streamguide
6 min readOctober 27, 2026