Beispiel #1
0
 private void montageOriginalVideo(String inputFile, boolean isSelectedDelete) {
   if (videoPath.equals(diaryEditNote.mediaPath)) {
     return;
   }
   XMp4Box mMp4Box = new XMp4Box();
   String videoID = DiaryController.getNextUUID();
   String RECORD_FILE_DIR =
       Constant.SD_STORAGE_ROOT + "/" + ActiveAccount.getInstance(this).getLookLookID() + "/video";
   String outputFile =
       Environment.getExternalStorageDirectory() + RECORD_FILE_DIR + "/" + videoID + ".mp4";
   if (isSelectedDelete) {
     String outputFile1 =
         Environment.getExternalStorageDirectory()
             + RECORD_FILE_DIR
             + "/"
             + videoID
             + "_temp1.mp4";
     int ret1 = mMp4Box.splitFile(inputFile, outputFile1, 0, (float) startMontageTime);
     String outputFile2 =
         Environment.getExternalStorageDirectory()
             + RECORD_FILE_DIR
             + "/"
             + videoID
             + "_temp2.mp4";
     int ret2 =
         mMp4Box.splitFile(inputFile, outputFile2, (float) endMontageTime, (float) videoDuration);
     Log.d(
         TAG,
         "ret1 = "
             + ret1
             + " ret2 = "
             + ret2
             + " startTime = "
             + startMontageTime
             + " endTime = "
             + endMontageTime
             + " duration = "
             + videoDuration);
     Log.d(
         TAG,
         "len1 = "
             + (new Mp4InfoUtils(outputFile1).totaltime)
             + " len2 = "
             + (new Mp4InfoUtils(outputFile2).totaltime));
     mMp4Box.appendOpen(outputFile);
     if (ret1 == 0) {
       mMp4Box.appendFile(outputFile1);
       ZFileSystem.delFile(outputFile1);
     }
     if (ret2 == 0) {
       mMp4Box.appendFile(outputFile2);
       ZFileSystem.delFile(outputFile2);
     }
     mMp4Box.appendClose();
   } else {
     int ret =
         mMp4Box.splitFile(
             inputFile, outputFile, (float) startMontageTime, (float) endMontageTime); // 1s
     Log.d(
         TAG,
         "ret = "
             + ret
             + " startMontageTime = "
             + startMontageTime
             + " endMontageTime = "
             + endMontageTime);
   }
   originalPathList.add(outputFile);
   curOriginalVideoPath = outputFile;
 }
Beispiel #2
0
  private void montageVideo(String inputFile, boolean isSelectedDelete) {
    XMp4Box mMp4Box = new XMp4Box();
    String videoID = DiaryController.getNextUUID();
    String RECORD_FILE_DIR =
        Constant.SD_STORAGE_ROOT + "/" + ActiveAccount.getInstance(this).getLookLookID() + "/video";
    String outputFile =
        Environment.getExternalStorageDirectory() + RECORD_FILE_DIR + "/" + videoID + ".mp4";
    if (isSelectedDelete) {
      String outputFile1 =
          Environment.getExternalStorageDirectory()
              + RECORD_FILE_DIR
              + "/"
              + videoID
              + "_temp1.mp4";
      int ret1 = mMp4Box.splitFile(inputFile, outputFile1, 0, (float) startMontageTime);
      String outputFile2 =
          Environment.getExternalStorageDirectory()
              + RECORD_FILE_DIR
              + "/"
              + videoID
              + "_temp2.mp4";
      int ret2 =
          mMp4Box.splitFile(inputFile, outputFile2, (float) endMontageTime, (float) videoDuration);
      Log.d(
          TAG,
          "ret1 = "
              + ret1
              + " ret2 = "
              + ret2
              + " startTime = "
              + startMontageTime
              + " endTime = "
              + endMontageTime
              + " duration = "
              + videoDuration);
      Log.d(
          TAG,
          "len1 = "
              + (new Mp4InfoUtils(outputFile1).totaltime)
              + " len2 = "
              + (new Mp4InfoUtils(outputFile2).totaltime));
      mMp4Box.appendOpen(outputFile);
      if (ret1 == 0) {
        mMp4Box.appendFile(outputFile1);
        ZFileSystem.delFile(outputFile1);
      }
      if (ret2 == 0) {
        mMp4Box.appendFile(outputFile2);
        ZFileSystem.delFile(outputFile2);
      }
      mMp4Box.appendClose();
    } else {
      int ret =
          mMp4Box.splitFile(
              inputFile, outputFile, (float) startMontageTime, (float) endMontageTime); // 1s
      Log.d(
          TAG,
          "ret = "
              + ret
              + " startMontageTime = "
              + startMontageTime
              + " endMontageTime = "
              + endMontageTime);
    }

    if (isVideoRolated()) {
      mMediaPlayer.saveOrientation(outputFile);
    }

    ivDone.setEnabled(true);
    ivUndo.setEnabled(true);
    OperateNote operate = new OperateNote();
    operate.operateType = OPERATE_CLIP;
    operate.videoPath = outputFile;
    operate.angle = curAngle;
    operate.coverTime = videoCoverTime;
    curVideoPath = outputFile;
    curVideoDuration = new Mp4InfoUtils(curVideoPath).totaltime;
    Log.d(
        TAG,
        "curVideoPath = "
            + curVideoPath
            + " curVideoDuration = "
            + curVideoDuration
            + " inputFile = "
            + inputFile);
    operateNotesList.add(operate);

    reloadVideo();
  }