Examples of ConverterProcessResult


Examples of org.apache.openmeetings.util.process.ConverterProcessResult

import org.dom4j.io.XMLWriter;

public class CreateLibraryPresentation {
  public static ConverterProcessResult generateXMLDocument(File targetDirectory, String originalDocument,
      String pdfDocument, String swfDocument){
    ConverterProcessResult returnMap = new ConverterProcessResult();
    returnMap.setProcess("generateXMLDocument");   
    try {
     
          Document document = DocumentHelper.createDocument();
          Element root = document.addElement( "presentation" );

          File file = new File(targetDirectory, originalDocument);
          root.addElement( "originalDocument" )
        .addAttribute("lastmod", (new Long(file.lastModified())).toString())
        .addAttribute("size", (new Long(file.length())).toString())         
              .addText( originalDocument );
         
          if (pdfDocument!=null){
            File pdfDocumentFile = new File(targetDirectory, pdfDocument);
            root.addElement( "pdfDocument" )
          .addAttribute("lastmod", (new Long(pdfDocumentFile.lastModified())).toString())
          .addAttribute("size", (new Long(pdfDocumentFile.length())).toString())                
                .addText( pdfDocument );
          }
         
          if (swfDocument!=null){
            File swfDocumentFile = new File(targetDirectory, originalDocument);
            root.addElement( "swfDocument" )
          .addAttribute("lastmod", (new Long(swfDocumentFile.lastModified())).toString())
          .addAttribute("size", (new Long(swfDocumentFile.length())).toString())               
                .addText( swfDocument );   
          }
         
          Element thumbs = root.addElement( "thumbs" );
         
      //Secoond get all Files of this Folder
      FilenameFilter ff = new FilenameFilter() {
           public boolean accept(File b, String name) {
              File f = new File(b, name);
                return f.isFile();
           }
      }
     
      String[] allfiles = targetDirectory.list(ff);     
      if(allfiles!=null){
        Arrays.sort(allfiles);
        for(int i=0; i<allfiles.length; i++){
          File thumbfile = new File(targetDirectory, allfiles[i]);
          if (allfiles[i].startsWith(thumbImagePrefix)){
            thumbs.addElement( "thumb" )
              .addAttribute("lastmod", (new Long(thumbfile.lastModified())).toString())
              .addAttribute("size", (new Long(thumbfile.length())).toString())
                    .addText( allfiles[i] );
          }
        }
      }
         
          // lets write to a file
          XMLWriter writer = new XMLWriter(
              new FileOutputStream(new File(targetDirectory, OmFileHelper.libraryFileName))
          );
          writer.write( document );
          writer.close();
     
          returnMap.setExitValue("0");
         
      return returnMap;
    } catch (Exception err) {
      err.printStackTrace();
      returnMap.setError(err.getMessage());
      returnMap.setExitValue("-1");
      return returnMap;
    }
  }
View Full Code Here

Examples of org.apache.openmeetings.util.process.ConverterProcessResult

    File fileFullPath = new File(OmFileHelper.getUploadTempRoomDir(roomName), inFileName);
    File destinationFolder = OmFileHelper.getNewDir(OmFileHelper.getUploadRoomDir(roomName), fileName);

    log.debug("fullProcessing: " + fullProcessing);
    if (fullProcessing) {
      ConverterProcessResult processOpenOffice = doJodConvert(
          fileFullPath, destinationFolder, fileName);
      returnError.addItem("processOpenOffice", processOpenOffice);
      ConverterProcessResult processThumb = generateThumbs
          .generateBatchThumb(new File(destinationFolder, fileName + ".pdf"), destinationFolder, 80, "thumb");
      returnError.addItem("processThumb", processThumb);
      ConverterProcessResult processSWF = generateSWF
          .generateSwf(destinationFolder, destinationFolder, fileName);
      returnError.addItem("processSWF", processSWF);
    } else {

      log.debug("-- generateBatchThumb --");

      ConverterProcessResult processThumb = generateThumbs
          .generateBatchThumb(fileFullPath, destinationFolder, 80, "thumb");
      returnError.addItem("processThumb", processThumb);

      ConverterProcessResult processSWF = generateSWF.generateSwf(
          fileFullPath.getParentFile(), destinationFolder, fileName);
      returnError.addItem("processSWF", processSWF);
    }

    // now it should be completed so copy that file to the expected location
    File fileWhereToMove = new File(destinationFolder, inFileName);
    fileWhereToMove.createNewFile();
    FileHelper.moveRec(inFile, fileWhereToMove);

    if (fullProcessing) {
      ConverterProcessResult processXML = CreateLibraryPresentation
          .generateXMLDocument(destinationFolder,
              inFileName, fileName + ".pdf",
              fileName + ".swf");
      returnError.addItem("processXML", processXML);
    } else {
      ConverterProcessResult processXML = CreateLibraryPresentation
          .generateXMLDocument(destinationFolder,
              inFileName, null, fileName + ".swf");
      returnError.addItem("processXML", processXML);
    }
View Full Code Here

Examples of org.apache.openmeetings.util.process.ConverterProcessResult

      return ProcessHelper.executeScript("doJodConvert",
          argv.toArray(new String[argv.size()]));

    } catch (Exception ex) {
      log.error("doJodConvert", ex);
      return new ConverterProcessResult("doJodConvert", ex.getMessage(), ex);
    }
  }
View Full Code Here

