Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Video compression error: setDataSource failed: status = 0x80000000 #307

Open
1 task done
PhilippPriller opened this issue Aug 29, 2024 · 4 comments
Open
1 task done

Comments

@PhilippPriller
Copy link

Current behavior

Video.compress() crashes on Android 10 (Samsung Galaxy A7) with error: setDataSource failed: status = 0x80000000.
Works on all my other Android Devices, but all of them have Android Version > 10, so maybe thats the issue.

Expected behavior

Should work :)

Platform

  • Android

React Native Version

0.74.3

React Native Compressor Version

1.8.25

Reproducible Steps And Demo

import { Video as VideoCompressor } from 'react-native-compressor'

function compressVideo(path: string) {
    return VideoCompressor.compress(path, {
      compressionMethod: 'auto'
    })
  }

// path example 'file:///data/user/0/xx.xx.xx/cache/mrousavy-2909129058745738728.mov'

I've been able to trace the issue all the way into the AutoVideoCompression.kt file.
There on line 19 setting the data source for some reason fails on that device.

           metaRetriever.setDataSource(srcPath)

I've tried passing the path without the "file:///" part or even passing it as an base64 uri, but on that device nothing seems to work.

Copy link

👋 @PhilippPriller
Thanks for opening your issue here! If you find this package useful hit the star🌟!

@efstathiosntonas
Copy link

@PhilippPriller hi, did you managed to solve this?

@efstathiosntonas
Copy link

efstathiosntonas commented Oct 7, 2024

I added a path normalizer and it fixed it for me:

import {
  createVideoThumbnail
} from 'react-native-compressor';

export function normalizePath(str: string, allPlatforms = false): string {
  if (isAndroid || allPlatforms) {
    if (!str.startsWith('file://')) {
      return `file://${str}`;
    }
  }
  return str;
}


const thumbnail = (await createVideoThumbnail(
  normalizePath(localVideo.uri)
)) as VideoThumbnail;

@PhilippPriller
Copy link
Author

Hey @efstathiosntonas thanks for the reply. I was not able to solve this issue.
My path should already have been normalised and I tried passing it in different formats, but on that particular device/android version nothing worked.

Since this is an extremely rare edge case in my app I decided to simply not compress the video in the case of the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants