use of android.media.videoeditor.MediaImageItem 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.MediaImageItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testTransitionCrossFade.
/**
* To test Transition : CrossFade with all behavior
* SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST
*/
@LargeTest
public void testTransitionCrossFade() 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_1600x1200.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";
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 TransitionCrossfade transition1And2 = mVideoEditorHelper.createTCrossFade("transition1And2", mediaVideoItem1, mediaVideoItem2, 3000, Transition.BEHAVIOR_SPEED_UP);
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());
final MediaImageItem mediaImageItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem3);
final TransitionCrossfade transition2And3 = mVideoEditorHelper.createTCrossFade("transition2And3", mediaVideoItem2, mediaImageItem3, 1000, Transition.BEHAVIOR_SPEED_DOWN);
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());
final MediaVideoItem mediaVideoItem4 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem4.setExtractBoundaries(0, 18000);
mVideoEditor.addMediaItem(mediaVideoItem4);
final TransitionCrossfade transition3And4 = mVideoEditorHelper.createTCrossFade("transition3And4", mediaImageItem3, mediaVideoItem4, 5000, Transition.BEHAVIOR_LINEAR);
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());
final MediaVideoItem mediaVideoItem5 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", videoItemFilename4, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaVideoItem5);
final TransitionCrossfade transition4And5 = mVideoEditorHelper.createTCrossFade("transition4And5", mediaVideoItem4, mediaVideoItem5, 8000, Transition.BEHAVIOR_MIDDLE_FAST);
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());
final MediaVideoItem mediaVideoItem6 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", videoItemFilename5, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem6.setExtractBoundaries(0, 20000);
mVideoEditor.addMediaItem(mediaVideoItem6);
final TransitionCrossfade transition5And6 = mVideoEditorHelper.createTCrossFade("transition5And6", mediaVideoItem5, mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_SLOW);
mVideoEditor.addTransition(transition5And6);
assertTrue("Transition ID", transition5And6.getId().equals("transition5And6"));
assertEquals("Transtion After Media item", mediaVideoItem5, transition5And6.getAfterMediaItem());
assertEquals("Transtion Before Media item", mediaVideoItem6, transition5And6.getBeforeMediaItem());
assertEquals("Transtion Duration", 2000, transition5And6.getDuration());
assertEquals("Transtion Behavior", Transition.BEHAVIOR_MIDDLE_SLOW, transition5And6.getBehavior());
flagForException = false;
try {
mVideoEditorHelper.createTCrossFade("transitiond6", mediaVideoItem5, mediaVideoItem6, 2000, Transition.BEHAVIOR_SPEED_UP - 1);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Transition FadeBlack with Invalid behavior", flagForException);
flagForException = false;
try {
mVideoEditorHelper.createTCrossFade("transitiond6", mediaVideoItem5, mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_FAST + 1);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Transition FadeBlack with Invalid behavior", flagForException);
}
use of android.media.videoeditor.MediaImageItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorStressTest method testStressMediaProperties.
/**
* To stress test media properties
*
* @throws Exception
*/
@LargeTest
public void testStressMediaProperties() throws Exception {
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final String VideoItemFileName1 = INPUT_FILE_PATH + "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
final String ImageItemFileName2 = INPUT_FILE_PATH + "IMG_640x480.jpg";
final String AudioItemFileName3 = INPUT_FILE_PATH + "AACLC_44.1kHz_256kbps_s_1_17.mp4";
final String[] loggingInfo = new String[1];
int i = 0;
final int videoAspectRatio = MediaProperties.ASPECT_RATIO_3_2;
final int videoFileType = MediaProperties.FILE_MP4;
final int videoCodecType = MediaProperties.VCODEC_H264;
final int videoDuration = 77366;
final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
final int videoLevel = MediaProperties.H264Level.H264Level13;
final int videoHeight = MediaProperties.HEIGHT_720;
final int videoWidth = 1080;
final int imageAspectRatio = MediaProperties.ASPECT_RATIO_4_3;
final int imageFileType = MediaProperties.FILE_JPEG;
final int imageWidth = 640;
final int imageHeight = MediaProperties.HEIGHT_480;
final int audioDuration = 77554;
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
final int audioSamplingFrequency = 44100;
final int audioChannel = 2;
writeTestCaseHeader("testStressMediaProperties");
getBeginMemory();
for (i = 0; i < 50; i++) {
if (i % 3 == 0) {
final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, "m1" + i, VideoItemFileName1, renderingMode);
mVideoEditor.addMediaItem(mediaItem1);
mediaItem1.setExtractBoundaries(0, 20000);
assertEquals("Aspect Ratio Mismatch", videoAspectRatio, mediaItem1.getAspectRatio());
assertEquals("File Type Mismatch", videoFileType, mediaItem1.getFileType());
assertEquals("VideoCodec Mismatch", videoCodecType, mediaItem1.getVideoType());
assertEquals("duration Mismatch", videoDuration, mediaItem1.getDuration());
assertEquals("Video Profile ", videoProfile, mediaItem1.getVideoProfile());
assertEquals("Video Level ", videoLevel, mediaItem1.getVideoLevel());
assertEquals("Video height ", videoHeight, mediaItem1.getHeight());
assertEquals("Video width ", videoWidth, mediaItem1.getWidth());
mVideoEditor.removeMediaItem("m1" + i);
}
if (i % 3 == 1) {
final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, "m2" + i, ImageItemFileName2, 10000, renderingMode);
mVideoEditor.addMediaItem(mediaItem2);
assertEquals("Aspect Ratio Mismatch", imageAspectRatio, mediaItem2.getAspectRatio());
assertEquals("File Type Mismatch", imageFileType, mediaItem2.getFileType());
assertEquals("Image height", imageHeight, mediaItem2.getHeight());
assertEquals("Image width", imageWidth, mediaItem2.getWidth());
mVideoEditor.removeMediaItem("m2" + i);
}
if (i % 3 == 2) {
final AudioTrack mediaItem3 = new AudioTrack(mVideoEditor, "m3" + i, AudioItemFileName3);
mVideoEditor.addAudioTrack(mediaItem3);
assertEquals("AudioType Mismatch", audioCodecType, mediaItem3.getAudioType());
assertEquals("Audio Sampling", audioSamplingFrequency, mediaItem3.getAudioSamplingFrequency());
assertEquals("Audio Channels", audioChannel, mediaItem3.getAudioChannels());
assertEquals("duration Mismatch", audioDuration, mediaItem3.getDuration());
mVideoEditor.removeAudioTrack("m3" + i);
}
if (i % 10 == 0) {
getAfterMemory_updateLog(loggingInfo, false, i);
}
}
getAfterMemory_updateLog(loggingInfo, false, i);
}
use of android.media.videoeditor.MediaImageItem 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());
}
use of android.media.videoeditor.MediaImageItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testMediaImageItemHeightWidth.
/**
* To Test the Media Image API : GetHeight and GetWidth
*/
@LargeTest
public void testMediaImageItemHeightWidth() throws Exception {
final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final MediaImageItem mediaImageItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", imageItemFileName, imageItemRenderingMode, 5000);
mVideoEditor.addMediaItem(mediaImageItem1);
assertEquals("Image Height = Image Scaled Height", mediaImageItem1.getScaledHeight(), mediaImageItem1.getHeight());
assertEquals("Image Width = Image Scaled Width", mediaImageItem1.getScaledWidth(), mediaImageItem1.getWidth());
}
Aggregations