google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.7k stars 6.01k forks source link

Provide an API for metadata & frame extraction without playback #3609

Open mhabzda opened 6 years ago

mhabzda commented 6 years ago

Issue description

I'm trying to extract track information such as title and an artist from the local mp3 file before playing it.

I managed to get track metadata in 'onTracksChanged' callback, but I need access to it earlier. I have File object and its uri and I tried to use Mp3Extractor directly, which needs DataSource, but I'm not sure how to create it.

Could you provide me with the information if such a thing is possible and how to do it?

Version of ExoPlayer being used

2.5.4

andrewlewis commented 6 years ago

The easiest option may be to create a player which is paused (setPlayWhenReady(false)) so that playback doesn't start automatically, then prepare it with your media source. You should get an onTracksChanged callback with the metadata but audio won't start playing.

mhabzda commented 6 years ago

Thank you for your reply, but I wonder if there is a chance to extract metadata without initializing and preparing player? You wrote about the easiest way, so is there another option? Will it take a lot of effort to implement it without using player?

ojw28 commented 6 years ago

@andrewlewis - Should we turn this into a general enhancement request for providing metadata APIs (or alternatively, should we file a new one and dupe this one to it)?

andrewlewis commented 6 years ago

Marking as an enhancement for now.

AndroidDeveloperLB commented 5 years ago

Can you please also consider adding metadata extraction of video files?

tonihei commented 5 years ago

@AndroidDeveloperLB That will be included. There is already pending work in that area and we will notify this thread if we publish something.

AndroidDeveloperLB commented 5 years ago

@tonihei That's great news. But I also wonder something: Doesn't the Android framework already offer such things ? Or do you plan on much more than what it offers, and have a consistent result, or something ?

ened commented 4 years ago

@AndroidDeveloperLB @mhabzda some sample code in my project is available here: https://github.com/ened/flutter_plugin_media_info/blob/master/android/src/main/java/asia/ivity/mediainfo/MediaInfoPlugin.java#L139-L188 . It uses the technique mentioned by @andrewlewis, but comes with the full initialisation of a player instance.

AndroidDeveloperLB commented 4 years ago

@ened Sadly now that Android Q isn't nice to file path, I think you should provide an alternative, that uses Uri or InputStream. Can you please make a repository that shows only this? Meaning of metadata extraction without playback ?

kim-vde commented 4 years ago

Just adding a clarification for #7285: this API would also support video thumbnail extraction.

ademirqueiroga commented 1 year ago

Hello. Do you happen to have any updates regarding the frame extraction API?

andrewlewis commented 1 year ago

We don't have any updates on this yet I'm afraid.

lectricas commented 1 year ago

Coil has this feature that allows to extract the first frame from video: https://coil-kt.github.io/coil/videos/ Although this thing is pretty slow.

I set a transparent background for the player and placed AsyncImage below that. It does work, but flicks with black.

Not sure how to fix this thing