title: How to make an MP4 recorded video from an iOS app playable on Chrome?
body: <p>I have an iOS app in which users upload a selfie video on my server. Afterwards, a reviewer sees the video on a back-office website, and accept/reject it.</p>
  <p>The problem is that I upload MP4 video files from my iOS client app. When I load the file url in the <code>&lt;video&gt;</code> tag of my website, chrome doesn't load the video (no error is displayed in the console). In Safari, everything works fine.</p>
  <p>After some researches, I saw that <em>sometimes</em>, mp4 video can't be played by Chrome. Strangly, I tried to play some other mp4 video found on my laptop in chrome, and it worked. As if there were several &quot;kind&quot; of MP4 encoding and the one my client apps uses to encode is not supported by Chrome.</p>
  <p>I saw that Chrome could handle .webm format, but I takes a lot of time to my server (4 entiere minutes at 100% CPU...) to translate from a MP4 to a WEBM.</p>
  <p>My questions are :</p>
  <ul>
  <li><p>(1) Why some mp4 can be played by Chrome and other not ? How I can make Swift <code>AVFoundation</code> module encoding the recorded video in the &quot;right&quot; mp4 encoding ?</p>
  </li>
  <li><p>(2) If it's impossible, I'd like to encode the 2 files (webm and mp4) client-side, within the user devices (I really want to avoid handling these computations by my server as they look extremely long to perform). The problem is that Apple does not provide webm as a possible translatable format in the documentation : <a href="https://developer.apple.com/documentation/avfoundation/avfiletype" rel="nofollow noreferrer">https://developer.apple.com/documentation/avfoundation/avfiletype</a>. Is there any way to translate a mp4 into a webm in Swift ?</p>
  </li>
  <li><p>(3) If (2) is impossible, is translating a user video into different formats server-side something commonly done as a &quot;best practice&quot; to manage video files and make them available in all platforms ? I mean, am I just missing some client-side trick to make mp4 videos playable everywhere or is it normal when dealing with cross platform videos to budget a whole CPU machine from AWS or whatever to handle conversions server-side ?</p>
  </li>
  </ul>