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

[question] Playing MP3 and MP4 from InputStream, is it possible? #603

Closed
rraallvv opened this issue Apr 20, 2018 · 5 comments
Closed

[question] Playing MP3 and MP4 from InputStream, is it possible? #603

rraallvv opened this issue Apr 20, 2018 · 5 comments
Labels

Comments

@rraallvv
Copy link

I've been trying to play an InputStream on Android but it seems there isn't a simple way to do that. The files are compressed and encrypted using LZ4 and AES, so the idea is to get the stream of data without saving the decompressed files to the files system. Does ExoMedia have a way to do that? Thanks.
Keep up the good work!

@brianwernick
Copy link
Owner

You can use a custom DataSource similar to what is needed in #581 that handles the decryption of the source file however you'll have to be careful of the file sizes. I don't know enough about LZ4 to know if it allows partial file decompression, if it doesn't then you'll have to decompress the entire file before returning any data from the DataSource which can have a huge memory footprint.

@rraallvv
Copy link
Author

@brianwernick Thanks for looking into the issue. The file sizes are small, MP3s are under 10KB, and MP4s under 100KB. I think LZ4 streams are not seekable, I read somewhere they have a predefined block size, and compress each block separately but can't tell for sure if that information is stored somewhere after compression. Nevertheless, last night I managed to play the MP3s using JLayer on-the-fly (without storing the the file on disk). Playing audio like that added a few milliseconds of delay to the playback compared to raw PCM from a WAV file, but that's ok, the delay is barely noticeable. I'm not into the details of how the MP4 data is stored into the file, but my guess is that since MP4 plays over a stream on the Internet, maybe I could use some similar approach to play those files from an InputStream, and cover both use cases (MP3 and MP4) with the same library.

@isabsent
Copy link

isabsent commented May 8, 2018

There is a code to play from (unencrypted) InputStream with ExoPlayer.

@rraallvv
Copy link
Author

rraallvv commented May 8, 2018

@isabsent thanks, it's very much appreciated.

@isabsent
Copy link

isabsent commented May 8, 2018

@rraallvv: I am going to place the demo project with this stuff on Github soon.

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

No branches or pull requests

3 participants