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

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

Open
mhabzda opened this issue Dec 18, 2017 · 13 comments
Open

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

mhabzda opened this issue Dec 18, 2017 · 13 comments
Assignees

Comments

@mhabzda
Copy link

mhabzda commented Dec 18, 2017

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
Copy link
Collaborator

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
Copy link
Author

mhabzda commented Dec 21, 2017

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
Copy link
Contributor

ojw28 commented Dec 22, 2017

@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
Copy link
Collaborator

Marking as an enhancement for now.

@andrewlewis andrewlewis changed the title How to extract track information(id3 frames) from mp3 file before playing it? Provide an API for metadata extraction without playback Dec 22, 2017
@andrewlewis andrewlewis self-assigned this Jan 2, 2018
ojw28 pushed a commit that referenced this issue Jun 5, 2018
Use PixelCopy API for the first SurfaceCapturer implementation. This supports
devices from API 24+.

Github: #3609.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=197732711
@ojw28 ojw28 assigned andrewlewis and unassigned botaydotcom Aug 1, 2018
@AndroidDeveloperLB
Copy link

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

@tonihei
Copy link
Collaborator

tonihei commented Jan 24, 2019

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

@AndroidDeveloperLB
Copy link

@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
Copy link
Contributor

ened commented Oct 8, 2019

@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
Copy link

@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
Copy link
Contributor

kim-vde commented Apr 24, 2020

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

@ojw28 ojw28 changed the title Provide an API for metadata extraction without playback Provide an API for metadata & frame extraction without playback Apr 30, 2020
kim-vde added a commit that referenced this issue Aug 17, 2020
Issue: #3609
PiperOrigin-RevId: 326991376
kim-vde added a commit that referenced this issue Aug 18, 2020
Issue: #3609
PiperOrigin-RevId: 327176362
@ademirqueiroga
Copy link

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

@andrewlewis
Copy link
Collaborator

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

@lectricas
Copy link

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

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

No branches or pull requests

10 participants