Open ShihabSoft opened 9 years ago
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
Let me know when you have a sample with audio and everything ready, it will be of great help. Thanks for everything!
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.
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...
@leofarage Thanks for using my code.
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.