Android: Jcodec Framerate and Duration

1.5k views Asked by At

I'm having a hard time getting the right duration and the exact framerate in Jcodec.

My situation is I have a app that shows an array of bitmaps, wherein the user can change its frame rate like 1fps, 5fps, 32fps, all I did was 1000/fps. so 1fps will show 1 bitmap every 1 second, 2fps: 2bitmap and so on, in short the user is the one that supplies the frame rate.I found this but I can't get the right formula to it.

And another thing, about the duration. What if I want 1fps and I have 16 bitmaps. JCodec should produce a 16 seconds video.

How can I achieve that? lets say that the bitmaps will be dynamic. Base on what I understand, Jcodec relies on hard coded duration. not by the number of frames it has encoded and converted to MP4.

Thanks in advance.

1

There are 1 answers

0
Douglas Cooper On

Had a hard time finding this myself. Took some searching through the API.

FileChooser fc = new FileChooser();
File file = fc.showOpenDialog(null);
SeekableByteChannel bc = NIOUtils.readableFileChannel(file);
MP4Demuxer dm = new MP4Demuxer(bc);
DemuxerTrack vt = dm.getVideoTrack();
double frameRate = vt.getMeta().getTotalFrames()/vt.getMeta().getTotalDuration();