Anamorphic MPEG-2 video is displayed with the wrong aspect ratio

:backhand_index_pointing_right: Bug Description

1. Summary

Anamorphic MPEG-2 video is displayed with the wrong aspect ratio.

The source is encoded at 704×480 with a 16:9 display aspect ratio (SAR 40:33). Vega plays it as though the pixels are square, resulting in pillarboxing and a vertically stretched image. For example, a circle in the source appears as a tall oval.

The same stream displays correctly in VLC and other TV players.

Bug Severity: Impacts operation of app

2. Steps to Reproduce

  1. Create an MPEG-2 HLS stream with:
    • Coded resolution: 704×480
    • Display aspect ratio: 16:9
    • Sample aspect ratio: 40:33
    • AAC audio
    • We can provide a Synthetic mpeg2 stream to our amazon contact.
  2. Play the stream using Shaka with the Vega headless VideoPlayer.
  3. Attach the player to a fullscreen KeplerVideoSurfaceView using setSurfaceHandle().
  4. Compare the result with VLC.

3. Observed Behavior

The video is centered but pillarboxed, and the image is vertically stretched. A circle appears as a tall oval.

The device correctly detects the sample aspect ratio:

width=704
height=480
pixel-aspect-ratio=40/33

However, the W3C media path reports only the coded size:

generateMediaTrackInfo width = 704
generateMediaTrackInfo height = 480

This suggests the sample aspect ratio is detected by the media pipeline but not applied when rendering the video.

4. Expected Behavior

The player should apply the source’s 40:33 sample aspect ratio.

A 704×480 frame with this sample aspect ratio should be displayed at approximately 854×480, producing a 16:9 image without pillarboxing. The test circle should remain round.

4.a Possible Root Cause & Temporary Workaround

The GStreamer pipeline appears to detect pixel-aspect-ratio=40/33, but that value does not appear to reach the final display path.

We tried the following:

  • All available KeplerVideoSurfaceView scaling modes
  • Applying a React Native horizontal transform
  • Setting VideoPlayer.width and VideoPlayer.height
  • Adding RESOLUTION=854x480 to the HLS master playlist

The playlist test was recognized by Shaka, which reported 854×480, but the rendered output remained unchanged.

React Native transforms only affected the hardware surface window, not the video pixels themselves.

We have not found a client-side workaround on Vega. A rendering fix or an API for setting the destination aspect ratio would be helpful.

5. Logs or Crash Report

This is not a crash.

We have a complete device log covering player initialization, manifest parsing, track detection, and playback. Relevant lines show that the media pipeline detects 704×480 with pixel-aspect-ratio=40/33, while the W3C display path continues to use 704×480.

The full logs and synthetic test stream can be provided directly to our Amazon contact.

6. Environment

SDK Version: 0.22.5600
React Native Version: RN 0.72
@amazon-devices/react-native-w3cmedia: 2.2.11
Player client/server: 2.2.11
App State: Foreground
Device: Fire TV Stick 4K Select (AFTCR001), ARM

OS Information:

NAME="OS"
OE_VERSION="4.0.0"
OS_VERSION="2.0"
BUILD_DESC="OS 2.0 (TV Ship/63)"
BUILD_FINGERPRINT="4.0.179177.0(5cf44be4fdaf0f84)/63N:user/release-keys"
VERSION_NUMBER="2502000006320"

7. Example Code

const player = new VideoPlayer();
await player.initialize();

<KeplerVideoSurfaceView
  style={{ width: 1920, height: 1080 }}
  onSurfaceViewCreated={handle => player.setSurfaceHandle(handle)}
/>

:backhand_index_pointing_right: Playback Details

The issue occurs with anamorphic NTSC MPEG-2 delivered through HLS. No authentication, geographic restriction, or special HTTP headers are required for the synthetic reproduction stream.

Player SDK: Shaka Player
Player SDK Version: 4.8.5
Audio Codec: AAC (mp4a.40.2)
Video Codec: MPEG-2 (mp2v)
Manifest Type: HLS (m3u8)
Device Architecture: ARM
Content URL: No public URL; a short synthetic HLS package can be provided
Special Headers: None

The synthetic video contains a circle specifically to make the incorrect aspect ratio easy to identify:

  • VLC: round circle, correct 16:9 presentation
  • Vega: tall oval, pillarboxed presentation

:backhand_index_pointing_right: Additional Context

Playback uses the recommended headless architecture with VideoPlayer, KeplerVideoSurfaceView, and setSurfaceHandle().

The key detail is that the platform logs already contain the correct 40:33 pixel aspect ratio. The problem appears to occur later, when the decoded frame is passed to the display surface.

We can provide the complete logs, screenshots, and synthetic HLS reproduction package to our Amazon contact.

Hi @Jon_Page,

Thank you for the detailed bug report on the anamorphic MPEG-2 aspect-ratio issue - the SAR 40:33 analysis, the generateMediaTrackInfo logs showing only the coded 704×480, the VLC comparison, and the list of workarounds you already ruled out make the problem very clear.

Our team is investigating this issue and will provide an update as soon as we have more information. To help us reproduce and move faster, could you share with your Amazon contact:

  • The synthetic HLS reproduction package (the circle test stream) and the complete device log you mentioned, covering player init, manifest parsing, track detection, and playback.
  • Confirmation of whether the same SAR handling occurs with a non-MPEG-2 anamorphic source (e.g., an H.264 stream with a non-1:1 SAR), which helps us narrow whether this is specific to the MPEG-2 decode path or the display path in general.

For reference, the KeplerVideoSurfaceView API (including the scalingmode prop on SurfaceViewProps) is documented here: KeplerVideoSurfaceView - Amazon Vega Docs

Thanks for helping us improve the Vega platform.

Warm regards,
Aishwarya