Video transcoding, explained
Transcoding turns one source file into a set of aligned versions ready for adaptive streaming. Here is what happens at each stage, and which settings decide the result.
Transcoding decodes a video to raw frames and encodes them again with new settings. In between it can filter the frames, for example to scale them or fix the frame rate. For streaming it usually makes several renditions at once. Every rendition must share keyframe positions, so a player can switch between them.
Upload a single 4 GB file and wait a few minutes. A viewer on a phone is now watching a 360p rendition of it. A viewer on a television is watching 1080p. Both can switch to anything in between at a segment boundary. The work done in those minutes is transcoding. It is the most computing-heavy thing a video platform does.
This deep dive follows the pipeline from source to ladder. It covers probing, decoding, filtering, encoding with rate control, keyframe alignment and packaging. It also covers the checks that catch a bad output before a viewer does. It ends with a real ffmpeg command that makes a two-rendition HLS ladder. The container vs codec explainer gives the words this guide relies on. The video streaming hub shows what happens to the ladder after transcoding.
Transcoding, transmuxing, transrating
Three similar words describe three different amounts of work. Transmuxing (remuxing) changes only the container: an H.264 stream is copied from MKV into MP4 or cut into HLS segments without being decoded. Transrating re-encodes at a different bitrate but the same resolution and codec. Transcoding in the full sense decodes to raw frames and re-encodes, possibly with a different codec, resolution, frame rate or colour format. A streaming ladder needs the full version, because it produces multiple resolutions from one source. The free video converter is a small everyday example. It decodes your file and encodes it again, for instance to H.264 and AAC in an MP4.
The cost follows the same order. Transmuxing is limited by disk speed. Transrating and transcoding are limited by the encoder. As a rule of thumb, encoding H.264 at 1080p with a careful software preset runs at about real time on a modern processor. AV1 is slower still, as the codec comparison discusses.
The pipeline, stage by stage
Probe
Read the container and stream metadata: codecs, resolution, frame rate, whether the frame rate is constant, interlacing, colour primaries and transfer characteristics, audio channels, duration. Everything downstream is configured from this. A corrupt index or a missing duration is caught here.
Demux and decode
Split the container into elementary streams and decode the video to raw frames, typically 8-bit or 10-bit YUV in 4:2:0 chroma. Hardware decoders speed this up considerably; software decoders handle the exotic cases.
Filter
Scale each rendition with a good resampling filter. Deinterlace if the probe found interlaced fields. Convert the frame rate, or force a constant one for variable sources. Tone map if HDR must also be delivered as SDR.
Encode
Compress each rendition with a codec and rate-control settings chosen for streaming. Constrained bitrates keep the BANDWIDTH a playlist advertises honest. A fixed keyframe interval makes every rendition segment at the same instants.
Encode audio
Decode and re-encode the audio to AAC, normally at 128 to 192 kbps stereo, shared across all video renditions. Multiple language tracks become alternate renditions.
Package
Segment each rendition, write the media playlists and the multivariant playlist, generate thumbnails and scrub previews, and upload everything to storage from which it is delivered.
Verify
Probe every output: duration matches the source, segment counts match across renditions, keyframes sit at segment starts, audio and video stay in sync. Then mark the video ready.
Rate control: CRF versus constrained bitrate
A one-off encode for archiving uses constant quality (CRF in x264 and x265). It spends bits wherever the picture needs them and lets file size fall where it may. Streaming cannot use pure CRF, because the playlist must advertise a peak bitrate that the player can rely on. The usual compromise is capped CRF or constrained VBR. That is a quality target plus -maxrate and -bufsize limits, which bound how far the bitrate can spike over any short window. The buffer size models the decoder's buffer. A rule of thumb is one to two times the target bitrate.
Two-pass encoding analyses the whole file before encoding it. It gives a more even result at a chosen average bitrate, but it doubles the time. Some platforms go further with per-title or content-aware encoding. They analyse each source and choose bitrates for its own ladder, instead of one ladder for everything. A static talking head and a sports match do not need the same bits at 720p. The bitrate guide gives working ranges.
Keyframe alignment: the rule that makes switching work
Every segment must begin with a keyframe, called an IDR frame in H.264 terms. Every rendition must also place its keyframes at the same timestamps. If not, a player switching renditions at a segment boundary would land in the middle of a group of pictures. It would have nothing to decode from. In ffmpeg with x264, you fix the GOP length with -g and -keyint_min. You also turn off scene-cut detection with -sc_threshold 0. Then the encoder cannot add an extra keyframe at a scene change in one rendition but not in another. -force_key_frames with an expression is the alternative when the interval must be in seconds rather than frames.
The keyframe interval also sets the minimum segment length. Apple recommends keyframes at least every two seconds with six-second segments, so each segment holds three groups of pictures. Longer intervals compress slightly better. Shorter intervals make seeking and switching snappier. Two seconds is the widely used compromise, and the adaptive bitrate guide explains what the player does with the result.
Settings that decide the output
| Setting | x264 option | Effect | Streaming guidance |
|---|---|---|---|
| Preset | -preset | Speed versus compression efficiency | medium or slow for on-demand; faster presets for live |
| Quality target | -crf | Perceptual quality level | 18-23 for the top rung, capped by maxrate |
| Peak bitrate | -maxrate | Upper bound over the VBV window | Set per rung; matches the advertised BANDWIDTH |
| VBV buffer | -bufsize | Window over which maxrate is enforced | 1-2× the target bitrate |
| GOP length | -g, -keyint_min | Frames between keyframes | Frame rate × 2 seconds, identical across rungs |
| Scene cut | -sc_threshold | Extra keyframes at scene changes | 0, to keep rungs aligned |
| Profile and level | -profile:v, -level | Decoder feature set | High profile, level 4.1 for 1080p30 |
| Pixel format | -pix_fmt | Chroma and bit depth | yuv420p for universal playback |
A two-rendition HLS ladder in one ffmpeg command
The command below makes 1080p and 720p renditions with aligned keyframes at 24 or 25 frames per second. For other frame rates, set -g to twice the frame rate. Each rendition gets its own AAC audio and six-second fMP4 segments, plus a multivariant playlist:
ffmpeg -i source.mp4 -filter_complex "[0:v]split=2[v1][v2];[v1]scale=-2:1080[v1o];[v2]scale=-2:720[v2o]" -map "[v1o]" -map 0:a -map "[v2o]" -map 0:a -c:v libx264 -preset medium -crf 21 -g 48 -keyint_min 48 -sc_threshold 0 -pix_fmt yuv420p -maxrate:v:0 5000k -bufsize:v:0 7500k -maxrate:v:1 2800k -bufsize:v:1 4200k -c:a aac -b:a 128k -f hls -hls_time 6 -hls_playlist_type vod -hls_segment_type fmp4 -hls_segment_filename "rung_%v_%03d.m4s" -master_pl_name master.m3u8 -var_stream_map "v:0,a:0 v:1,a:1" rung_%v.m3u8
The split filter decodes the source once and feeds both scalers, which is the single largest efficiency win in a multi-rendition encode. Adding rungs is a matter of extending the split, the maps and the var_stream_map.
Where pipelines go wrong
- Variable frame rate sources, common from phones and screen recorders, produce renditions whose segment boundaries drift apart unless the pipeline forces a constant frame rate first.
- Interlaced sources that are not deinterlaced show combing on every progressive display; the AVI conversion guide covers the filter.
- Scene-cut keyframes left enabled in one rung and not another break alignment silently; playback works until the first switch across the misaligned point.
- Upscaling a low-resolution source to fill a ladder adds bytes without detail. Renditions above the source resolution should be skipped, which is why a 720p upload does not gain a 1080p rung.
- Double compression. A source that was already heavily compressed gives the encoder artefacts to keep instead of detail. The blurry after upload guide shows the effect, and the preparation guide the remedy.
Frequently asked questions
How long does transcoding take after upload?
It depends on the source length, resolution and codec, and on how many renditions are produced. As a rule of thumb, software H.264 encoding of a 1080p source at a medium preset runs close to real time per rendition on a capable machine. Platforms spread the work across renditions and across chunks of the file. A short clip is usually ready in a minute or two. A long 4K source takes longer and produces more rungs. The help page on encoding times after upload explains what to expect on VideoBB.
Does transcoding reduce quality?
Every lossy encode discards some information, so yes in principle; the goal is to make the loss invisible at each rendition's intended viewing size. A high-quality source gives the encoder detail to keep, while a heavily compressed source forces it to spend bits preserving artefacts. The largest quality lever you control is therefore the upload itself, not the transcoder.
Why does my 720p upload not have a 1080p option?
Because a 1080p rendition upscaled from 720p would contain no more detail than the 720p rendition while using roughly twice the bandwidth. Transcoders build rungs at or below the source resolution. To offer 1080p, 1440p or 2160p, upload a source at that resolution; VideoBB produces 1440p and 2160p renditions when the source supports them, and Premium members can watch them.
Can I skip transcoding by uploading a ready-made HLS package?
Not on VideoBB; the platform accepts source files in the supported containers and builds the ladder itself, so that every rendition is aligned and packaged consistently. On a self-hosted setup you can package your own ladder with ffmpeg or a dedicated packager and serve it directly, which is exactly what the command in this guide produces.
Sources
- FFmpeg documentation: ffmpeg — Filter graphs, stream mapping and per-stream options
- FFmpeg formats documentation: hls muxer — var_stream_map and segment options
- FFmpeg H.264 encoding guide — CRF, presets and rate control for libx264
- Apple: HLS Authoring Specification for Apple Devices — Keyframe interval and segment duration guidance
- RFC 8216: HTTP Live Streaming — Segment and playlist requirements
Related guides

What is HLS streaming?
HTTP Live Streaming is a text playlist, a pile of short media files and a set of rules for a player. Here is how those pieces fit together and why it became the default way to deliver video.

Adaptive bitrate streaming, explained
A player that changes quality mid-stream is making a prediction every few seconds. How the rendition ladder is built, how the player chooses a rung, and what makes the choice hard.

H.264 vs H.265 vs AV1
One codec plays on everything, one halves the bitrate but carries licensing baggage, and one is royalty-free and gaining ground. How to choose between them for encoding, upload and delivery.

Prepare video for upload
The right export is smaller, uploads faster, is accepted without complaint and transcodes cleanly. It is not the highest possible quality and it is not the smallest file. Here is the middle.