Examples of org.apache.openmeetings.util.process.ConverterProcessResult

              , "-i", path
              , "-an" // only input files with video will be treated as video sources
              , "-v", "error"
              , "-f", "null"
              , "file.null"};
          ConverterProcessResult r = ProcessHelper.executeScript("checkFlvPod_" + pod , args);
          returnLog.add(r);
          if ("0".equals(r.getExitValue())) {
            //TODO need to remove smallest gap
            long diff = diff(meta.getRecordStart(), meta.getFlvRecording().getRecordStart());
            if (diff != 0L) {
              // stub to add
              // ffmpeg -y -loop 1 -i /home/solomax/work/openmeetings/branches/3.0.x/dist/red5/webapps/openmeetings/streams/hibernate/default_interview_image.jpg -filter_complex '[0:0]scale=320:260' -c:v libx264 -t 00:00:29.059 -pix_fmt yuv420p out.flv
              File podFB = new File(streamFolder, meta.getStreamName() + "_pod_" + pod + "_blank.flv");
              String podPB = podFB.getCanonicalPath();
              String[] argsPodB = new String[] { getPathToFFMPEG(), "-y" //
                  , "-loop", "1", "-i", defaultInterviewImageFile.getCanonicalPath() //
                  , "-filter_complex", String.format("[0:0]scale=%1$d:%2$d", flvWidth, flvHeight) //
                  , "-c:v", "libx264" //
                  , "-t", formatMillis(diff) //
                  , "-pix_fmt", "yuv420p" //
                  , podPB };
              returnLog.add(ProcessHelper.executeScript("blankFlvPod_" + pod , argsPodB));
             
              //ffmpeg -y -i out.flv -i rec_15_stream_4_2014_07_15_20_41_03.flv -filter_complex '[0:0]setsar=1/1[sarfix];[1:0]scale=320:260,setsar=1/1[scale];[sarfix] [scale] concat=n=2:v=1:a=0 [v]' -map '[v]'  output1.flv
              File podF = new File(streamFolder, meta.getStreamName() + "_pod_" + pod + ".flv");
              String podP = podF.getCanonicalPath();
              String[] argsPod = new String[] { getPathToFFMPEG(), "-y"//
                  , "-i", podPB //
                  , "-i", path //
                  , "-filter_complex", String.format("[0:0]setsar=1/1[sarfix];[1:0]scale=%1$d:%2$d,setsar=1/1[scale];[sarfix] [scale] concat=n=2:v=1:a=0 [v]", flvWidth, flvHeight) //
                  , "-map", "[v]" //
                  , podP };
              returnLog.add(ProcessHelper.executeScript("shiftedFlvPod_" + pod , argsPod));
 
              pods[pod - 1] = podP;
            } else {
              pods[pod - 1] = path;
            }
          }
          found = true;
        }
      }
      if (!found) {
        ConverterProcessResult r = new ConverterProcessResult();
        r.setProcess("CheckFlvFilesExists");
        r.setError("No valid pods found");
        returnLog.add(r);
        return;
      }
      boolean shortest = false;
      List<String> args = new ArrayList<String>();
View Full Code Here

Examples of org.apache.openmeetings.util.process.ConverterProcessResult

      // Add empty pieces at the beginning and end of the wav
      // FIXME: Is this really needed anymore?!

    } catch (Exception err) {
      log.error("[startConversion]", err);
      returnLog.add(new ConverterProcessResult("startConversion", err.getMessage(), err));
    }

    return returnLog;
  }
View Full Code Here

Examples of org.apache.openmeetings.util.process.ConverterProcessResult

          "-ar", "22050", "-acodec", "libmp3lame", "-ab", "32k",
          "-vcodec", "flv",
          outputFullFlv.getCanonicalPath() };
      // "-s", flvWidth + "x" + flvHeight,

      ConverterProcessResult returnMapConvertFLV = ProcessHelper.executeScript("uploadFLV ID :: "
          + fileExplorerItem.getFileExplorerItemId(), argv_fullFLV);
     
      //Parse the width height from the FFMPEG output
      FlvDimension flvDimension = getFlvDimension(returnMapConvertFLV.getError());
      int flvWidth = flvDimension.width;
      int flvHeight = flvDimension.height;
     
     
      fileExplorerItem.setFlvWidth(flvWidth);
      fileExplorerItem.setFlvHeight(flvHeight);

      returnLog.add(returnMapConvertFLV);

      String hashFileFullNameJPEG = "UPLOADFLV_" + fileExplorerItem.getFileExplorerItemId() + ".jpg";
      File outPutJpeg = new File(getStreamsHibernateDir(), name + ".jpg");

      fileExplorerItem.setPreviewImage(hashFileFullNameJPEG);

      String[] argv_previewFLV = new String[] { getPathToFFMPEG(), "-y", "-i",
          outputFullFlv.getCanonicalPath(), "-vcodec", "mjpeg", "-vframes", "1", "-an",
          "-f", "rawvideo", "-s", flvWidth + "x" + flvHeight,
          outPutJpeg.getCanonicalPath() };

      returnLog.add(ProcessHelper.executeScript("previewUpload ID :: "
              + fileExplorerItem.getFileExplorerItemId(),
              argv_previewFLV));

      fileExplorerItemDaoImpl.updateFileOrFolder(fileExplorerItem);

      for (ConverterProcessResult returnMap : returnLog) {
        flvRecordingLogDaoImpl.addFLVRecordingLog("generateFFMPEG", null, returnMap);
      }
    } catch (Exception err) {
      log.error("[convertToFLV]", err);
      returnLog.add(new ConverterProcessResult("convertToFLV", err.getMessage(), err));
    }

    return returnLog;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.