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

getScaledFrameAtTime returns black bitmap on some videos #265

Open
DeVictorVH opened this issue Oct 22, 2022 · 7 comments
Open

getScaledFrameAtTime returns black bitmap on some videos #265

DeVictorVH opened this issue Oct 22, 2022 · 7 comments

Comments

@DeVictorVH
Copy link

final FFmpegMediaMetadataRetriever retriever = new FFmpegMediaMetadataRetriever();
retriever.setDataSource(source.getPath());
final Bitmap bitmap = retriever.getScaledFrameAtTime(10000000L, width, height);

It returns black bitmap on some videos, but using a different option (FFmpegMediaMetadataRetriever.OPTION_CLOSEST, OPTION_CLOSEST_SYNC, etc) fixes it but others get the same problem;

Tested on a Redmi 9 (android 11) and Bluestacks emulator (android 7)

@DeVictorVH
Copy link
Author

DeVictorVH commented Nov 4, 2022

In your test application use the following code:
Bitmap b = fmmr.getFrameAtTime();
if (b != null) {
Bitmap b2 = fmmr.getFrameAtTime(4000000, FFmpegMediaMetadataRetriever.OPTION_CLOSEST_SYNC);
if (b2 != null) {
b = b2;
}
}
This fixes the problem but calls getFrameAtTime() 2 times.
Is this a hack and how does it work?

@kyriej
Copy link

kyriej commented Nov 7, 2022

same problem ,hope to solved it

@wseemann
Copy link
Owner

Are all of your videos greater or equal to 10000000L in length? If not, then the library is probably returning the last available frame in the video, which may be black, since your timestamp exceeds the content duration.

@DeVictorVH
Copy link
Author

The duration of the videos is greater than 10000000L.

Some months ago I tried to fix the error, so I downloaded the project, started modifying the native code and if I remember correctly the problem was that FFmpeg couldn't do seek in some situations.

@wseemann
Copy link
Owner

wseemann commented Feb 14, 2023

That makes sense. Thanks for the reply @DeVictorVH. Sorry this library didn't quite meet your needs.

@DeVictorVH
Copy link
Author

That makes sense. Thanks for the reply @DeVictorVH. Sorry this library didn't quite meet your needs.

Bitmap b = fmmr.getFrameAtTime();
if (b != null) {
Bitmap b2 = fmmr.getFrameAtTime(4000000, FFmpegMediaMetadataRetriever.OPTION_CLOSEST_SYNC);
if (b2 != null) {
b = b2;
}
}

This is in the test app but I don't understand why it fixes the problem.

@guiguzixiansheng
Copy link

Can you let the lib avoid crash?

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

4 participants