private long getVideoTimestamp(long timestamp) { currentlyShowingIndex = Arrays.binarySearch(robotTimestamps, timestamp); if (currentlyShowingIndex < 0) { int nextIndex = -currentlyShowingIndex + 1; if ((nextIndex < robotTimestamps.length) && (Math.abs(robotTimestamps[-currentlyShowingIndex] - timestamp) > Math.abs(robotTimestamps[nextIndex]))) { currentlyShowingIndex = nextIndex; } else { currentlyShowingIndex = -currentlyShowingIndex; } } if (currentlyShowingIndex < 0) currentlyShowingIndex = 0; if (currentlyShowingIndex >= robotTimestamps.length) currentlyShowingIndex = robotTimestamps.length - 1; currentlyShowingRobottimestamp = robotTimestamps[currentlyShowingIndex]; long videoTimestamp = videoTimestamps[currentlyShowingIndex]; if (hasTimebase) { videoTimestamp = (videoTimestamp * bmdTimeBaseNum * demuxer.getTimescale()) / (bmdTimeBaseDen); } return videoTimestamp; }
private long getVideoTimestamp(long timestamp) { currentlyShowingIndex = Arrays.binarySearch(robotTimestamps, timestamp); if (currentlyShowingIndex < 0) { int nextIndex = -currentlyShowingIndex + 1; if ((nextIndex < robotTimestamps.length) && (Math.abs(robotTimestamps[-currentlyShowingIndex] - timestamp) > Math.abs(robotTimestamps[nextIndex]))) { currentlyShowingIndex = nextIndex; } else { currentlyShowingIndex = -currentlyShowingIndex; } } if (currentlyShowingIndex < 0) currentlyShowingIndex = 0; if (currentlyShowingIndex >= robotTimestamps.length) currentlyShowingIndex = robotTimestamps.length - 1; currentlyShowingRobottimestamp = robotTimestamps[currentlyShowingIndex]; long videoTimestamp = videoTimestamps[currentlyShowingIndex]; if (hasTimebase) { videoTimestamp = (videoTimestamp * bmdTimeBaseNum * demuxer.getTimescale()) / (bmdTimeBaseDen); } return videoTimestamp; }
private long getVideoTimestamp(long timestamp) { currentlyShowingIndex = Arrays.binarySearch(robotTimestamps, timestamp); if (currentlyShowingIndex < 0) { int nextIndex = -currentlyShowingIndex + 1; if ((nextIndex < robotTimestamps.length) && (Math.abs(robotTimestamps[-currentlyShowingIndex] - timestamp) > Math.abs(robotTimestamps[nextIndex]))) { currentlyShowingIndex = nextIndex; } else { currentlyShowingIndex = -currentlyShowingIndex; } } if (currentlyShowingIndex < 0) currentlyShowingIndex = 0; if (currentlyShowingIndex >= robotTimestamps.length) currentlyShowingIndex = robotTimestamps.length - 1; currentlyShowingRobottimestamp = robotTimestamps[currentlyShowingIndex]; long videoTimestamp = videoTimestamps[currentlyShowingIndex]; if (hasTimebase) { videoTimestamp = (videoTimestamp * bmdTimeBaseNum * demuxer.getTimescale()) / (bmdTimeBaseDen); } return videoTimestamp; }
private static int getFrameRate(MP4VideoDemuxer demuxer) throws IOException { demuxer.seekToFrame(0); long startPts = demuxer.getCurrentPTS(); demuxer.seekToFrame(1); long endPts = demuxer.getCurrentPTS(); double step = endPts - startPts; int rate = (int)Math.round((double)demuxer.getTimescale() / step); System.out.println("Framerate is " + rate); return rate; }
private static int getFrameRate(MP4VideoDemuxer demuxer) throws IOException { demuxer.seekToFrame(0); long startPts = demuxer.getCurrentPTS(); demuxer.seekToFrame(1); long endPts = demuxer.getCurrentPTS(); double step = endPts - startPts; int rate = (int)Math.round((double)demuxer.getTimescale() / step); System.out.println("Framerate is " + rate); return rate; }
private static int getFrameRate(MP4VideoDemuxer demuxer) throws IOException { demuxer.seekToFrame(0); long startPts = demuxer.getCurrentPTS(); demuxer.seekToFrame(1); long endPts = demuxer.getCurrentPTS(); double step = endPts - startPts; int rate = (int)Math.round((double)demuxer.getTimescale() / step); System.out.println("Framerate is " + rate); return rate; }