/** * Reads frames from * * @param filename * @param removing the first Startframe - 1 frames */ public VideoImageSource(String filename, int startFrame) { this.reader = ToolFactory.makeReader(filename); reader.setBufferedImageTypeToGenerate( BufferedImage.TYPE_3BYTE_BGR); // the wrong format for JMTF, but others are not supported reader.addListener(new FrameExtractor()); fillQueue(); while (this.index < startFrame && hasMoreImages()) { getNextImage(); } }
@Override public void gerar() throws Exception { Propriedades prop = new Propriedades(); // pegar as posicoes GeradorPosicoes g = getgPosicoes(); // abrir o video original // create a media reader String idVideoTemp = "2"; String idUsuarioPasta = super.getCocaCola().getJsonCoca().getUsuFaceId().toString(); ClassLoader classLoader = getClass().getClassLoader(); File file = new File(super.getUrlCena2()); IMediaReader mediaReader = ToolFactory.makeReader(file.getAbsolutePath()); // configure it to generate BufferImages mediaReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR); // System.out.println() String folderBase = prop.getProp().getProperty("prop.video.pasta.temp"); File folder = new File(classLoader.getResource("temp/").getPath()); boolean success = (new File(folder.getAbsolutePath() + "/" + idUsuarioPasta)).mkdirs(); if (!success) { System.out.println("Erro ao criar folder"); } System.out.println("Pasta temporária: " + folder.getAbsolutePath() + "/" + idUsuarioPasta); String urlTemp = folder.getAbsolutePath() + "\\" + idUsuarioPasta + "/" + "video2.mov"; IMediaWriter mediaWriter = ToolFactory.makeWriter(urlTemp, mediaReader); String url = "http://festivaldomeujeito.com.br/site/uploads/festival/" + super.getCocaCola().getJsonCoca().getUsuFaceId() + "/avatar_crop.png"; System.out.println(url); super.getCocaCola().setImagem(url); IMediaTool imageMediaTool = new StaticImageMediaTool(super.getCocaCola().getImagem()); mediaReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR); // Adicionou um listener com a imagem estatica mediaReader.addListener(imageMediaTool); mediaReader.addListener(mediaWriter); // Adiciona o listener do nome // Adiciona o listener do nome // Adiciona o listener do nome System.out.println("------------------------Gerando Video 2 -------------- "); while (mediaReader.readPacket() == null) ; System.out.println("------------------------Video 2 GERADO-------------- "); }