VionetoVioneto
Back to the magazine

VIONETO MAGAZINE Playback & technology

Why a video URL returns HTML: check Content-Type

An address ending with .mp4 may return a login page or an error page. To verify the actual media response and separate it from the embedded player.

A dark blue video file with a turquoise overlay passes through a transparent channel into the appropriate slot of a browser frame.
The actual media response must correspond to the requested resource. The illustration is illustrative.Image: Vioneto · AI-generated illustration

When encountering a faulty video embedding, check what the actual media request actually delivers. The filename in the URL is not sufficient for this purpose. Behind a seemingly MP4 URL, there could be a login page, an error message, or video data with an incorrect content type. These scenarios require different corrections.

Separate player side from media response

An embedded player within an iframe is initially an HTML document. Its response must be text/html. The actual media assets are requested only within this HTML document. Therefore, do not accidentally examine only the response of the player page itself. With HLS, there is also a playlist and individual media segments; these are not single MP4 files and must not be universally labeled as video/mp4.

The HTTP header Content-Type describes the media type of the returned data. MDN explains the purpose of this header. For an MP4 file containing video, video/mp4 is registered with IANA. However, the header alone is not proof that the data contains an intact video or a codec supported by the target browser.

MDN: The purpose of the Content-Type header

IANA: registered media type video/mp4

Check the specific response in the network protocol

  • Open your browser's developer tools and go to the Network tab before reloading the page and starting the video.
  • Select the specific media requirement. Use the address and initiator to assign it; if the media filter yields no results, also check the other requests.
  • Check the status, possible redirects, and the response headers. Note the final URL and the Content-Type.
  • Check whether the response matches the expected medium. A readable HTML login or error message is not video content, even if the status code is 200.

A hypothetical example: /filme/erklaerung.mp4 redirects to /login. The final response is 200 with Content-Type set to text/html. This explains why the supposed video file does not play as a video. The task here is to correct the intended access and media path. Setting the login page's Content-Type header to video/mp4 would only mask the underlying issue.

Forward three findings accurately

  • HTML instead of video: provide the final address, redirect, and page type. Determine the appropriate audience or media access.
  • True MP4 bytes with incorrect type: verify the responsible delivery rule or object metadata for this specific resource.
  • mp4 video and real video data: separately analyze containers, embedded codecs, file integrity, and playback functionality.

A MIME type hint in the source element is no substitute for the correct server response. Similarly, you should not disable browser protection to work around a conflicting response type. The MDN explanation of nosniff details its specific blocking rules for scripts and stylesheets; it does not imply a general rule that nosniff blocks all problematic videos.

MDN: MIME type validation and the nosniff rules

After correction, reverify the same requirement.

Reload the affected page and verify the media response as well as the actual playback. If cached object metadata has been changed, also consider the relevant cache. Record a clean address, timestamp, status, and content type for handover; do not publish signed access parameters or session tokens. This ensures that observation leads to a specific action rather than the vague notification "The MP4 won't play."

MP4 containers and their embedded codecs vary

Further potential causes of videos that fail to start are identified.

Topics

Sources and further reading

  1. https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Type
  2. https://www.iana.org/assignments/media-types/video/mp4
  3. https://developer.mozilla.org/en-US/docs/Web/Security/Practical_implementation_guides/MIME_types