Skip to content

Corrupted files when using on Android maxSize: 1080 #380

@Mihai-github

Description

@Mihai-github

Current behavior

When using VideoCompressor.compress() with maxSize: 1080 on Android, the compressed video file becomes corrupted/unplayable. The compressed video:

  • Shows a black screen when played with react-native-video (ExoPlayer)
  • Throws ExoPlaybackException: ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED error
  • Results in error message: "None of the available extractors could read the stream."
  • The file appears to exist and has a size of 28 (which is weird), but is not in a valid/playable format

This occurs specifically when the maxSize parameter is set. When maxSize is removed (using only bitrate and compressionMethod: 'manual'), compression works correctly.

Code example:

const compressedVideoUri = await VideoCompressor.compress(file.uri, {
  compressionMethod: 'manual',
  maxSize: 1080, // This causes corruption
  minimumFileSizeForCompress: 15,
  bitrate: 5_000_000,
});

Expected behavior

The compressed video should be playable with react-native-video on Android, maintaining proper container format and codec compatibility with ExoPlayer. The maxSize parameter should resize the video resolution without corrupting the file format.

Platform

  • Android
  • iOS

(Note: Issue confirmed on Android; iOS had no issues with the configuration, but used different videos, not sure if this can be the cause but don't think so)

React Native Version

0.75.4

React Native Compressor Version

1.13.0

Reproducible Steps And Demo

  1. Pick a video file from the device library using react-native-image-picker
  2. Compress the video using the configuration above with maxSize: 1080
  3. Attempt to play the compressed video using react-native-video on Android
  4. Observe: Black screen and ExoPlayer error ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED

Workaround: Remove maxSize parameter, and compression works correctly (only using bitrate reduction).

Tested video files: MP4 format, various resolutions (1080p and above), file sizes > 15MB.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions