use of android.media.videoeditor.EffectKenBurns in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorExportTest method testExportEffectKenBurn.
/**
* To test export : with Image with KenBurnEffect
*/
@LargeTest
public void testExportEffectKenBurn() throws Exception {
final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", imageItemFileName, 5000, imageItemRenderingMode);
mVideoEditor.addMediaItem(mediaImageItem);
final Rect startRect = new Rect((mediaImageItem.getHeight() / 3), (mediaImageItem.getWidth() / 3), (mediaImageItem.getHeight() / 2), (mediaImageItem.getWidth() / 2));
final Rect endRect = new Rect(0, 0, mediaImageItem.getWidth(), mediaImageItem.getHeight());
final EffectKenBurns kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2", startRect, endRect, 500, 3000);
assertNotNull("EffectKenBurns", kbEffectOnMediaItem);
mediaImageItem.addEffect(kbEffectOnMediaItem);
assertEquals("KenBurn Start Rect", startRect, kbEffectOnMediaItem.getStartRect());
assertEquals("KenBurn End Rect", endRect, kbEffectOnMediaItem.getEndRect());
mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
public void onProgress(Object item, int action, int progress) {
}
});
try {
final int[] progressUpdate = new int[100];
mVideoEditor.export(outFilename, 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 (Exception e) {
assertTrue("Error in Export" + e.toString(), false);
}
mVideoEditorHelper.validateExport(mVideoEditor, outFilename, MediaProperties.HEIGHT_720, 0, mediaImageItem.getDuration(), MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
use of android.media.videoeditor.EffectKenBurns in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorStressTest method testStressAddRemoveEffects.
/**
* To stress test Effects
*
* @throws Exception
*/
@LargeTest
public void testStressAddRemoveEffects() throws Exception {
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final String VideoItemFileName1 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp";
final String ImageItemFileName2 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String[] loggingInfo = new String[1];
final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, "m1", VideoItemFileName1, renderingMode);
mVideoEditor.addMediaItem(mediaItem1);
final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, "m2", ImageItemFileName2, 10000, renderingMode);
int i = 0;
mVideoEditor.addMediaItem(mediaItem2);
writeTestCaseHeader("testStressAddRemoveEffects");
getBeginMemory();
for (i = 0; i < 50; i++) {
if (i % 5 == 0) {
mediaItem1.setExtractBoundaries(10000, 30000);
final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(mediaItem1, "effect1" + i, 10000, (mediaItem1.getTimelineDuration() - 1000), EffectColor.TYPE_COLOR, EffectColor.GREEN);
mediaItem1.addEffect(effectColor1);
}
if (i % 5 == 1) {
mediaItem2.setDuration(20000);
final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(mediaItem2, "effect1" + i, 0, 4000, EffectColor.TYPE_GRADIENT, EffectColor.GRAY);
mediaItem2.addEffect(effectColor1);
}
if (i % 5 == 2) {
mediaItem1.setExtractBoundaries(10000, 30000);
final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(mediaItem1, "effect1" + i, (mediaItem1.getTimelineDuration() - 4000), 4000, EffectColor.TYPE_SEPIA, 0);
mediaItem1.addEffect(effectColor1);
}
if (i % 5 == 3) {
mediaItem2.setDuration(20000);
final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(mediaItem2, "effect1" + i, 10000, 4000, EffectColor.TYPE_NEGATIVE, 0);
mediaItem2.addEffect(effectColor1);
}
if (i % 5 == 4) {
mediaItem2.setDuration(20000);
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 % 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 % 5 == 0) {
mediaItem1.removeEffect("effect1" + i);
}
if (i % 5 == 1) {
mediaItem1.removeEffect("effect1" + i);
}
if (i % 5 == 2) {
mediaItem1.removeEffect("effect1" + i);
}
if (i % 5 == 3) {
mediaItem1.removeEffect("effect1" + i);
}
if (i % 5 == 4) {
mediaItem1.removeEffect("KBOnM2" + i);
}
if (i % 10 == 0) {
getAfterMemory_updateLog(loggingInfo, true, i);
}
}
getAfterMemory_updateLog(loggingInfo, true, i);
}
use of android.media.videoeditor.EffectKenBurns in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testEffectKenBurn.
private void testEffectKenBurn(final String imageItemFileName, final String MediaId) throws Exception {
final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, MediaId, imageItemFileName, 5000, imageItemRenderingMode);
mVideoEditor.addMediaItem(mediaImageItem);
final Rect startRect = new Rect((mediaImageItem.getHeight() / 3), (mediaImageItem.getWidth() / 3), (mediaImageItem.getHeight() / 2), (mediaImageItem.getWidth() / 2));
final Rect endRect = new Rect(0, 0, mediaImageItem.getWidth(), mediaImageItem.getHeight());
final EffectKenBurns kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2", startRect, endRect, 500, 3000);
assertNotNull("EffectKenBurns: " + imageItemFileName, kbEffectOnMediaItem);
mediaImageItem.addEffect(kbEffectOnMediaItem);
assertEquals("KenBurn Start Rect: " + imageItemFileName, startRect, kbEffectOnMediaItem.getStartRect());
assertEquals("KenBurn End Rect: " + imageItemFileName, endRect, kbEffectOnMediaItem.getEndRect());
}
Aggregations