コード例 #1
0
ファイル: Video2.java プロジェクト: fmaymone/cocacolafestival
  @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
 /**
  * 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();
   }
 }
コード例 #3
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");
 }
コード例 #4
0
  private IMediaReader[] gerarVideosUsuario(String respostas) {
    // metodo que, baseado nas respostas do usuario pega o video necessario
    String[] split = respostas.split(";");

    IMediaReader[] retorno = new IMediaReader[respostas.length()];

    for (int i = 0; i < split.length; i++) {

      String url = processarResposta(split[i]);
      IMediaReader temp = ToolFactory.makeReader(url);
      retorno[i] = temp;
    }

    return retorno;
  }