예제 #1
0
  @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-------------- ");
  }
예제 #2
0
 /*
  * Will create a writer for file named 'outputFilename'
  */
 public ImageToVideo(String Filename, double interval, int width, int height) {
   outputFilename = Filename;
   v_MICRO_SECONDS_BETWEEN_FRAMES = interval;
   // let's make a IMediaWriter to write the file.
   writer = ToolFactory.makeWriter(outputFilename);
   // We tell it we're going to add one video stream, with id 0,
   // at position 0, and that it will have a fixed frame rate of FRAME_RATE.
   // 4th and 5th parameter are width and height of the created video.
   writer.addVideoStream(0, 0, width, height);
   // writer.addVideoStream(0, 0, 100, 100);
   // System.err.println("hello");
 }