Skip to content

fix(encode): tag HEVC as hvc1 so AVFoundation players open the file - #460

Merged
LeadcodeDev merged 1 commit into
mainfrom
fix/h265-hvc1-tag
Sep 30, 2026
Merged

LeadcodeDev merged 1 commit into
mainfrom
fix/h265-hvc1-tag

Conversation

@LeadcodeDev

Copy link
Copy Markdown
Owner

--codec h265 wrote an mp4 that QuickTime, Safari and avconvert refuse. ffmpeg's mp4/mov muxer writes HEVC under the hev1 sample entry unless told otherwise, and Apple's stack reads only hvc1. The issue measured it: a -c copy remux that changes the tag and nothing else makes the identical bitstream play.

ffmpeg_args now derives the tag from the codec and the output extension, so it lands on the libx265 branch and the hardware one alike — hevc_videotoolbox, hevc_nvenc, hevc_qsv, hevc_amf all go through the same muxer with the same gap. mkv has no sample entry table, so it gets nothing, and no other codec is touched: prores_ks sets its own tag, and avc1 was never refused.

rustmotion concat turned out to need no change. -c copy carries the tag across, checked on two --frames segments rendered from this branch and joined: hvc1, hvc1, hvc1.

Verification — three args-level tests (both codec spellings, both branches, .mp4/.mov/uppercase/the .partial. path the encoder actually passes; absent for mkv and for every other codec), plus one that renders an HEVC mp4 and reads codec_tag_string back with ffprobe, skipping itself where ffmpeg, ffprobe or libx265 is missing. The args test was red before the fix and the two negative ones green, which is what keeps the fix from over-reaching. cargo fmt --all --check, cargo clippy --workspace --all-targets --features rustmotion/studio -- -D warnings, cargo test --workspace --features rustmotion/studio: 0 failed.

Closes #457

`--codec h265` produced an mp4 that QuickTime, Safari and avconvert
refuse. The bitstream was never the problem: ffmpeg's mp4/mov muxer
writes HEVC under the `hev1` sample entry unless told otherwise, and
Apple's stack reads only `hvc1`. A `-c copy` remux that changes nothing
but the tag is enough to make the same file play, which is what the
issue measured.

The tag now comes from the codec and the output extension, so both the
libx265 branch and the hardware one get it, and mkv — which has no such
sample entry — gets nothing. `rustmotion concat` needed no change:
`-c copy` carries the tag across, verified on two rendered segments.

Closes #457
@LeadcodeDev LeadcodeDev self-assigned this Sep 30, 2026
@LeadcodeDev
LeadcodeDev merged commit 77e1e30 into main Sep 30, 2026
4 checks passed
@LeadcodeDev
LeadcodeDev deleted the fix/h265-hvc1-tag branch September 30, 2026 16:09
@LeadcodeDev LeadcodeDev mentioned this pull request Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

H.265 output is tagged hev1, which QuickTime and Safari refuse: -tag:v hvc1 is never passed to ffmpeg

1 participant