brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ffmpeg -tag:v hvc1 makes an H.265 MP4 play on Apple devices

Ffmpeg
~/tips/tip-ffmpeg-hvc1-tag

ffmpeg -i input.mkv -c:v libx265 -crf 26 -tag:v hvc1 -c:a aac output.mp4

Sets the codec tag Apple players expect, so an HEVC file plays in QuickTime and Safari.

H.265 files are small, but an MP4 made with libx265 often refuses to play in QuickTime, Safari or on an iPhone, while VLC plays it fine. The reason is a four-letter tag.

ffmpeg -i input.mkv -c:v libx265 -crf 26 -tag:v hvc1 -c:a aac output.mp4

HEVC in MP4 can be tagged in two ways: hev1 or hvc1. ffmpeg uses hev1 by default, and Apple’s players only accept hvc1. -tag:v hvc1 sets the other one. ffprobe shows the tag in codec_tag_string, which is how you can check yours.

If you already have an HEVC file that won’t play on a Mac, you don’t need to encode again. A copy with the tag changed is enough:

ffmpeg -i old.mp4 -c copy -tag:v hvc1 fixed.mp4

I’d keep in mind that the tag only solves the label. Very old Apple devices can’t decode HEVC at all, and 10-bit HEVC is a problem for some older hardware too. If a file needs to play everywhere, H.264 is still the safe choice, at the cost of a bigger file.

Further reading: ffmpeg documentation, FFmpeg wiki: H.265 encoding guide

More Ffmpeg tips ffmpeg -stream_loop 2 -i in.mp4 -c copy out.mp4 ffmpeg -i in.mp4 \ ffmpeg -i video.mp4 -i video.en.srt -map 0 -map 1 -c copy -c:s mov_text -metadata:s:s:0 language=eng video-subs.mp4 ffmpeg -i film.mkv -map 0:v -map 0:a:0 -c:v copy -c:a aac -b:a 192k -ac 2 film-stereo.mkv ffmpeg -i talk.mp4 -vn -c:a copy talk.m4a All Ffmpeg tips (38) All topics

Link