How to convert HEVC (H.265) video to H.264

Convert HEVC (H.265) to H.264 by re-encoding the video stream. On Sume, an exact trim of a whole non-HDR clip returns an H.264 MP4.

5 min readSume
All posts

To convert HEVC to H.264, re-encode the video stream: decode the H.265 frames and compress them again with an H.264 encoder such as FFmpeg's libx264. Renaming the file doesn't change the codec, and neither does a stream copy into a new container, which moves the compressed packets as they are. With Sume, trim a whole non-HDR clip at the default exact precision: the result is a new MP4 with H.264 video and any kept audio as AAC.

The facts come from the Video trim and Video inspect docs, the Sume API reference, and FFmpeg's ffmpeg and codecs documentation, read on 2026-09-27. Anything described as current behavior is read from Sume's code.

How do I convert HEVC to H.264 with FFmpeg?

FFmpeg's documentation uses this command as its transcoding example: it decodes the video, encodes it again with libx264, and copies the audio as it is. Point -i at your HEVC file and name the output:

  • FFmpeg's docs name feeding a stream to something that cannot decode the original codec as a typical reason to transcode.
  • The same docs say encoding in most cases degrades quality, so convert once, from the original file, not from an earlier conversion.
  • A stream copy, like -c:a copy for the audio, might not work in some cases, the docs add, for example when the target container needs information the source lacks.
ffmpeg -i INPUT.mkv -map 0:v -map 0:a -c:v libx264 -c:a copy OUTPUT.mp4

How do I convert a Sume-hosted clip with the API?

Sume's media tools read only your workspace's media.sume.com files, such as an earlier Sume job's output; which URLs each endpoint accepts explains the rule. Run a free probe first, POST /v1/video-inspect with frames: false: video_codec names the codec, duration_seconds gives the length, and hdr flags PQ and HLG sources. Then trim from 0 to the full length:

  • precision defaults to exact, the frame-accurate re-encode. Don't send keyframe: it is a stream copy, so the video would stay HEVC.
  • An end past the source clamps to it and warns trim_clamped_to_source, but a range longer than 900 seconds is refused with video_trim_range_empty.
  • The default mode is async: poll GET /v1/jobs/:id/status, then read GET /v1/jobs/:id/result, whose video_url is the new MP4. The source is untouched.
curl -X POST https://api.sume.com/v1/video-trim \
  -H "Authorization: Bearer $SUME_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: hevc-to-h264-001" \
  -d '{
    "video_url": "https://media.sume.com/artifacts/artf_demo/clip-hevc.mp4",
    "start": 0,
    "end": 64.2
  }'

What settings does the converted file use?

You can't choose the codec or its quality: trim refuses codec, crf, and other ffmpeg fields with ffmpeg_fields_rejected. Today the trim compiler sets these:

From Video trim, Sume's trim compiler as it runs today, and the FFmpeg codecs documentation, read 2026-09-27.
SettingAn exact trim today
Video codecH.264 through libx264, which FFmpeg's docs describe as an H.264/MPEG-4 AVC encoder wrapper
Rate controlCRF 18, libx264's constant quality mode, with the veryfast preset
Pixel formatyuv420p
KeyframesAbout one second apart, when the source's frame rate is known
AudioAAC at 192 kbps, when the audio is kept
ContainerMP4 with +faststart
Size and frame rateThe source's, unless you set output: 256 to 2160 pixels per edge, and 24, 25, 30, or 60 fps

Can Sume convert HDR HEVC to H.264?

Not with trim or filter. The probe's hdr is true for PQ and HLG transfers. In current code, an exact trim refuses those sources with hdr_source_unsupported and points to keyframe precision or an SDR source, while a keyframe trim copies the stream, so the video stays HEVC. Video filter refuses HDR sources too.

A Timeline render doesn't refuse HDR sources in current code, but Sume doesn't document how it handles their color, so don't count on a correct conversion from one.

What are the limits?

  • Trim reads sources up to 1,800 seconds and writes at most 900 seconds per job, so a clip longer than 900 seconds takes two trims, and one longer than 1,800 seconds can't be trimmed. Joining them with a Timeline render encodes them a second time, with libx264 at CRF 20 in current code.
  • An exact trim always writes H.264 in an MP4; there is no field to pick another codec.
  • Trim is billed per job, plus a 5.5% agent fee by default; the docs say to confirm the rate in GET /v1/catalog. The probe is unbilled. Sume API output formats lists what every other endpoint returns.

Sources

Related posts

More in Media tools

All Media tools posts

Written by Sume