use of android.media.videoeditor.MediaImageItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPerformance method testPerformanceWithKenBurn.
/**
* To test the performance of generatePreview : with KenBurn
*
* @throws Exception
*/
@LargeTest
public void testPerformanceWithKenBurn() 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;
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 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);
mediaImageItem.addEffect(kbEffectOnMediaItem);
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();
mediaImageItem.removeEffect(kbEffectOnMediaItem.getId());
mediaImageItem.addEffect(kbEffectOnMediaItem);
averageTime += duration2 - duration1;
}
final long durationToAddObjects = (averageTime);
final float timeTaken = (float) durationToAddObjects * 1.0f / (float) NUM_OF_ITERATIONS;
loggingInfo[0] = "Time taken to Generate KenBurn Effect :" + timeTaken;
writeTimingInfo("testPerformanceWithKenBurn", loggingInfo);
}
use of android.media.videoeditor.MediaImageItem 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.MediaImageItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorExportTest method testExportWithoutMediaItemsAddRemove.
/**
* To Test Export : With Media Items add and removed in the story Board
*
* @throws Exception
*/
@LargeTest
public void testExportWithoutMediaItemsAddRemove() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp";
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg";
final String maskFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
boolean flagForException = false;
final MediaVideoItem mediaItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaItem1.setExtractBoundaries(0, 15000);
mVideoEditor.addMediaItem(mediaItem1);
final MediaImageItem mediaItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaItem2);
final TransitionAlpha transition1 = mVideoEditorHelper.createTAlpha("transition1", mediaItem1, mediaItem2, 3000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, false);
mVideoEditor.addTransition(transition1);
final EffectColor effectColor = mVideoEditorHelper.createEffectItem(mediaItem2, "effect", 12000, 3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
mediaItem2.addEffect(effectColor);
mVideoEditor.removeMediaItem(mediaItem1.getId());
mVideoEditor.removeMediaItem(mediaItem2.getId());
try {
final int[] progressUpdate = new int[100];
mVideoEditor.export("/sdcard/Test.3gp", 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 (IllegalStateException e) {
flagForException = true;
}
assertTrue("Export with MediaItem added and removed", flagForException);
}
use of android.media.videoeditor.MediaImageItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPreviewTest method testRenderPreviewFrame.
/**
* To test render Preview Frame
*/
@LargeTest
public void testRenderPreviewFrame() throws Exception {
final String videoItemFileName1 = INPUT_FILE_PATH + "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
final String videoItemFileName2 = INPUT_FILE_PATH + "MPEG4_SP_800x480_515kbps_15fps_AMR_NB_8KHz_12.2kbps_m_0_26.mp4";
final String videoItemFileName3 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String imageItemFilename2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
final String audioFilename = INPUT_FILE_PATH + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
OverlayData overlayData1 = new OverlayData();
previewStart = false;
previewStop = false;
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem1.setExtractBoundaries(0, 10000);
mVideoEditor.addMediaItem(mediaVideoItem1);
final MediaVideoItem mediaVideoItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", videoItemFileName2, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem1.setExtractBoundaries(mediaVideoItem2.getDuration() / 4, mediaVideoItem2.getDuration() / 2);
mVideoEditor.addMediaItem(mediaVideoItem2);
final MediaVideoItem mediaVideoItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", videoItemFileName3, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem1.setExtractBoundaries(mediaVideoItem2.getDuration() / 2, mediaVideoItem2.getDuration());
mVideoEditor.addMediaItem(mediaVideoItem3);
final MediaImageItem mediaImageItem4 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", imageItemFilename1, 5000, MediaItem.RENDERING_MODE_BLACK_BORDER);
final MediaImageItem mediaImageItem5 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", imageItemFilename2, 5000, MediaItem.RENDERING_MODE_BLACK_BORDER);
List<MediaItem> mediaList = mVideoEditor.getAllMediaItems();
assertEquals("Media Item List Size", 3, mediaList.size());
mVideoEditor.insertMediaItem(mediaImageItem4, mediaVideoItem2.getId());
mediaList = mVideoEditor.getAllMediaItems();
assertEquals("Media Item List Size", 4, mediaList.size());
assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0));
assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1));
assertEquals("Media item 4", mediaImageItem4, mediaList.get(2));
assertEquals("Media item 3", mediaVideoItem3, mediaList.get(3));
mVideoEditor.insertMediaItem(mediaImageItem5, mediaImageItem4.getId());
mediaList = mVideoEditor.getAllMediaItems();
assertEquals("Media Item List Size", 5, mediaList.size());
assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0));
assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1));
assertEquals("Media item 4", mediaImageItem4, mediaList.get(2));
assertEquals("Media item 5", mediaImageItem5, mediaList.get(3));
assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4));
mVideoEditor.moveMediaItem(mediaVideoItem1.getId(), mediaImageItem5.getId());
mediaList = mVideoEditor.getAllMediaItems();
assertEquals("Media Item List Size", 5, mediaList.size());
assertEquals("Media item 2", mediaVideoItem2, mediaList.get(0));
assertEquals("Media item 4", mediaImageItem4, mediaList.get(1));
assertEquals("Media item 5", mediaImageItem5, mediaList.get(2));
assertEquals("Media item 1", mediaVideoItem1, mediaList.get(3));
assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4));
final TransitionCrossfade transition2And4CrossFade = mVideoEditorHelper.createTCrossFade("transition2And4CrossFade", mediaVideoItem2, mediaImageItem4, 2000, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor.addTransition(transition2And4CrossFade);
final TransitionCrossfade transition1And3CrossFade = mVideoEditorHelper.createTCrossFade("transition1And3CrossFade", mediaVideoItem1, mediaVideoItem3, 5000, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor.addTransition(transition1And3CrossFade);
final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "a1", audioFilename);
audioTrack.setExtractBoundaries(0, 2000);
mVideoEditor.addAudioTrack(audioTrack);
audioTrack.enableLoop();
mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
public void onProgress(Object item, int action, int progress) {
}
});
final SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
mVideoEditor.renderPreviewFrame(surfaceHolder, mVideoEditor.getDuration() / 4, overlayData1);
Thread.sleep(1000);
mVideoEditor.renderPreviewFrame(surfaceHolder, mVideoEditor.getDuration() / 2, overlayData1);
Thread.sleep(1000);
mVideoEditor.renderPreviewFrame(surfaceHolder, mVideoEditor.getDuration(), overlayData1);
}
use of android.media.videoeditor.MediaImageItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPreviewTest method testPreviewWithEndAudioTrack.
/**
* To test Preview : Preview of current work from selected jump location
* till end with Audio Track
*/
@LargeTest
public void testPreviewWithEndAudioTrack() throws Exception {
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String videoItemFileName = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
final String imageItemFilename2 = INPUT_FILE_PATH + "IMG_640x480.jpg";
final String audioFilename = INPUT_FILE_PATH + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
boolean flagForException = false;
previewStart = false;
previewStop = false;
final MediaImageItem mediaImageItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", imageItemFilename1, 7000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem1);
final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem.setExtractBoundaries(1000, 8000);
mVideoEditor.addMediaItem(mediaVideoItem);
final MediaImageItem mediaImageItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", imageItemFilename2, 7000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem2);
final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "a1", audioFilename);
mVideoEditor.addAudioTrack(audioTrack);
List<AudioTrack> audioList = mVideoEditor.getAllAudioTracks();
assertEquals("Audio Track List size", 1, audioList.size());
assertEquals("Audio Track", audioTrack, audioList.get(0));
mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_4_3);
validatePreviewProgress(10000, -1, false, mVideoEditor.getDuration());
}
Aggregations