use of android.media.videoeditor.TransitionAlpha in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPreviewTest method testStartPreviewAddRemoveMediaItems.
/**
* To Test Preview : Add Media and Remove Media Item (Without any Media
* Items in the story Board)
*/
@LargeTest
public void testStartPreviewAddRemoveMediaItems() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String alphaFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
boolean flagForException = false;
final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem.setExtractBoundaries(0, 15000);
mVideoEditor.addMediaItem(mediaVideoItem);
final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem);
final TransitionAlpha transition1And2 = mVideoEditorHelper.createTAlpha("transition", mediaVideoItem, mediaImageItem, 3000, Transition.BEHAVIOR_SPEED_UP, alphaFilename, 10, false);
mVideoEditor.addTransition(transition1And2);
final EffectColor effectColor = mVideoEditorHelper.createEffectItem(mediaImageItem, "effect", 5000, 3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
mediaImageItem.addEffect(effectColor);
assertEquals("removing Media item 1", mediaVideoItem, mVideoEditor.removeMediaItem(mediaVideoItem.getId()));
assertEquals("removing Media item 2", mediaImageItem, mVideoEditor.removeMediaItem(mediaImageItem.getId()));
try {
mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
public void onProgress(Object item, int action, int progress) {
}
});
final SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
mVideoEditor.startPreview(surfaceHolder, 0, -1, false, 1, new PreviewProgressListener() {
public void onProgress(VideoEditor videoEditor, long timeMs, OverlayData overlayData) {
}
public void onStart(VideoEditor videoEditor) {
setPreviewStart();
}
public void onStop(VideoEditor videoEditor) {
setPreviewStop();
}
public void onError(VideoEditor videoEditor, int error) {
setPreviewError();
}
});
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Preview with removed Media Items", flagForException);
}
use of android.media.videoeditor.TransitionAlpha in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorExportTest method testExportMMS.
/**
* To Test Export : With Video and Image : MMS use case
*
* @throws Exception
*/
@LargeTest
public void testExportMMS() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp";
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String videoItemFilename2 = INPUT_FILE_PATH + "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
final String maskFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
final MediaVideoItem mediaItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaItem1.setExtractBoundaries(2000, 7000);
mVideoEditor.addMediaItem(mediaItem1);
final TransitionAlpha transition1 = mVideoEditorHelper.createTAlpha("transition1", null, mediaItem1, 2000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, true);
mVideoEditor.addTransition(transition1);
final MediaImageItem mediaItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFilename1, 8000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaItem2);
final MediaVideoItem mediaItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaItem3.setExtractBoundaries(0, 8000);
mVideoEditor.addMediaItem(mediaItem3);
final TransitionSliding transition2And3 = mVideoEditorHelper.createTSliding("transition2", mediaItem2, mediaItem3, 4000, Transition.BEHAVIOR_MIDDLE_FAST, TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN);
mVideoEditor.addTransition(transition2And3);
final TransitionCrossfade transition3 = mVideoEditorHelper.createTCrossFade("transition3", mediaItem3, null, 3500, Transition.BEHAVIOR_MIDDLE_SLOW);
mVideoEditor.addTransition(transition3);
final EffectColor effectColor = mVideoEditorHelper.createEffectItem(mediaItem2, "effect", 0, 3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
mediaItem2.addEffect(effectColor);
mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_11_9);
try {
final int[] progressUpdate = new int[100];
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144, MediaProperties.BITRATE_800K, new ExportProgressListener() {
int i = 0;
public void onProgress(VideoEditor ve, String outFileName, int progress) {
progressUpdate[i++] = progress;
}
});
mVideoEditorHelper.checkProgressCBValues(progressUpdate);
} catch (Exception e) {
assertTrue("Error in Export" + e.toString(), false);
}
final long storyBoardDuration = mediaItem1.getTimelineDuration() + mediaItem2.getTimelineDuration() + mediaItem3.getTimelineDuration() - transition2And3.getDuration();
mVideoEditorHelper.validateExport(mVideoEditor, outFilename, MediaProperties.HEIGHT_144, 0, storyBoardDuration, MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
use of android.media.videoeditor.TransitionAlpha in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorExportTest method testExportWithoutMediaItemsAddRemove.
/**
* To Test Export : With Media Items add and removed in the story Board
*
* @throws Exception
*/
@LargeTest
public void testExportWithoutMediaItemsAddRemove() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp";
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg";
final String maskFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
boolean flagForException = false;
final MediaVideoItem mediaItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaItem1.setExtractBoundaries(0, 15000);
mVideoEditor.addMediaItem(mediaItem1);
final MediaImageItem mediaItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaItem2);
final TransitionAlpha transition1 = mVideoEditorHelper.createTAlpha("transition1", mediaItem1, mediaItem2, 3000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, false);
mVideoEditor.addTransition(transition1);
final EffectColor effectColor = mVideoEditorHelper.createEffectItem(mediaItem2, "effect", 12000, 3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
mediaItem2.addEffect(effectColor);
mVideoEditor.removeMediaItem(mediaItem1.getId());
mVideoEditor.removeMediaItem(mediaItem2.getId());
try {
final int[] progressUpdate = new int[100];
mVideoEditor.export("/sdcard/Test.3gp", MediaProperties.HEIGHT_720, MediaProperties.BITRATE_800K, new ExportProgressListener() {
int i = 0;
public void onProgress(VideoEditor ve, String outFileName, int progress) {
progressUpdate[i++] = progress;
}
});
mVideoEditorHelper.checkProgressCBValues(progressUpdate);
} catch (IllegalStateException e) {
flagForException = true;
}
assertTrue("Export with MediaItem added and removed", flagForException);
}
use of android.media.videoeditor.TransitionAlpha in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testTransitionAlpha.
/**
* To test Transition : Alpha with all behavior
* SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST
*/
@LargeTest
public void testTransitionAlpha() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
final String videoItemFilename2 = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_128kbps_1_35.3gp";
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg";
final String videoItemFilename3 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_192kbps_1_5.mp4";
final String videoItemFilename4 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_256kbps_0_30.mp4";
final String videoItemFilename5 = INPUT_FILE_PATH + "H263_profile0_176x144_10fps_96kbps_0_25.3gp";
final String maskFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
boolean flagForException = false;
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem1.setExtractBoundaries(0, 15000);
mVideoEditor.addMediaItem(mediaVideoItem1);
final MediaVideoItem mediaVideoItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem2.setExtractBoundaries(0, 15000);
mVideoEditor.addMediaItem(mediaVideoItem2);
final TransitionAlpha transition1And2 = mVideoEditorHelper.createTAlpha("transition1And2", mediaVideoItem1, mediaVideoItem2, 3000, Transition.BEHAVIOR_SPEED_UP, maskFilename, 10, false);
mVideoEditor.addTransition(transition1And2);
assertTrue("Transition ID", transition1And2.getId().equals("transition1And2"));
assertEquals("Transtion After Media item", mediaVideoItem1, transition1And2.getAfterMediaItem());
assertEquals("Transtion Before Media item", mediaVideoItem2, transition1And2.getBeforeMediaItem());
assertEquals("Transtion Duration", 3000, transition1And2.getDuration());
assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_UP, transition1And2.getBehavior());
assertTrue("Transition maskFile", transition1And2.getMaskFilename().equals(maskFilename));
assertEquals("Transition BlendingPercent", 10, transition1And2.getBlendingPercent());
assertFalse("Transition Invert", transition1And2.isInvert());
final MediaImageItem mediaImageItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem3);
final TransitionAlpha transition2And3 = mVideoEditorHelper.createTAlpha("transition2And3", mediaVideoItem2, mediaImageItem3, 1000, Transition.BEHAVIOR_SPEED_DOWN, maskFilename, 30, false);
mVideoEditor.addTransition(transition2And3);
assertTrue("Transition ID", transition2And3.getId().equals("transition2And3"));
assertEquals("Transtion After Media item", mediaVideoItem2, transition2And3.getAfterMediaItem());
assertEquals("Transtion Before Media item", mediaImageItem3, transition2And3.getBeforeMediaItem());
assertEquals("Transtion Duration", 1000, transition2And3.getDuration());
assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_DOWN, transition2And3.getBehavior());
assertTrue("Transition maskFile", transition2And3.getMaskFilename().equals(maskFilename));
assertEquals("Transition BlendingPercent", 30, transition2And3.getBlendingPercent());
assertFalse("Transition Invert", transition2And3.isInvert());
final MediaVideoItem mediaVideoItem4 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem4.setExtractBoundaries(0, 18000);
mVideoEditor.addMediaItem(mediaVideoItem4);
final TransitionAlpha transition3And4 = mVideoEditorHelper.createTAlpha("transition3And4", mediaImageItem3, mediaVideoItem4, 5000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, false);
mVideoEditor.addTransition(transition3And4);
assertTrue("Transition ID", transition3And4.getId().equals("transition3And4"));
assertEquals("Transtion After Media item", mediaImageItem3, transition3And4.getAfterMediaItem());
assertEquals("Transtion Before Media item", mediaVideoItem4, transition3And4.getBeforeMediaItem());
assertEquals("Transtion Duration", 5000, transition3And4.getDuration());
assertEquals("Transtion Behavior", Transition.BEHAVIOR_LINEAR, transition3And4.getBehavior());
assertTrue("Transition maskFile", transition3And4.getMaskFilename().equals(maskFilename));
assertEquals("Transition BlendingPercent", 50, transition3And4.getBlendingPercent());
assertFalse("Transition Invert", transition3And4.isInvert());
final MediaVideoItem mediaVideoItem5 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", videoItemFilename4, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaVideoItem5);
final TransitionAlpha transition4And5 = mVideoEditorHelper.createTAlpha("transition4And5", mediaVideoItem4, mediaVideoItem5, 8000, Transition.BEHAVIOR_MIDDLE_FAST, maskFilename, 70, true);
mVideoEditor.addTransition(transition4And5);
assertTrue("Transition ID", transition4And5.getId().equals("transition4And5"));
assertEquals("Transtion After Media item", mediaVideoItem4, transition4And5.getAfterMediaItem());
assertEquals("Transtion Before Media item", mediaVideoItem5, transition4And5.getBeforeMediaItem());
assertEquals("Transtion Duration", 8000, transition4And5.getDuration());
assertEquals("Transtion Behavior", Transition.BEHAVIOR_MIDDLE_FAST, transition4And5.getBehavior());
assertTrue("Transition maskFile", transition4And5.getMaskFilename().equals(maskFilename));
assertEquals("Transition BlendingPercent", 70, transition4And5.getBlendingPercent());
assertTrue("Transition Invert", transition4And5.isInvert());
final MediaVideoItem mediaVideoItem6 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", videoItemFilename5, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem6.setExtractBoundaries(0, 20000);
mVideoEditor.addMediaItem(mediaVideoItem6);
try {
mVideoEditorHelper.createTAlpha("transition5And6", mediaVideoItem5, mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_SLOW, INPUT_FILE_PATH + "imDummyFile.jpg", 70, true);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("MaskFile is not exsisting", flagForException);
flagForException = false;
try {
mVideoEditorHelper.createTAlpha("transition5And6", null, null, 2000, Transition.BEHAVIOR_MIDDLE_SLOW, maskFilename, 101, true);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Invalid Blending Percent", flagForException);
flagForException = false;
try {
mVideoEditorHelper.createTAlpha("transitiond6", mediaVideoItem4, mediaVideoItem5, 2000, Transition.BEHAVIOR_SPEED_UP - 1, maskFilename, 30, false);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Transition FadeBlack with Invalid behavior", flagForException);
flagForException = false;
try {
mVideoEditorHelper.createTAlpha("transitiond6", mediaVideoItem4, mediaVideoItem5, 2000, Transition.BEHAVIOR_MIDDLE_FAST + 1, maskFilename, 30, false);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Transition FadeBlack with Invalid behavior", flagForException);
}
use of android.media.videoeditor.TransitionAlpha in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testTransitionAlphaBasic.
/**
* To test: Need a basic test case for the get value for TransitionAlpha
* ( ie. getBlendingPercent, getMaskFilename, isInvert)
*
* @throws Exception
*/
@LargeTest
public void testTransitionAlphaBasic() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
final String maskFilename = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
boolean flagForException = false;
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem1.setExtractBoundaries(0, 15000);
final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", maskFilename, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaImageItem.setDuration(15000);
mVideoEditor.addMediaItem(mediaVideoItem1);
mVideoEditor.addMediaItem(mediaImageItem);
final TransitionAlpha transition1And2 = mVideoEditorHelper.createTAlpha("transition1And2", mediaVideoItem1, mediaImageItem, 3000, Transition.BEHAVIOR_SPEED_UP, maskFilename, 10, false);
mVideoEditor.addTransition(transition1And2);
assertTrue("Transition maskFile", transition1And2.getMaskFilename().equals(maskFilename));
assertEquals("Transition BlendingPercent", 10, transition1And2.getBlendingPercent());
assertFalse("Transition Invert", transition1And2.isInvert());
}
Aggregations