Skip to content

Evaluating a Codec Migration

Broadcasters that move channels from MPEG-2 to H.264 (AVC) or HEVC want to know which bitrate the new codec needs to reach at least the quality of the current MPEG-2 encode. This page shows how to answer this question with the toolkit.

The challenge

The values of the different codecs cannot be compared directly:

  • QP values use different scales. MPEG-2 reports the quantizer scale (1 to 112), H.264 and HEVC a QP from 0 to 51. A QP of 30 means something different in each codec.
  • P.1204.3 does not cover MPEG-2 yet, as of October 2026.

The common scale is therefore a full-reference metric (VMAF) against the same reference, together with the no-reference pixel metrics, which work the same way for every codec.

Preparing the inputs

You need:

  • a reference: the best available version of the content, ideally the contribution feed or a mezzanine file, for example in FFV1 or ProRes
  • the current MPEG-2 encode of the same content
  • one or more H.264 or HEVC encodes at different bitrates

Check the inputs with probe first. Pay attention to interlacing: broadcast MPEG-2 is often interlaced (for example 1080i25), while the new encodes may be progressive.

Running the comparison

Compare all encodes against the reference in one run, with the pixel metrics enabled:

surfmeter-media compare --pixels -o results/migration \
  reference.mkv \
  current/mpeg2_15000k.ts \
  candidates/h264_8000k.ts candidates/h264_6000k.ts \
  candidates/hevc_5000k.ts candidates/hevc_3500k.ts

The toolkit deinterlaces interlaced inputs with FFmpeg's bwdif filter before computing the metrics, so interlaced and progressive encodes can be compared. The filter used is stored in the alignment record of each encode (deinterlace).

If the encodes come from recordings of live channels, they will not start at the same picture as the reference. Add --align auto (see Aligning Inputs).

Interpreting the results

The result table gives the VMAF statistics of each encode. Find the lowest bitrate of each new codec whose VMAF mean and 5th percentile are at least those of the MPEG-2 encode. The 5th percentile matters here: an encode with the same mean but a lower 5th percentile has more visible drops in difficult scenes.

For a more detailed view, export the summaries to CSV:

surfmeter-media compare --pixels --format ndjson,json,csv -o results/migration \
  reference.mkv current/mpeg2_15000k.ts candidates/*.ts

summary.csv then has one row per input, metric and frame type, which you can open in a spreadsheet to compare VMAF, PSNR, SSIM, blockiness, blurriness and the bitstream statistics side by side.

The no-reference pixel metrics add information that VMAF does not show on its own:

  • blockiness typically increases first when the bitrate of MPEG-2 is too low
  • blurriness often increases when H.264 or HEVC encoders smooth fine detail at low bitrates
  • freezing and jerkiness show frame drops or repeated frames, for example from frame rate conversion

In the terminal view (--tui), the tracks of all encodes are drawn on top of each other, so you can see in which scenes the codecs differ.

Checking the existing MPEG-2 channels without a reference

If you do not have a reference, for example when you assess the channels that are currently on air, analyze still gives you the bitstream statistics and pixel metrics of the MPEG-2 encodes:

surfmeter-media analyze --layers bitstream,pixels -o results/mpeg2-channels recordings/*.ts

The QP statistics per frame type (I, P and B frames) show how close each channel is to the limit of its bitrate. A high 95th percentile of qp_avg for I frames means that the encoder often runs out of bits at scene changes. Use these values to choose the most demanding channels as test content for the migration.