use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPerformance method testPerformanceGeneratePreviewWithTransitions.
/**
* To test the performance of generatePreview : with Transitions
*
* @throws Exception
*/
@LargeTest
public void testPerformanceGeneratePreviewWithTransitions() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH + "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
long averageTime = 0;
final String[] loggingInfo = new String[1];
final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor, "mediaItem1", videoItemFileName, renderingMode);
mediaVideoItem.setExtractBoundaries(0, 10000);
mVideoEditor.addMediaItem(mediaVideoItem);
final MediaImageItem mediaImageItem = new MediaImageItem(mVideoEditor, "mediaItem2", imageItemFileName, 10000, renderingMode);
mVideoEditor.addMediaItem(mediaImageItem);
final TransitionCrossfade transitionCrossFade = new TransitionCrossfade("transitionCrossFade", mediaVideoItem, mediaImageItem, 5000, transitionBehavior);
mVideoEditor.addTransition(transitionCrossFade);
for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
final long duration1 = SystemClock.uptimeMillis();
mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
public void onProgress(Object item, int action, int progress) {
}
});
final long duration2 = SystemClock.uptimeMillis();
mVideoEditor.removeTransition(transitionCrossFade.getId());
mVideoEditor.addTransition(transitionCrossFade);
averageTime += (duration2 - duration1);
}
final long durationToAddObjects = averageTime;
final float timeTaken = (float) durationToAddObjects * 1.0f / (float) NUM_OF_ITERATIONS;
loggingInfo[0] = "Time taken to Generate Preview with transition :" + timeTaken;
writeTimingInfo("testPerformanceGeneratePreviewWithTransitions:", loggingInfo);
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPerformance method testThumbnailH264NonIFrame.
/**
*To test ThumbnailList for H264
*/
@LargeTest
public void testThumbnailH264NonIFrame() throws Exception {
final String videoItemFilename = INPUT_FILE_PATH + "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
final int outWidth = 1080;
final int outHeight = 720;
final int atTime = 2400;
long durationToAddObjects = 0;
int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final String[] loggingInfo = new String[1];
final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor, "m1", videoItemFilename, renderingMode);
assertNotNull("MediaVideoItem", mediaVideoItem);
for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
final long duration1 = SystemClock.uptimeMillis();
mediaVideoItem.getThumbnail(outWidth, outHeight, atTime + i);
final long duration2 = SystemClock.uptimeMillis();
durationToAddObjects += (duration2 - duration1);
}
final float timeTaken = (float) durationToAddObjects * 1.0f / (float) NUM_OF_ITERATIONS;
loggingInfo[0] = "Time taken for Thumbnail generation :" + timeTaken;
writeTimingInfo("testThumbnailH264NonIFrame", loggingInfo);
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPerformance method testPerformanceAddRemoveTransition.
/**
* To test the performance of adding and removing the transition
*
* @throws Exception
*/
@LargeTest
public void testPerformanceAddRemoveTransition() throws Exception {
final String videoItemFileName1 = INPUT_FILE_PATH + "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
final int videoItemStartTime1 = 0;
final int videoItemEndTime1 = 20000;
final String videoItemFileName2 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
final int videoItemStartTime2 = 0;
final int videoItemEndTime2 = 20000;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final int transitionDuration = 5000;
final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
final String[] loggingInfo = new String[3];
int timeTaken = 0;
final MediaVideoItem[] mediaVideoItem = new MediaVideoItem[(NUM_OF_ITERATIONS * 10) + 1];
for (int i = 0; i < (NUM_OF_ITERATIONS * 10); i += 2) {
try {
mediaVideoItem[i] = new MediaVideoItem(mVideoEditor, "m" + i, videoItemFileName1, renderingMode);
mediaVideoItem[i + 1] = new MediaVideoItem(mVideoEditor, "m" + (i + 1), videoItemFileName2, renderingMode);
mediaVideoItem[i].setExtractBoundaries(videoItemStartTime1, videoItemEndTime1);
mediaVideoItem[i + 1].setExtractBoundaries(videoItemStartTime2, videoItemEndTime2);
} catch (Exception e1) {
assertTrue("Can not create Video Object Item with file name = " + e1.toString(), false);
}
mVideoEditor.addMediaItem(mediaVideoItem[i]);
mVideoEditor.addMediaItem(mediaVideoItem[i + 1]);
}
mediaVideoItem[(NUM_OF_ITERATIONS * 10)] = new MediaVideoItem(mVideoEditor, "m" + (NUM_OF_ITERATIONS * 10), videoItemFileName1, renderingMode);
mediaVideoItem[(NUM_OF_ITERATIONS * 10)].setExtractBoundaries(videoItemStartTime1, videoItemEndTime1);
mVideoEditor.addMediaItem(mediaVideoItem[(NUM_OF_ITERATIONS * 10)]);
final TransitionCrossfade[] tranCrossfade = new TransitionCrossfade[(NUM_OF_ITERATIONS * 10)];
long beginTime = SystemClock.uptimeMillis();
for (int i = 0; i < (NUM_OF_ITERATIONS * 10); i++) {
tranCrossfade[i] = new TransitionCrossfade("transition" + i, mediaVideoItem[i], mediaVideoItem[i + 1], transitionDuration, transitionBehavior);
}
timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10));
loggingInfo[0] = "Time taken to Create CrossFade Transition :" + timeTaken;
beginTime = SystemClock.uptimeMillis();
for (int i = 0; i < (NUM_OF_ITERATIONS * 10); i++) {
mVideoEditor.addTransition(tranCrossfade[i]);
}
timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10));
loggingInfo[1] = "\n\tTime taken to add CrossFade Transition :" + timeTaken;
beginTime = SystemClock.uptimeMillis();
for (int i = 0; i < (NUM_OF_ITERATIONS * 10); i++) {
assertEquals("Removing Transitions", tranCrossfade[i], mVideoEditor.removeTransition(tranCrossfade[i].getId()));
}
timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10));
loggingInfo[2] = "\n\tTime taken to remove CrossFade Transition :" + timeTaken;
writeTimingInfo("testPerformanceAddRemoveTransition (in mSec)", loggingInfo);
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPerformance method testPerformanceVideoItemProperties.
/**
* To test the performance of get properties of a Video media item
*
* @throws Exception
*/
@LargeTest
public void testPerformanceVideoItemProperties() throws Exception {
final String videoItemFileName1 = INPUT_FILE_PATH + "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
final int videoItemStartTime1 = 0;
final int videoItemEndTime1 = 10100;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
final int fileType = MediaProperties.FILE_MP4;
final int videoCodecType = MediaProperties.VCODEC_H264;
final int duration = 77366;
final int videoBitrate = 3169971;
final int fps = 30;
final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
final int videoLevel = MediaProperties.H264Level.H264Level13;
final int width = 1080;
final int height = MediaProperties.HEIGHT_720;
int timeTaken = 0;
final String[] loggingInfo = new String[1];
final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor, "m0", videoItemFileName1, renderingMode);
mediaVideoItem.setExtractBoundaries(videoItemStartTime1, videoItemEndTime1);
long beginTime = SystemClock.uptimeMillis();
for (int i = 0; i < (NUM_OF_ITERATIONS * 10); i++) {
try {
assertEquals("Aspect Ratio Mismatch", aspectRatio, mediaVideoItem.getAspectRatio());
assertEquals("File Type Mismatch", fileType, mediaVideoItem.getFileType());
assertEquals("VideoCodec Mismatch", videoCodecType, mediaVideoItem.getVideoType());
assertEquals("duration Mismatch", duration, mediaVideoItem.getDuration());
assertEquals("Video Profile ", videoProfile, mediaVideoItem.getVideoProfile());
assertEquals("Video Level ", videoLevel, mediaVideoItem.getVideoLevel());
assertEquals("Video height ", height, mediaVideoItem.getHeight());
assertEquals("Video width ", width, mediaVideoItem.getWidth());
} catch (Exception e1) {
assertTrue("Can not create Video Item with file name = " + e1.toString(), false);
}
}
timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10));
loggingInfo[0] = "Time taken to get Media Properties :" + timeTaken;
writeTimingInfo("testPerformanceVideoItemProperties:", loggingInfo);
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorStressTest method testStressAddRemoveTransition.
/**
* To stress test transition
*
* @throws Exception
*/
@LargeTest
public void testStressAddRemoveTransition() throws Exception {
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final String VideoItemFileName1 = INPUT_FILE_PATH + "H264_BP_800x480_15fps_512kbps_1_17.mp4";
final String ImageItemFileName2 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String VideoItemFileName3 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
final String maskFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
final String[] loggingInfo = new String[1];
int i = 0;
writeTestCaseHeader("testStressAddRemoveTransition");
getBeginMemory();
for (i = 0; i < 50; i++) {
if (i % 4 == 0) {
final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, "m1" + i, VideoItemFileName1, renderingMode);
mVideoEditor.addMediaItem(mediaItem1);
mediaItem1.setExtractBoundaries(0, 10000);
final TransitionCrossfade tranCrossfade = new TransitionCrossfade("transCF" + i, null, mediaItem1, 5000, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor.addTransition(tranCrossfade);
}
if (i % 4 == 1) {
final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, "m1" + i, VideoItemFileName1, renderingMode);
mVideoEditor.addMediaItem(mediaItem1);
mediaItem1.setExtractBoundaries(0, 10000);
final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, "m2" + i, ImageItemFileName2, 10000, renderingMode);
mVideoEditor.addMediaItem(mediaItem2);
final TransitionAlpha transitionAlpha = mVideoEditorHelper.createTAlpha("transAlpha" + i, mediaItem1, mediaItem2, 5000, Transition.BEHAVIOR_SPEED_UP, maskFilename, 10, false);
transitionAlpha.setDuration(4000);
mVideoEditor.addTransition(transitionAlpha);
}
if (i % 4 == 2) {
final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, "m2" + i, ImageItemFileName2, 10000, renderingMode);
mVideoEditor.addMediaItem(mediaItem2);
final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor, "m3" + i, VideoItemFileName3, renderingMode);
mVideoEditor.addMediaItem(mediaItem3);
mediaItem3.setExtractBoundaries(0, 10000);
final TransitionAlpha transitionAlpha = mVideoEditorHelper.createTAlpha("transAlpha" + i, mediaItem2, mediaItem3, 5000, Transition.BEHAVIOR_SPEED_UP, maskFilename, 10, false);
transitionAlpha.setDuration(4000);
mVideoEditor.addTransition(transitionAlpha);
mediaItem3.setExtractBoundaries(0, 6000);
final TransitionSliding transition2And3 = mVideoEditorHelper.createTSliding("transSlide" + i, mediaItem2, mediaItem3, 3000, Transition.BEHAVIOR_MIDDLE_FAST, TransitionSliding.DIRECTION_LEFT_OUT_RIGHT_IN);
mVideoEditor.addTransition(transition2And3);
}
if (i % 4 == 3) {
final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor, "m3" + i, VideoItemFileName3, renderingMode);
mVideoEditor.addMediaItem(mediaItem3);
mediaItem3.setExtractBoundaries(0, 5000);
final TransitionFadeBlack transition3 = mVideoEditorHelper.createTFadeBlack("transFB" + i, mediaItem3, null, 2500, Transition.BEHAVIOR_SPEED_UP);
transition3.setDuration(500);
mVideoEditor.addTransition(transition3);
}
if (i % 10 == 0) {
getAfterMemory_updateLog(loggingInfo, false, i);
}
}
getAfterMemory_updateLog(loggingInfo, false, i);
/** Remove items and check for memory leak if any */
for (i = 0; i < 50; i++) {
if (i % 4 == 0) {
mVideoEditor.removeTransition("transCF" + i);
mVideoEditor.removeMediaItem("m1" + i);
}
if (i % 4 == 1) {
mVideoEditor.removeTransition("transAlpha" + i);
mVideoEditor.removeMediaItem("m1" + i);
mVideoEditor.removeMediaItem("m2" + i);
}
if (i % 4 == 2) {
mVideoEditor.removeTransition("transSlide" + i);
mVideoEditor.removeMediaItem("m2" + i);
mVideoEditor.removeMediaItem("m3" + i);
}
if (i % 4 == 3) {
mVideoEditor.removeMediaItem("m3" + i);
}
if (i % 10 == 0) {
getAfterMemory_updateLog(loggingInfo, true, i);
}
}
getAfterMemory_updateLog(loggingInfo, true, i);
}
Aggregations