Lorixen.
EN

Customer video uploads: transcoding for every phone and browser

Short answer: Videos customers upload, straight from phones, cameras or screen recorders, come in many codecs, sizes and orientations, and some won't play in every browser. Don't serve the original file. Transcode each upload in a background job into a widely supported format, typically H.264 video with AAC audio in an MP4 file with the metadata moved to the start, at one or a few sensible sizes, plus a poster image. Keep the original in storage, show "processing" until the job finishes, and set limits on size and length.

Why uploaded videos fail to play

Business apps increasingly accept video: product reviews, property walk-throughs, damage reports for insurance or repairs, training clips, testimonials, before-and-after footage. The trouble is that a video file that plays fine on the phone that recorded it may not play elsewhere:

  • Codec support differs. Newer phones often record in HEVC (H.265) to save space. Support for it varies between browsers and devices, so some viewers get a blank player.
  • Files are huge. A minute of high-resolution phone video can be hundreds of megabytes, which is slow to stream and expensive to store and serve.
  • Playback can't start until the end loads. If an MP4's index sits at the end of the file, some players must download the whole thing before playing.
  • Orientation and odd formats. Rotation metadata, variable frame rates and unusual containers from screen recorders and older cameras cause sideways or stuttering playback.

Serving originals directly pushes all of these problems onto your viewers.

Pick a safe target format

MDN's guide to web video codecs describes AVC, also called H.264, as a widely used codec supported in MP4 and other containers, and covers newer, more efficient options like VP9, HEVC and AV1, which compress better but have more variable support.

A practical default for a business app:

  • Video: H.264.
  • Audio: AAC.
  • Container: MP4.
  • Optional extra: a more efficient codec such as AV1 or VP9 as an additional rendition for browsers that support it, offered first in the <video> element's <source> list.

This gives near-universal playback, with an efficiency bonus where available.

Make MP4s start quickly

An MP4 contains an index, often called the moov atom, that players need before they can start. FFmpeg's formats documentation explains that by default this index is written at the end of the file, and that it can be moved to the start for better playback by adding +faststart to the -movflags option. Do this for every MP4 you serve progressively, so playback begins as soon as the first part downloads.

Choose sizes deliberately

Most uploaded video is far larger than viewers need. Decide on a small set of renditions:

  • A main version sized for how the video is shown in your app, such as a maximum of 1080 pixels on the long edge.
  • A smaller version for thumbnails, previews or slow connections.
  • A poster image taken from early in the video, used by the poster attribute of the <video> element.

For long videos or audiences on variable connections, consider adaptive streaming. Apple's HTTP Live Streaming documentation describes splitting video into short media segments listed in an index file, with multiple alternate streams at different bit rates and switching between them as network bandwidth changes. HLS and similar formats add complexity, so they're best reserved for longer content or when a video platform handles them for you.

Build the pipeline around a background job

Transcoding takes time and CPU, so never do it inside the upload request:

  1. Upload directly to object storage using a pre-signed URL, so large files don't pass through your web servers.
  2. Record the upload in your database with status "processing".
  3. Queue a transcoding job. Run it on a worker with tools like FFmpeg, or use a managed media-processing service from your cloud provider.
  4. Write outputs to storage under a predictable path, with the renditions and poster.
  5. Update the status to "ready", or "failed" with a reason.
  6. Notify the user if they're waiting, for example "Your video is ready".

Show a clear processing state in the interface. A blank player with no explanation looks broken.

Set limits and validate

Protect your workers and storage:

  • Limit file size and duration at upload, and tell users the limits up front.
  • Check the file is actually a video by inspecting it, not trusting the extension or browser-reported type.
  • Put a time limit on each transcoding job, and kill jobs that exceed it, so a malformed file can't tie up a worker forever.
  • Strip metadata you don't need, such as location, from the transcoded outputs.

Keep the original, serve the outputs

Store the original upload in a cheaper storage class if your provider has one, so you can re-transcode later if you change formats or sizes. Serve only the processed renditions to viewers, through a CDN where possible. Check current storage and data-transfer prices for your provider, since video is where those costs grow fastest.

Accessibility and usability

  • Offer captions for spoken content, using the <track> element with WebVTT files.
  • Don't autoplay with sound; if you autoplay previews, mute them and use playsinline so iPhones don't jump to fullscreen, as MDN's <video> reference describes.
  • Provide a transcript or summary for key videos, such as training content.

A worked example

Picture a hypothetical Sligo property-management company whose tenants uploaded videos of maintenance problems. Staff on some laptops saw black screens, and large uploads took ages to open. The developer switched uploads to direct-to-storage, added a background job that produced an H.264 MP4 with faststart, a smaller preview and a poster image, showed a "processing" badge until ready and capped uploads by length. Staff now open every video straight away, and the originals are kept in cheaper storage for re-processing.

FAQ

Can I avoid transcoding by using a video platform?

Yes. Video hosting services handle transcoding and streaming for you, at a cost. That's often sensible if video is central to your app.

How long does transcoding take?

It depends on the file, the target settings and the worker's power. Test with real uploads and size workers accordingly.

Should I transcode audio-only uploads too?

The same principles apply: convert to a widely supported format and keep the original.

If customers' uploaded videos won't play for your team or viewers, tell us how uploads work today.

Sources

WhatsAppBook a call