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

Correct way to decode video file and show it with FFmpegFrameGrabber - Android #100

Open
ShihabSoft opened this issue Mar 10, 2015 · 4 comments
Labels

Comments

@ShihabSoft
Copy link

Iam querying around the internet for a week.For a correct way to implement a video playback using FFmpegFrameGrabber.

I have tried using all code snippets.

i know when each and every frame the frame number is increased and timestamp also incremented.

But for each and every video file the fps rate may vary.

So in the loop

I used Thread.sleep(1000/fps) for making the video frames play as a smooth movie.

But it lags so much between each and every frame.

And when i used a static millisecond like 10 or 20 or 30 its goes smooth for one video file.But after changing the video it goes so fast or so lags.

Can u please mention the correct way to grab frame and set it to the ImageView.

And one more request.

Can anyone please mention what is the correct way to play the audio samples from the grabbed frame.

@saudet
Copy link
Member

saudet commented Mar 15, 2015

sleep() isn't usually precise enough for smooth video playback. We usually need to do some amount of busy waiting in a tight loop.

If someone has more specific information about the best way to go about this on Android, please let us know! Thanks

@saudet
Copy link
Member

saudet commented Apr 11, 2015

Let me know when you have a sample with audio and everything ready, it will be of great help. Thanks for everything!

@leofarage
Copy link

I'm doing something like what you're trying to do. I based my code on the Lunar Lander sample code from google which uses a SurfaceView for drawing the frames. The video is pretty smooth doesn't matter how many times I play it.

My problem is with playing the audio. I'm using this tutorial for playing the audio from FrameGrabber -- which plays fine but the audio and frames are not synced, having the audio ending before the frames.

I noticed that the FrameGrabber returns a bunch of audio before the first frame and the last second returns only frames but no audio. I noticed that a Frame never has audio and video -- just audio or video.

As soon as I can resolve this issue I can send it to github to be used as a sample.

Cheers.

@saudet
Copy link
Member

saudet commented Apr 26, 2015

Each frame comes with a timestamp, so we need to play them back, based on that info. I don't know what would be the best way to achieve synchronization on Android, but I suspect we can find a lot of info about that from the indie games community...

@ShihabSoft
Copy link
Author

@leofarage Thanks for using my code.

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