use of android.media.videoeditor.MediaImageItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorStressTest method testStressStoryBoard.
/**
* To Test Stress : Story Board creation with out preview or export
*
* @throws Exception
*/
@LargeTest
public void testStressStoryBoard() throws Exception {
final String videoItemFileName1 = INPUT_FILE_PATH + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_161kbps_s_0_26.mp4";
final String videoItemFileName2 = INPUT_FILE_PATH + "MPEG4_SP_854x480_15fps_256kbps_AACLC_16khz_48kbps_s_0_26.mp4";
final String videoItemFileName3 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
final String imageItemFileName4 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String imageItemFileName5 = INPUT_FILE_PATH + "IMG_176x144.jpg";
final String audioFilename6 = INPUT_FILE_PATH + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
final String audioFilename7 = INPUT_FILE_PATH + "AACLC_44.1kHz_256kbps_s_1_17.mp4";
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final int audioVolume = 50;
final String[] loggingInfo = new String[1];
int i = 1;
writeTestCaseHeader("testStressStoryBoard");
getBeginMemory();
final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, "m1", videoItemFileName1, renderingMode);
mediaItem1.setExtractBoundaries(0, 10000);
mVideoEditor.addMediaItem(mediaItem1);
final MediaVideoItem mediaItem2 = new MediaVideoItem(mVideoEditor, "m2", videoItemFileName2, renderingMode);
mediaItem2.setExtractBoundaries(mediaItem2.getDuration() / 4, mediaItem2.getDuration() / 2);
mVideoEditor.addMediaItem(mediaItem2);
final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor, "m3", videoItemFileName3, renderingMode);
mediaItem3.setExtractBoundaries(mediaItem3.getDuration() / 2, mediaItem3.getDuration());
mVideoEditor.addMediaItem(mediaItem3);
final MediaImageItem mediaItem4 = new MediaImageItem(mVideoEditor, "m4", imageItemFileName4, 5000, renderingMode);
mVideoEditor.addMediaItem(mediaItem4);
final MediaImageItem mediaItem5 = new MediaImageItem(mVideoEditor, "m5", imageItemFileName5, 5000, renderingMode);
mVideoEditor.addMediaItem(mediaItem5);
final TransitionCrossfade tranCrossfade = new TransitionCrossfade("transCF", mediaItem2, mediaItem3, 2500, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor.addTransition(tranCrossfade);
final TransitionCrossfade tranCrossfade1 = new TransitionCrossfade("transCF1", mediaItem3, mediaItem4, 2500, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor.addTransition(tranCrossfade1);
final AudioTrack audioTrack1 = new AudioTrack(mVideoEditor, "Audio Track1", audioFilename6);
mVideoEditor.addAudioTrack(audioTrack1);
mVideoEditor.removeAudioTrack("Audio Track1");
final AudioTrack audioTrack2 = new AudioTrack(mVideoEditor, "Audio Track2", audioFilename7);
mVideoEditor.addAudioTrack(audioTrack2);
audioTrack2.enableLoop();
getAfterMemory_updateLog(loggingInfo, false, i);
/** Remove items and check for memory leak if any */
getBeginMemory();
mVideoEditor.removeAudioTrack("Audio Track2");
mVideoEditor.removeTransition("transCF");
mVideoEditor.removeTransition("transCF1");
mVideoEditor.removeMediaItem("m5");
mVideoEditor.removeMediaItem("m4");
mVideoEditor.removeMediaItem("m3");
mVideoEditor.removeMediaItem("m2");
mVideoEditor.removeMediaItem("m1");
getAfterMemory_updateLog(loggingInfo, true, i);
}
use of android.media.videoeditor.MediaImageItem 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.MediaImageItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorStressTest method testStressAddRemoveImageItem.
/**
* To stress test MediaItem(Image Item) adding functionality
*
* @throws Exception
*/
@LargeTest
public void testStressAddRemoveImageItem() throws Exception {
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final String ImageItemFileName1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String ImageItemFileName2 = INPUT_FILE_PATH + "IMG_640x480.jpg";
final String ImageItemFileName3 = INPUT_FILE_PATH + "IMG_320x240.jpg";
final String ImageItemFileName4 = INPUT_FILE_PATH + "IMG_176x144.jpg";
final String[] loggingInfo = new String[1];
int i = 0;
writeTestCaseHeader("testStressAddRemoveImageItem");
getBeginMemory();
for (i = 0; i < 50; i++) {
if (i % 4 == 0) {
final MediaImageItem mediaItem1 = new MediaImageItem(mVideoEditor, "m1" + i, ImageItemFileName1, 5000, renderingMode);
mVideoEditor.addMediaItem(mediaItem1);
}
if (i % 4 == 1) {
final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, "m2" + i, ImageItemFileName2, 10000, renderingMode);
mVideoEditor.addMediaItem(mediaItem2);
}
if (i % 4 == 2) {
final MediaImageItem mediaItem3 = new MediaImageItem(mVideoEditor, "m3" + i, ImageItemFileName3, 15000, renderingMode);
mVideoEditor.addMediaItem(mediaItem3);
}
if (i % 4 == 3) {
final MediaImageItem mediaItem4 = new MediaImageItem(mVideoEditor, "m4" + i, ImageItemFileName4, 20000, renderingMode);
mVideoEditor.addMediaItem(mediaItem4);
}
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.removeMediaItem("m1" + i);
}
if (i % 4 == 1) {
mVideoEditor.removeMediaItem("m2" + i);
}
if (i % 4 == 2) {
mVideoEditor.removeMediaItem("m3" + i);
}
if (i % 4 == 3) {
mVideoEditor.removeMediaItem("m4" + i);
}
if (i % 10 == 0) {
getAfterMemory_updateLog(loggingInfo, true, i);
}
}
getAfterMemory_updateLog(loggingInfo, true, i);
}
use of android.media.videoeditor.MediaImageItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testAudioTrackWaveFormData.
/**
* To Test the Audio Track API:Extract waveform data
*/
@LargeTest
public void testAudioTrackWaveFormData() throws Exception {
/** Image item is added as dummy as Audio track cannot be added without
* a media item in the story board
*/
final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", imageItemFileName, 5000, imageItemRenderingMode);
mVideoEditor.addMediaItem(mediaImageItem);
final String audioFileName = INPUT_FILE_PATH + "AACLC_48KHz_256Kbps_s_1_17.3gp";
final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "audioTrack", audioFileName);
mVideoEditor.addAudioTrack(audioTrack);
assertNull("WaveForm data", audioTrack.getWaveformData());
final int[] progressUpdate = new int[105];
mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
int i = 0;
public void onProgress(Object item, int action, int progress) {
progressUpdate[i++] = progress;
}
});
final int[] progressWaveform = new int[105];
audioTrack.extractAudioWaveform(new ExtractAudioWaveformProgressListener() {
int i = 0;
public void onProgress(int progress) {
Log.i("AudioWaveformData", "progress=" + progress);
progressWaveform[i++] = progress;
}
});
assertTrue("Progress of WaveForm data", mVideoEditorHelper.checkProgressCBValues(progressWaveform));
assertNotNull("WaveForm data", audioTrack.getWaveformData());
assertTrue("WaveForm Frame Duration", (audioTrack.getWaveformData().getFrameDuration() > 0 ? true : false));
assertTrue("WaveForm Frame Count", (audioTrack.getWaveformData().getFramesCount() > 0 ? true : false));
assertTrue("WaveForm Gain", (audioTrack.getWaveformData().getFrameGains().length > 0 ? true : false));
}
use of android.media.videoeditor.MediaImageItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testMediaImageItemTransitions.
/**
* To Test the Media Image API : Get Before and after transition
*/
@LargeTest
public void testMediaImageItemTransitions() throws Exception {
final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final MediaImageItem mediaImageItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", imageItemFileName, 5000, imageItemRenderingMode);
mVideoEditor.addMediaItem(mediaImageItem1);
assertNull("Begin Transition", mediaImageItem1.getBeginTransition());
assertNull("End Transition", mediaImageItem1.getEndTransition());
TransitionFadeBlack transition1 = mVideoEditorHelper.createTFadeBlack("transition1", mediaImageItem1, null, 0, Transition.BEHAVIOR_SPEED_UP);
mVideoEditor.addTransition(transition1);
assertEquals("Begin transition", transition1, mediaImageItem1.getEndTransition());
assertNotNull("End Transition", mediaImageItem1.getEndTransition());
assertTrue(mediaImageItem1.getEndTransition().getId().equals(transition1.getId()));
assertTrue(mediaImageItem1.getEndTransition().getDuration() == transition1.getDuration() ? true : false);
assertTrue(mediaImageItem1.getEndTransition().getBehavior() == transition1.getBehavior() ? true : false);
TransitionFadeBlack transition2 = mVideoEditorHelper.createTFadeBlack("transition2", null, mediaImageItem1, 0, Transition.BEHAVIOR_SPEED_UP);
mVideoEditor.addTransition(transition2);
assertNotNull("Begin transition", mediaImageItem1.getBeginTransition());
assertEquals("End Transition", transition2, mediaImageItem1.getBeginTransition());
assertTrue(mediaImageItem1.getBeginTransition().getId().equals(transition2.getId()));
assertTrue(mediaImageItem1.getBeginTransition().getDuration() == transition2.getDuration() ? true : false);
assertTrue(mediaImageItem1.getBeginTransition().getBehavior() == transition2.getBehavior() ? true : false);
}
Aggregations