use of android.media.videoeditor.OverlayFrame in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorStressTest method testStressAddRemoveOverlay.
/**
* To stress test overlay
*
* @throws Exception
*/
@LargeTest
public void testStressAddRemoveOverlay() throws Exception {
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final String VideoItemFileName1 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
final String ImageItemFileName2 = INPUT_FILE_PATH + "IMG_640x480.jpg";
final String OverlayFile3 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
final String OverlayFile4 = INPUT_FILE_PATH + "IMG_640x480_Overlay2.png";
final String[] loggingInfo = new String[1];
int i = 0;
final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, "m1", VideoItemFileName1, renderingMode);
mVideoEditor.addMediaItem(mediaItem1);
final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, "m2", ImageItemFileName2, 10000, renderingMode);
mVideoEditor.addMediaItem(mediaItem2);
writeTestCaseHeader("testStressAddRemoveOverlay");
getBeginMemory();
for (i = 0; i < 50; i++) {
if (i % 3 == 0) {
mediaItem1.setExtractBoundaries(0, 10000);
final Bitmap mBitmap = mVideoEditorHelper.getBitmap(OverlayFile3, 640, 480);
final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaItem1, "overlay" + i, mBitmap, 1000, 5000);
mediaItem1.addOverlay(overlayFrame);
mediaItem1.removeOverlay("overlay" + i);
}
if (i % 3 == 1) {
final Bitmap mBitmap = mVideoEditorHelper.getBitmap(OverlayFile4, 640, 480);
final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaItem2, "overlay" + i, mBitmap, 1000, 5000);
mediaItem2.addOverlay(overlayFrame);
mediaItem2.removeOverlay("overlay" + i);
}
if (i % 3 == 2) {
mediaItem1.setExtractBoundaries(0, 10000);
final Bitmap mBitmap = mVideoEditorHelper.getBitmap(OverlayFile4, 640, 480);
final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaItem1, "overlay" + i, mBitmap, 0, mediaItem1.getDuration());
mediaItem1.addOverlay(overlayFrame);
mediaItem1.removeOverlay("overlay" + i);
}
if (i % 10 == 0) {
getAfterMemory_updateLog(loggingInfo, false, i);
}
}
getAfterMemory_updateLog(loggingInfo, false, i);
}
use of android.media.videoeditor.OverlayFrame in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorStressTest method testStressLoadAndSave.
/**
* To stress test : load and save
*
* @throws Exception
*/
@LargeTest
public void testStressLoadAndSave() 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 VideoItemFileName2 = INPUT_FILE_PATH + "H264_BP_800x480_15fps_512kbps_1_17.mp4";
final String VideoItemFileName3 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp";
final String ImageItemFileName4 = INPUT_FILE_PATH + "IMG_640x480.jpg";
final String ImageItemFileName5 = INPUT_FILE_PATH + "IMG_176x144.jpg";
final String OverlayFile6 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
final String[] loggingInfo = new String[1];
int i = 0;
final String[] projectPath = new String[10];
writeTestCaseHeader("testStressLoadAndSave");
getBeginMemory();
for (i = 0; i < 10; i++) {
projectPath[i] = mVideoEditorHelper.createRandomFile(PROJECT_LOCATION);
final VideoEditor mVideoEditor1 = mVideoEditorHelper.createVideoEditor(projectPath[i]);
final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor1, "m1", VideoItemFileName1, renderingMode);
mVideoEditor1.addMediaItem(mediaItem1);
mediaItem1.setExtractBoundaries(0, 10000);
final MediaVideoItem mediaItem2 = new MediaVideoItem(mVideoEditor1, "m2", VideoItemFileName2, renderingMode);
mVideoEditor1.addMediaItem(mediaItem2);
mediaItem2.setExtractBoundaries(mediaItem2.getDuration() / 4, mediaItem2.getDuration() / 2);
final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor1, "m3", VideoItemFileName3, renderingMode);
mVideoEditor1.addMediaItem(mediaItem3);
mediaItem3.setExtractBoundaries(mediaItem3.getDuration() / 2, mediaItem3.getDuration());
final MediaImageItem mediaItem4 = new MediaImageItem(mVideoEditor1, "m4", ImageItemFileName4, 5000, renderingMode);
mVideoEditor1.addMediaItem(mediaItem4);
final MediaImageItem mediaItem5 = new MediaImageItem(mVideoEditor1, "m5", ImageItemFileName5, 5000, renderingMode);
mVideoEditor1.addMediaItem(mediaItem5);
final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(mediaItem3, "effect1", 10000, 2000, EffectColor.TYPE_COLOR, EffectColor.GREEN);
mediaItem3.addEffect(effectColor1);
final Bitmap mBitmap = mVideoEditorHelper.getBitmap(OverlayFile6, 640, 480);
final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaItem4, "overlay", mBitmap, 4000, 1000);
mediaItem4.addOverlay(overlayFrame);
final TransitionCrossfade tranCrossfade = new TransitionCrossfade("transCF", mediaItem1, mediaItem2, 5000, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor1.addTransition(tranCrossfade);
final EffectColor effectColor2 = mVideoEditorHelper.createEffectItem(mediaItem4, "effect2", 0, mediaItem4.getDuration(), EffectColor.TYPE_COLOR, EffectColor.PINK);
mediaItem4.addEffect(effectColor2);
mVideoEditor1.generatePreview(new MediaProcessingProgressListener() {
public void onProgress(Object item, int action, int progress) {
}
});
mVideoEditor1.save();
mVideoEditor1.release();
getAfterMemory_updateLog(loggingInfo, false, i);
}
getAfterMemory_updateLog(loggingInfo, false, i);
/** Remove items and check for memory leak if any */
for (i = 0; i < 10; i++) {
final VideoEditor mVideoEditor1b = VideoEditorFactory.load(projectPath[i], true);
List<MediaItem> mediaList = mVideoEditor1b.getAllMediaItems();
assertEquals("Media Item List Size", 5, mediaList.size());
mediaList.get(3).removeEffect("effect1");
mediaList.get(3).removeEffect("effect2");
mediaList.get(2).removeOverlay("overlay");
mVideoEditor1b.removeTransition("transCF");
mVideoEditor1b.removeMediaItem("m5");
mVideoEditor1b.removeMediaItem("m4");
mVideoEditor1b.removeMediaItem("m3");
mVideoEditor1b.removeMediaItem("m2");
mVideoEditor1b.removeMediaItem("m1");
mVideoEditor1b.release();
getAfterMemory_updateLog(loggingInfo, true, i);
}
getAfterMemory_updateLog(loggingInfo, true, i);
}
use of android.media.videoeditor.OverlayFrame in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorStressTest method testStressOverlayTransKenBurn.
/**
* To stress test Media Item,Overlays,Transitions and Ken Burn
*
* @throws Exception
*/
@LargeTest
public void testStressOverlayTransKenBurn() throws Exception {
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final String VideoItemFileName1 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
final String ImageItemFileName2 = INPUT_FILE_PATH + "IMG_640x480.jpg";
final String OverlayFile3 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
final String audioFilename4 = INPUT_FILE_PATH + "AACLC_44.1kHz_256kbps_s_1_17.mp4";
int i = 0;
final String[] loggingInfo = new String[1];
writeTestCaseHeader("testStressOverlayTransKenBurn");
getBeginMemory();
for (i = 0; i < 10; i++) {
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 EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(mediaItem1, "effect1" + i, (mediaItem1.getDuration() - 4000), 4000, EffectColor.TYPE_SEPIA, 0);
mediaItem1.addEffect(effectColor1);
final TransitionCrossfade tranCrossfade = new TransitionCrossfade("transCF" + i, mediaItem1, mediaItem2, 4000, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor.addTransition(tranCrossfade);
final Bitmap mBitmap = mVideoEditorHelper.getBitmap(OverlayFile3, 640, 480);
final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaItem1, "overlay" + i, mBitmap, 1000, 5000);
mediaItem1.addOverlay(overlayFrame);
final Rect startRect = new Rect((mediaItem2.getHeight() / 3), (mediaItem2.getWidth() / 3), (mediaItem2.getHeight() / 2), (mediaItem2.getWidth() / 2));
final Rect endRect = new Rect(0, 0, mediaItem2.getWidth(), mediaItem2.getHeight());
final EffectKenBurns kbEffectOnMediaItem = new EffectKenBurns(mediaItem2, "KBOnM2" + i, startRect, endRect, 500, (mediaItem2.getDuration() - 500));
mediaItem2.addEffect(kbEffectOnMediaItem);
if (i == 5) {
final AudioTrack audioTrack1 = new AudioTrack(mVideoEditor, "Audio Track1", audioFilename4);
mVideoEditor.addAudioTrack(audioTrack1);
}
getAfterMemory_updateLog(loggingInfo, false, i);
}
getAfterMemory_updateLog(loggingInfo, false, i);
/** Remove items and check for memory leak if any */
for (i = 0; i < 10; i++) {
MediaImageItem m2 = (MediaImageItem) mVideoEditor.getMediaItem("m2" + i);
MediaVideoItem m1 = (MediaVideoItem) mVideoEditor.getMediaItem("m1" + i);
m2.removeEffect("KBOnM2" + i);
m1.removeOverlay("overlay" + i);
mVideoEditor.removeTransition("transCF" + i);
m1.removeEffect("effect1" + i);
mVideoEditor.removeMediaItem("m2" + i);
mVideoEditor.removeMediaItem("m1" + i);
if (i == 5) {
mVideoEditor.removeAudioTrack("Audio Track1");
}
getAfterMemory_updateLog(loggingInfo, true, i);
}
getAfterMemory_updateLog(loggingInfo, true, i);
}
use of android.media.videoeditor.OverlayFrame in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPerformance method testPerformanceExport.
/**
* To test performance of Export
*
* @throws Exception
*/
@LargeTest
public void testPerformanceExport() throws Exception {
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final int outHeight = MediaProperties.HEIGHT_480;
final int outBitrate = MediaProperties.BITRATE_256K;
final int outVcodec = MediaProperties.VCODEC_H264;
final String[] loggingInfo = new String[1];
final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
final String videoItemFileName1 = INPUT_FILE_PATH + "H264_BP_1080x720_30fps_12Mbps_AACLC_44.1khz_64kbps_s_1_17.mp4";
final String imageItemFileName1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String videoItemFileName2 = INPUT_FILE_PATH + "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_32kbps_m_1_17.3gp";
final String imageItemFileName2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
final String videoItemFileName3 = INPUT_FILE_PATH + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_161kbps_s_0_26.mp4";
final String overlayFile = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
final String audioTrackFilename = INPUT_FILE_PATH + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
final String maskFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, "m1", videoItemFileName1, renderingMode);
mediaItem1.setExtractBoundaries(0, 20000);
mVideoEditor.addMediaItem(mediaItem1);
final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, "m2", imageItemFileName1, 10000, renderingMode);
mVideoEditor.addMediaItem(mediaItem2);
final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor, "m3", videoItemFileName2, renderingMode);
mediaItem3.setExtractBoundaries(0, 20000);
mVideoEditor.addMediaItem(mediaItem3);
final MediaImageItem mediaItem4 = new MediaImageItem(mVideoEditor, "m4", imageItemFileName2, 10000, renderingMode);
mVideoEditor.addMediaItem(mediaItem4);
final MediaVideoItem mediaItem5 = new MediaVideoItem(mVideoEditor, "m5", videoItemFileName3, renderingMode);
mediaItem5.setExtractBoundaries(0, 20000);
mVideoEditor.addMediaItem(mediaItem5);
/**
* 7.Add TransitionAlpha, Apply this Transition as Begin for Media Item 1
* with duration = 2 sec behavior = BEHAVIOR_LINEAR, mask file name =
* TransitionSpiral_QVGA.jpg , blending percent = 50%, invert = true;
* */
final TransitionAlpha transition1 = mVideoEditorHelper.createTAlpha("transition1", null, mediaItem1, 2000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, true);
mVideoEditor.addTransition(transition1);
/**
* 8.Add Transition Sliding between MediaItem 2 and 3 ,
* Sliding Direction = DIRECTION_RIGHT_OUT_LEFT_IN,
* behavior = BEHAVIOR_MIDDLE_FAST and duration = 4sec
* */
final TransitionSliding transition2And3 = mVideoEditorHelper.createTSliding("transition2", mediaItem2, mediaItem3, 4000, Transition.BEHAVIOR_MIDDLE_FAST, TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN);
mVideoEditor.addTransition(transition2And3);
/**
* 9.Add Transition Crossfade between Media Item 3 and 4,
* behavior = BEHAVIOR_MIDDLE_SLOW, duration = 3.5 sec
* */
final TransitionCrossfade transition3And4 = mVideoEditorHelper.createTCrossFade("transition3", mediaItem3, mediaItem4, 3500, Transition.BEHAVIOR_MIDDLE_SLOW);
mVideoEditor.addTransition(transition3And4);
/**
* 10.Add Transition Fadeblack between Media Item 4 and 5,
* behavior = BEHAVIOR_SPEED_DOWN, duration = 3.5 sec
* */
final TransitionFadeBlack transition4And5 = mVideoEditorHelper.createTFadeBlack("transition4", mediaItem4, mediaItem5, 3500, Transition.BEHAVIOR_SPEED_DOWN);
mVideoEditor.addTransition(transition4And5);
/**
* 11.Add Effect 1 type="TYPE_SEPIA" to the MediaItem 1,
* start time=1sec and duration =4secs
* */
final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(mediaItem1, "effect1", 1000, 4000, EffectColor.TYPE_SEPIA, 0);
mediaItem1.addEffect(effectColor1);
/**
* 12.Add Overlay 1 to the MediaItem 3: Frame Overlay with start time = 1 sec
* duration = 4 sec with item = IMG_640x480_Overlay1.png
* */
final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile, 640, 480);
final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaItem3, "overlay", mBitmap, 1000, 4000);
mediaItem3.addOverlay(overlayFrame);
/**
* 13.Add Effect 2 type="TYPE_NEGATIVE" to the MediaItem 2,
* start time=8sec and duration =2secs
* */
final EffectColor effectColor2 = mVideoEditorHelper.createEffectItem(mediaItem2, "effect2", 8000, 2000, EffectColor.TYPE_NEGATIVE, 0);
mediaItem2.addEffect(effectColor2);
/**
* 14.Add Effect 3 type="TYPE_COLOR" to the MediaItem 3, color param = "PINK",
* start time=5 sec and duration =3secs
* */
final EffectColor effectColor3 = mVideoEditorHelper.createEffectItem(mediaItem3, "effect3", 5000, 3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
mediaItem3.addEffect(effectColor3);
/**
* 15.Add Effect 4 type="TYPE_FIFTIES" to the MediaItem 4,
* start time=2 sec and duration =1secs
* */
final EffectColor effectColor4 = mVideoEditorHelper.createEffectItem(mediaItem4, "effect4", 2000, 1000, EffectColor.TYPE_FIFTIES, 0);
mediaItem4.addEffect(effectColor4);
/**
* 16.Add KenBurnsEffect for MediaItem 4 with
* duration = 3 sec and startTime = 4 sec
* StartRect
* left = org_height/3 ; top = org_width/3
* bottom = org_width/2 ; right = org_height/2
* EndRect
* left = 0 ; top = 0
* bottom = org_height; right = org_width
* */
final Rect startRect = new Rect((mediaItem4.getHeight() / 3), (mediaItem4.getWidth() / 3), (mediaItem4.getHeight() / 2), (mediaItem4.getWidth() / 2));
final Rect endRect = new Rect(0, 0, mediaItem4.getWidth(), mediaItem4.getHeight());
final EffectKenBurns kbEffectOnMediaItem = new EffectKenBurns(mediaItem4, "KBOnM2", startRect, endRect, 4000, 3000);
mediaItem4.addEffect(kbEffectOnMediaItem);
/** 17.Add Audio Track,Set extract boundaries o to 10 sec.
* */
final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "audioTrack", audioTrackFilename);
mVideoEditor.addAudioTrack(audioTrack);
/** 18.Enable Looping for Audio Track.
* */
audioTrack.enableLoop();
int timeTaken = 0;
final long beginTime = SystemClock.uptimeMillis();
try {
mVideoEditor.export(outFilename, outHeight, outBitrate, new ExportProgressListener() {
public void onProgress(VideoEditor ve, String outFileName, int progress) {
}
});
} catch (Exception e) {
assertTrue("Error in Export" + e.toString(), false);
}
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
timeTaken = calculateTimeTaken(beginTime, 1);
loggingInfo[0] = "Time taken to do ONE export of storyboard duration " + mVideoEditor.getDuration() + " is :" + timeTaken;
writeTimingInfo("testPerformanceExport (in mSec)", loggingInfo);
mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
}
use of android.media.videoeditor.OverlayFrame in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPreviewTest method testPreviewWithOverlay.
/**
* To test Preview : Preview of current Overlay applied
*/
@LargeTest
public void testPreviewWithOverlay() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp";
final String overlayFilename1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
final String overlayFilename2 = INPUT_FILE_PATH + "IMG_640x480_Overlay2.png";
final int previewFrom = 5000;
final int previewTo = 10000;
final boolean previewLoop = false;
final int previewCallbackFrameCount = 1;
final int setAspectRatio = MediaProperties.ASPECT_RATIO_4_3;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final Semaphore blockTillPreviewCompletes = new Semaphore(1);
previewStart = false;
previewStop = false;
boolean flagForException = false;
final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName, renderingMode);
mVideoEditor.addMediaItem(mediaVideoItem);
mediaVideoItem.setExtractBoundaries(0, 10000);
final Bitmap mBitmap1 = mVideoEditorHelper.getBitmap(overlayFilename1, 640, 480);
final OverlayFrame overlayOnMvi1 = mVideoEditorHelper.createOverlay(mediaVideoItem, "OverlayOnMvi1", mBitmap1, 0, 5000);
mediaVideoItem.addOverlay(overlayOnMvi1);
final Bitmap mBitmap2 = mVideoEditorHelper.getBitmap(overlayFilename2, 640, 480);
final OverlayFrame overlayOnMvi2 = mVideoEditorHelper.createOverlay(mediaVideoItem, "OverlayOnMvi2", mBitmap2, 5000, 9000);
mediaVideoItem.addOverlay(overlayOnMvi2);
List<Overlay> overlayList = mediaVideoItem.getAllOverlays();
assertEquals("Overlay Size", 2, overlayList.size());
assertEquals("Overlay 1", overlayOnMvi1, overlayList.get(0));
assertEquals("Overlay 2", overlayOnMvi2, overlayList.get(1));
mVideoEditor.setAspectRatio(setAspectRatio);
validatePreviewProgress(0, /* previewFrom */
-1, previewLoop, mVideoEditor.getDuration());
}
Aggregations