sannies / mp4parser

A Java API to read, write and create MP4 files
Apache License 2.0
2.76k stars 566 forks source link

How to get frames of video according to time as pictures(jpg) ? #311

Open wangchenyan opened 6 years ago

wangchenyan commented 6 years ago

thanks

Tomygames commented 6 years ago

"What can't you do?

Create JPEGs from a movie. No - this is no decoder. The MP4 Parser doesn't know how to do that. Create a movie from JPEGs" I bet you're trolling right?

HBiSoft commented 4 years ago

This is not impossible. But you will have to use this library in combination with FFmpegMediaMetadataRetriever.

Let me explain:

You can get time between each frame by doing the following:

totalFrames = videoTrack.getSamples().size();
durationUs = videoTrack.getDuration() * 1000 *1000 / timeScale;
int intervals = Integer.parseInt(String.valueOf(durationUs / frames));

Above, intervals will provide you the intervals (in ms) between each frame. You can now pass these intervals to FFmpegMediaMetadataRetriever and retrieve all the frames from the video.

Please close this issue.