Tool

Re-encoding a Video Folder: Which Files First?

When your external drive is full, re-encoding every video would take far too long. Paste a list from an ffprobe scan of the folder (codec, resolution, fps, bitrate, duration) and this tool calculates, for each file, how many GB you would save by re-encoding it, using the x264 and x265 curves we measured ourselves, then ranks the files largest first. Files whose bitrate is already low, so there is nothing to gain, are flagged. All processing happens inside this browser.

1. Build the file list (Windows PowerShell)

Open PowerShell in the folder and run the script below. It walks all subfolders and writes list.csv. ffprobe must be on your PATH. File names and paths are not sent anywhere; whatever you paste is processed only inside your browser.

Get-ChildItem -Path . -Recurse -File -Include *.mp4,*.mkv,*.mov,*.avi,*.m4v,*.ts,*.wmv | ForEach-Object {
  $j = ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,width,height,avg_frame_rate,bit_rate:format=duration,size,bit_rate -of json $_.FullName | ConvertFrom-Json
  $s = $j.streams[0]; $f = $j.format
  if ($s) { '"{0}",{1},{2},{3},{4},{5},{6},{7},{8}' -f $_.FullName.Replace('"','""'), $s.codec_name, $s.width, $s.height, $s.avg_frame_rate, $s.bit_rate, $f.duration, $f.size, $f.bit_rate }
} | Set-Content -Encoding UTF8 list.csv

Column order: path, codec, width, height, fps, video bitrate (bps), duration (s), file size (bytes), overall bitrate (bps). The header line is optional. The example is made-up values to show the format, not real files.

3. Target quality for re-encoding

The higher the target, the less you save. See the notes below and the VMAF score interpreter for what each score looks like.

Codec to re-encode with

For HEVC files both choices are the same. Conversion to AV1 or VP9 is not included in this tool.

Resolution and fps scaling

We only measured 1080p25 clips, so 4K, 30 fps and 60 fps files are scaled by this ratio as an assumption. 0.75 is an option for the case where 4K needs less; it is not a measured value.

Used for files such as MKV where the video stream bitrate is empty. 128 is an arbitrary starting value, so change it to match your actual audio.

Loading measurement data…

Where do the numbers come from?

The tool reads the raw data from the CRF sweep measurement as is (four 10-second 1080p25 clips, x264 and x265 at medium, six CRF steps, one PC). Every measurement point has a bitrate (kbps) and a mean VMAF.

  1. It reads each file's video bitrate. If the list has none, it takes (file size × 8 ÷ duration) and subtracts the audio value you entered; if there is no size either, it subtracts from the overall bitrate.
  2. It converts resolution and fps to 1080p25: bitrate ÷ ((pixel count ÷ 1080p pixel count)exponent × fps ÷ 25). This conversion is an assumption, not a measurement.
  3. For each of the four clips it reads the "bitrate that reaches the target VMAF" off the curve (a straight line on log bitrate between measurement points, no extrapolation outside the measured range), then converts that back to your resolution and fps.
  4. (Current video bitrate − required bitrate) × duration is the saving on the video stream. The clip that needs the most bitrate gives the smaller value (conservative); the clip that needs the least gives the larger value (optimistic). The ranking uses the smaller value.
  5. If even the smaller value is above 0, the status is "Can shrink". If only the larger value is above 0, it is "Depends on the clip". If the larger value is 0 or less too, it is "No gain".
  6. The total adds up only the files with a gain. With many files, individual errors may cancel out or may all lean the same way; we did not measure which.

"bpp" (bits per pixel) is the bitrate divided by frame size and fps, shown so you can compare files of different resolutions. To see how much is too much, with the measured curve alongside, use the bits-per-pixel bitrate judge. What a VMAF score means is covered in the VMAF score interpreter, and the bad moments an average score hides are in Is an average VMAF of 95 safe?.

How to use it

  1. Open PowerShell in the folder you want to sort out and run the script above to create list.csv. With a very large number of files it can take a few minutes. On a Mac or Linux, build a CSV with the same column order yourself and paste it in.
  2. Set the target to around VMAF 93 and look at the ranking. The files at the top give the most savings for the effort. Camera originals with a high bitrate, screen recordings and long meeting recordings usually rise to the top.
  3. Pick one or two of the top files, encode them yourself and check them by eye. The CRF range in the table is a starting point. The FFmpeg command builder makes the command, and the batch folder encode script builder makes a script that runs many files at once.
  4. Leave files marked "No gain" alone. Re-encoding a file whose bitrate is already low may barely shrink it and only cost quality.
  5. Turn on the HEVC option to see how the bitrate needed for the same VMAF changes for H.264 files. For the codec difference itself, see the clip-by-clip results in the HEVC 50% savings measurement.
  6. If you would rather start from a target size and decide how much quality to keep for archiving, the video quality per GB planner for archives fits better. This tool is for deciding the order in which to tackle files you already have.

Limits worth knowing

  • Our curves come from a first encode of an original source. We did not measure the quality when an already compressed file is encoded again (re-compressing costs another round of quality). Reaching the same target VMAF from an already compressed file may need more bitrate, so the larger value can be optimistic.
  • It assumes your files are as efficient as our x264 and x265 medium curves. Files made by cameras, hardware encoders or other presets can look different at the same bitrate, so the "Est. VMAF" in the table is for reference only.
  • Only H.264 and HEVC are calculated. AV1, VP9, MPEG-4, ProRes and the like are marked "Codec not measured", and the tool cannot say whether shrinking a file that is already AV1 would gain anything.
  • Resolutions and frame rates other than 1080p25 are converted by assumption. If many 4K files land near the top of the ranking, look at both results, exponent 1 and 0.75.
  • The clips are four 10-second clips at 8-bit. 10-bit, log and HDR footage, and screen recordings, subtitles or graphics-heavy video may differ from the curves. The fps of a variable frame rate file is an average and may be inaccurate.
  • Encoding time is not calculated. To weigh the savings against the time, also look at the encode time estimator.
  • If the values in the list are wrong, the results are wrong. For files where the video bitrate was derived by subtraction, the error is large when there is audio, subtitles or multiple tracks. The tool never opens your files; it only reads the text you paste.
  • Re-encoding cannot be undone. Play back the result before deleting the original, and back up anything important first.