/** * Returns the duration of the video in seconds. * * @return The duration of the video in seconds. */ public synchronized long getDuration() { final long duration = (this.reader.getContainer().getStream(this.streamIndex).getDuration()); final double timebase = this.reader.getContainer().getStream(this.streamIndex).getTimeBase().getDouble(); return Math.round(duration * timebase); }
/** * Returns the duration of the video in seconds. * * @return The duration of the video in seconds. */ public synchronized long getDuration() { final long duration = (this.reader.getContainer().getStream(this.streamIndex).getDuration()); final double timebase = this.reader.getContainer().getStream(this.streamIndex).getTimeBase().getDouble(); return Math.round(duration * timebase); }
double timeBase = 0; int videoStreamId = -1; private void seekToMs(IContainer container, long timeMs) { if(videoStreamId == -1) { for(int i = 0; i < container.getNumStreams(); i++) { IStream stream = container.getStream(i); IStreamCoder coder = stream.getStreamCoder(); if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO) { videoStreamId = i; timeBase = stream.getTimeBase().getDouble(); break; } } } long seekTo = (long) (timeMs/1000.0/timeBase); container.seekKeyFrame(videoStreamId, seekTo, IContainer.SEEK_FLAG_BACKWARDS); }
this.streamIndex).getTimeBase().getDouble(); final long position = (long) (timestamp / timebase);
this.streamIndex).getTimeBase().getDouble(); final long position = (long) (timestamp / timebase);
this.streamIndex).getTimeBase().getDouble(); final long position = (long) (timestamp / timebase);
this.streamIndex).getTimeBase().getDouble(); final long position = (long) (timestamp / timebase);
else this.length = (long) (s.getDuration() * s.getTimeBase().getDouble() * 1000d);
else this.length = (long) (s.getDuration() * s.getTimeBase().getDouble() * 1000d);
else this.totalFrames = (long) (s.getDuration() * s.getTimeBase().getDouble() * s.getFrameRate().getDouble());
else this.totalFrames = (long) (s.getDuration() * s.getTimeBase().getDouble() * s.getFrameRate().getDouble());