16.9 C
Canberra
Saturday, March 21, 2026

javascript – Shopper-side video crop + audio mux on iOS Safari with HEVC — any viable method?


I am constructing an internet app the place customers add a video, the app crops the primary 60 seconds client-side, extracts audio for server-side AI processing, then muxes the returned audio again into the cropped video. This should work on cell together with iOS.

The issue

iPhones report HEVC (H.265) by default. Each client-side method I’ve tried fails on iOS Safari for big HEVC recordsdata:

WebCodecs:

VideoDecoder.isConfigSupported({ codec: "hev1..." }) → false
ffmpeg.wasm:    fetchFile() copies complete file to JS heap → OOM (tab crash) 
captureStream:  video.captureStream() not supported on iOS Safari
canvas:         should decode HEVC frames → ~8MB × 5 body buffer → OOM

File.slice() works for byte-level cropping with no decode, however I nonetheless have to mux a brand new audio monitor in afterward — which brings the identical reminiscence constraints again.

What works

– iOS + H.264: WebCodecs pipeline works effective (decode → re-encode at 720p through VideoEncoder → mp4box.js mux)
– Android Chrome: WebCodecs or ffmpeg.wasm each work

What I’ve thought of

1. Extract audio-only through mp4box.js + AudioDecoder (AAC is all the time supported even on iOS HEVC) — solves the crop step, not the mux step
2. Server-side mux — works however provides latency and bandwidth
3. mp4box.js container-level audio monitor substitute — nonetheless requires loading moov + mdat into reminiscence

Query

Is there any iOS Safari 16.4+ net API that permits changing the audio monitor in an MP4/MOV container with out decoding video frames? Or any memory-safe method to mux new audio into a big HEVC file client-side?

Or is server-side mux the one sensible possibility right here?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles