public void exportCurrentVideo(File selectedFile, long startTimestamp, long endTimestamp) { if (activePlayer != null) { ProgressMonitorInterface monitor = new CustomProgressMonitor("Exporting " + activePlayer.getName(), selectedFile.getAbsolutePath(), 0, 100); monitor.setProgress(10); activePlayer.exportVideo(selectedFile, startTimestamp, endTimestamp, monitor); monitor.close(); } }
public void exportVideo(File selectedFile, long startTimestamp, long endTimestamp, ProgressMonitorInterface monitor) { long startVideoTimestamp = getVideoTimestamp(startTimestamp); long endVideoTimestamp = getVideoTimestamp(endTimestamp); try { VideoConverter.convert(videoFile, selectedFile, startVideoTimestamp, endVideoTimestamp, 8000, monitor); } catch (IOException e) { e.printStackTrace(); } }
public void setActivePlayer(String name) { if (activePlayer != null) { activePlayer.setVisible(false); } if (name != null) { activePlayer = players.get(name); activePlayer.showVideoFrame(timestamp.getLongValue()); activePlayer.setVisible(true); } else { activePlayer = null; } }
VideoDataPlayer player = new VideoDataPlayer(camera, dataDirectory, true); player.setVisible(true); player.showVideoFrame(player.robotTimestamps[i]);
@Override public void notifyOfRewind() { if (activePlayer != null) { activePlayer.showVideoFrame(timestamp.getLongValue()); } }
public void crop(File selectedDirectory, long startTimestamp, long endTimestamp, ProgressMonitorInterface monitor) throws IOException { for (int i = 0; i < videos.size(); i++) { String video = videos.get(i); Camera camera = cameras.get(video); if (monitor != null) { monitor.setNote("Cropping video " + video); monitor.setProgress(50 + ((int) (50.0 * ((double) i / (double) videos.size())))); } File timestampFile = new File(selectedDirectory, camera.getTimestampFileAsString()); File videoFile = new File(selectedDirectory, camera.getVideoFileAsString()); players.get(video).cropVideo(videoFile, timestampFile, startTimestamp, endTimestamp, monitor); } }
public VideoDataPlayer(String name, File dataDirectory, LogProperties logProperties) throws IOException { this.name = name; this.interlaced = logProperties.getInterlaced(name); this.hasTimebase = logProperties.hasTimebase(); if (!hasTimebase) { System.err.println("Video data is using timestamps instead of frame numbers. Falling back to seeking based on timestamp."); } videoFile = new File(dataDirectory, logProperties.getVideoFile(name)); if (!videoFile.exists()) { throw new IOException("Cannot find video: " + videoFile); } File timestampFile = new File(dataDirectory, logProperties.getTimestampFile(name)); parseTimestampData(timestampFile); demuxer = new MP4VideoDemuxer(videoFile); viewer = new HideableMediaFrame(name, demuxer.getWidth(), demuxer.getHeight()); }
public MultiVideoDataPlayer(File dataDirectory, LogProperties logProperties, LongYoVariable timestamp) { this.timestamp = timestamp; this.logProperties = logProperties; for (String video : logProperties.getVideoFiles()) { try { VideoDataPlayer player = new VideoDataPlayer(video, dataDirectory, logProperties); players.put(video, player); videos.add(video); } catch (IOException e) { System.err.println(e.getMessage()); } } if (players.size() > 0) { setActivePlayer(videos.get(0)); } }
@Override public void notifyOfIndexChange(int newIndex) { if (activePlayer != null) { activePlayer.showVideoFrame(timestamp.getLongValue()); } }
public void crop(File selectedDirectory, long startTimestamp, long endTimestamp, ProgressMonitorInterface monitor) throws IOException { for (int i = 0; i < videos.size(); i++) { String video = videos.get(i); if (monitor != null) { monitor.setNote("Cropping video " + video); monitor.setProgress(50 + ((int) (50.0 * ((double) i / (double) videos.size())))); } File timestampFile = new File(selectedDirectory, logProperties.getTimestampFile(video)); File videoFile = new File(selectedDirectory, logProperties.getVideoFile(video)); players.get(video).cropVideo(videoFile, timestampFile, startTimestamp, endTimestamp, monitor); } }
public VideoDataPlayer(Camera camera, File dataDirectory, boolean hasTimeBase) throws IOException { this.name = camera.getNameAsString(); this.interlaced = camera.getInterlaced(); this.hasTimebase = hasTimeBase; if (!hasTimebase) { System.err.println("Video data is using timestamps instead of frame numbers. Falling back to seeking based on timestamp."); } videoFile = new File(dataDirectory, camera.getVideoFileAsString()); if (!videoFile.exists()) { throw new IOException("Cannot find video: " + videoFile); } File timestampFile = new File(dataDirectory, camera.getTimestampFileAsString()); parseTimestampData(timestampFile); demuxer = new MP4VideoDemuxer(videoFile); viewer = new HideableMediaFrame(camera.getNameAsString(), demuxer.getWidth(), demuxer.getHeight()); }
public MultiVideoDataPlayer(File dataDirectory, LogProperties logProperties, YoLong timestamp) { this.timestamp = timestamp; for(int i = 0; i < logProperties.getCameras().size(); i++) { Camera camera = logProperties.getCameras().get(i); try { VideoDataPlayer player = new VideoDataPlayer(camera, dataDirectory, logProperties.getVideo().getHasTimebase()); players.put(camera.getNameAsString(), player); cameras.put(camera.getNameAsString(), camera); videos.add(camera.getNameAsString()); } catch (IOException e) { System.err.println(e.getMessage()); } } if (players.size() > 0) { setActivePlayer(videos.get(0)); } }
public void exportCurrentVideo(File selectedFile, long startTimestamp, long endTimestamp) { if (activePlayer != null) { ProgressMonitorInterface monitor = new CustomProgressMonitor("Exporting " + activePlayer.getName(), selectedFile.getAbsolutePath(), 0, 100); monitor.setProgress(10); activePlayer.exportVideo(selectedFile, startTimestamp, endTimestamp, monitor); monitor.close(); } }
public void setActivePlayer(String name) { if (activePlayer != null) { activePlayer.setVisible(false); } if (name != null) { activePlayer = players.get(name); activePlayer.showVideoFrame(timestamp.getLongValue()); activePlayer.setVisible(true); } else { activePlayer = null; } }
public void exportVideo(File selectedFile, long startTimestamp, long endTimestamp, ProgressMonitorInterface monitor) { long startVideoTimestamp = getVideoTimestamp(startTimestamp); long endVideoTimestamp = getVideoTimestamp(endTimestamp); try { VideoConverter.convert(videoFile, selectedFile, startVideoTimestamp, endVideoTimestamp, monitor); } catch (IOException e) { e.printStackTrace(); } }
@Override public void indexChanged(int newIndex, double newTime) { if (activePlayer != null) { activePlayer.showVideoFrame(timestamp.getLongValue()); } }
long startVideoTimestamp = getVideoTimestamp(startTimestamp); long endVideoTimestamp = getVideoTimestamp(endTimestamp);
@Override public void wasRewound() { if (activePlayer != null) { activePlayer.showVideoFrame(timestamp.getLongValue()); } }
public void cropVideo(File outputFile, File timestampFile, long startTimestamp, long endTimestamp, ProgressMonitorInterface monitor) throws IOException { long startVideoTimestamp = getVideoTimestamp(startTimestamp); long endVideoTimestamp = getVideoTimestamp(endTimestamp); int framerate = VideoConverter.crop(videoFile, outputFile, startVideoTimestamp, endVideoTimestamp, monitor); PrintWriter timestampWriter = new PrintWriter(timestampFile); timestampWriter.println(1); timestampWriter.println(framerate); long pts = 0; /* * PTS gets reorderd to be monotonically increaseing starting from 0 */ for (int i = 0; i < robotTimestamps.length; i++) { long robotTimestamp = robotTimestamps[i]; if (robotTimestamp >= startTimestamp && robotTimestamp <= endTimestamp) { timestampWriter.print(robotTimestamp); timestampWriter.print(" "); timestampWriter.println(pts); pts++; } else if (robotTimestamp > endTimestamp) { break; } } timestampWriter.close(); }
public synchronized void showVideoFrame(long timestamp) { if (timestamp >= currentlyShowingRobottimestamp && timestamp < upcomingRobottimestamp) { return; } long videoTimestamp = getVideoTimestamp(timestamp); if (currentlyShowingIndex + 1 < robotTimestamps.length) { upcomingRobottimestamp = robotTimestamps[currentlyShowingIndex + 1]; } else { upcomingRobottimestamp = currentlyShowingRobottimestamp; } try { demuxer.seekToPTS(videoTimestamp); YUVPicture nextFrame = demuxer.getNextFrame(); viewer.update(nextFrame); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }