Closed michalrames closed 4 years ago
You can get the FPS by doing the following:
for(int i=0; i<video.getTracks().size();i++){
Track videoTrack = video.getTracks().get(i);
if(videoTrack.getHandler().equals("vide)){
TrackMetaData metaData = videoTrack.getTrackMetaData();
//Get timescale
long timeScale = metaData.getTimescale();
//Get video duration in Us
long durationUs = videoTrack.getDuration() * 1000 *1000 / timeScale;
//Get total frames
long totalFrames = videoTrack.getSamples().size();
//Calculate the frame duration
long perFrameDurationUs = durationUs / totalFrames;
//FPS
long fps = 1000 * 1000 / perFrameDurationUs;
}
}
video
is refering to Movie video = MovieCreator.build(filePath);
Thanks. I have since migrated my code to ffprobe. I think this is worth adding to the examples and/or documentation.
@michalrames Please consider closing the issue
Provided there's no API for reading track FPS, I wanted to calculate it as FPS=framescale/timescale. Timescale can be extracted easily, but I can't see any way to extract framescale.
Am I missing something? Is this a feature request?
My SO question: https://stackoverflow.com/questions/56749565/how-to-obtain-fps-using-mp4parser
Thanks