use of android.media.videoeditor.TransitionCrossfade in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorExportTest method testExportMMS.
/**
* To Test Export : With Video and Image : MMS use case
*
* @throws Exception
*/
@LargeTest
public void testExportMMS() 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_1600x1200.jpg";
final String videoItemFilename2 = INPUT_FILE_PATH + "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
final String maskFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
final MediaVideoItem mediaItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaItem1.setExtractBoundaries(2000, 7000);
mVideoEditor.addMediaItem(mediaItem1);
final TransitionAlpha transition1 = mVideoEditorHelper.createTAlpha("transition1", null, mediaItem1, 2000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, true);
mVideoEditor.addTransition(transition1);
final MediaImageItem mediaItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFilename1, 8000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaItem2);
final MediaVideoItem mediaItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaItem3.setExtractBoundaries(0, 8000);
mVideoEditor.addMediaItem(mediaItem3);
final TransitionSliding transition2And3 = mVideoEditorHelper.createTSliding("transition2", mediaItem2, mediaItem3, 4000, Transition.BEHAVIOR_MIDDLE_FAST, TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN);
mVideoEditor.addTransition(transition2And3);
final TransitionCrossfade transition3 = mVideoEditorHelper.createTCrossFade("transition3", mediaItem3, null, 3500, Transition.BEHAVIOR_MIDDLE_SLOW);
mVideoEditor.addTransition(transition3);
final EffectColor effectColor = mVideoEditorHelper.createEffectItem(mediaItem2, "effect", 0, 3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
mediaItem2.addEffect(effectColor);
mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_11_9);
try {
final int[] progressUpdate = new int[100];
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144, 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);
}
final long storyBoardDuration = mediaItem1.getTimelineDuration() + mediaItem2.getTimelineDuration() + mediaItem3.getTimelineDuration() - transition2And3.getDuration();
mVideoEditorHelper.validateExport(mVideoEditor, outFilename, MediaProperties.HEIGHT_144, 0, storyBoardDuration, MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
use of android.media.videoeditor.TransitionCrossfade in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorHelper method createTCrossFade.
/**
*This Method creates object of Type Transition Cross fade
*
* @return TransitionCrossfade object
*/
public TransitionCrossfade createTCrossFade(String transitionId, MediaItem afterMediaItem, MediaItem beforeMediaItem, long durationMs, int behavior) {
Log.i("TransitionCrossfade Details === ", "Transid ID = " + transitionId + " Duration= " + durationMs + " Behaviour " + behavior);
TransitionCrossfade transitionCF = null;
transitionCF = new TransitionCrossfade(transitionId, afterMediaItem, beforeMediaItem, durationMs, behavior);
return transitionCF;
}
use of android.media.videoeditor.TransitionCrossfade in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testVideoEditorAPI.
/**
* To test Video Editor API
*
* @throws Exception
*/
@LargeTest
public void testVideoEditorAPI() throws Exception {
final String videoItemFileName1 = INPUT_FILE_PATH + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4";
final String videoItemFileName2 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp";
final String videoItemFileName3 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
final String imageItemFileName1 = INPUT_FILE_PATH + "IMG_640x480.jpg";
final String imageItemFileName2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
final String audioFilename1 = INPUT_FILE_PATH + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
final String audioFilename2 = INPUT_FILE_PATH + "AACLC_48KHz_256Kbps_s_1_17.3gp";
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
boolean flagForException = false;
TransitionCrossfade transition2And4;
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName1, renderingMode);
mediaVideoItem1.setExtractBoundaries(0, 10000);
mVideoEditor.addMediaItem(mediaVideoItem1);
final MediaVideoItem mediaVideoItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", videoItemFileName2, renderingMode);
mediaVideoItem2.setExtractBoundaries(mediaVideoItem2.getDuration() / 4, mediaVideoItem2.getDuration() / 2);
mVideoEditor.addMediaItem(mediaVideoItem2);
final MediaVideoItem mediaVideoItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", videoItemFileName3, renderingMode);
mediaVideoItem3.setExtractBoundaries(mediaVideoItem3.getDuration() / 2, mediaVideoItem3.getDuration());
mVideoEditor.addMediaItem(mediaVideoItem3);
final MediaImageItem mediaImageItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", imageItemFileName1, 5000, renderingMode);
final MediaImageItem mediaImageItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", imageItemFileName2, 5000, renderingMode);
List<MediaItem> mediaList = mVideoEditor.getAllMediaItems();
assertEquals("Media Item List Size", 3, mediaList.size());
mVideoEditor.insertMediaItem(mediaImageItem1, 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", mediaImageItem1, mediaList.get(2));
assertEquals("Media item 3", mediaVideoItem3, mediaList.get(3));
mVideoEditor.insertMediaItem(mediaImageItem2, mediaImageItem1.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", mediaImageItem1, mediaList.get(2));
assertEquals("Media item 5", mediaImageItem2, mediaList.get(3));
assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4));
mVideoEditor.moveMediaItem(mediaVideoItem1.getId(), mediaImageItem2.getId());
mediaList = mVideoEditor.getAllMediaItems();
assertEquals("Media Item List Size", 5, mediaList.size());
assertEquals("Media item 2", mediaVideoItem2, mediaList.get(0));
assertEquals("Media item 4", mediaImageItem1, mediaList.get(1));
assertEquals("Media item 5", mediaImageItem2, mediaList.get(2));
assertEquals("Media item 1", mediaVideoItem1, mediaList.get(3));
assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4));
assertEquals("Media Item 1", mediaVideoItem1, mVideoEditor.getMediaItem(mediaVideoItem1.getId()));
flagForException = false;
transition2And4 = null;
try {
transition2And4 = mVideoEditorHelper.createTCrossFade("transition2And4", mediaVideoItem2, mediaImageItem1, 2000, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor.addTransition(transition2And4);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertFalse("Transition2and4 cannot be created", flagForException);
TransitionCrossfade transition1And3 = null;
flagForException = false;
try {
transition1And3 = mVideoEditorHelper.createTCrossFade("transition1And3", mediaVideoItem1, mediaVideoItem2, 5000, Transition.BEHAVIOR_MIDDLE_FAST);
mVideoEditor.addTransition(transition1And3);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Transition1and3 cannot be created", flagForException);
List<Transition> transitionList = mVideoEditor.getAllTransitions();
assertEquals("Transition List", 1, transitionList.size());
assertEquals("Transition 2", transition2And4, mVideoEditor.getTransition(transition2And4.getId()));
final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "audioTrack", audioFilename1);
mVideoEditor.addAudioTrack(audioTrack);
List<AudioTrack> audioList = mVideoEditor.getAllAudioTracks();
assertEquals("Audio List", 1, audioList.size());
final AudioTrack audioTrack1 = mVideoEditorHelper.createAudio(mVideoEditor, "audioTrack1", audioFilename2);
flagForException = false;
try {
mVideoEditor.addAudioTrack(audioTrack1);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Audio Track support is 1 ", flagForException);
flagForException = false;
try {
mVideoEditor.insertAudioTrack(audioTrack1, "audioTrack");
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Audio Track supports is 1 ", flagForException);
assertEquals("Removing AudioTrack", audioTrack, mVideoEditor.removeAudioTrack(audioTrack.getId()));
assertEquals("Removing transition", transition2And4, mVideoEditor.removeTransition(transition2And4.getId()));
assertEquals("Removing Media Item", mediaVideoItem2, mVideoEditor.removeMediaItem(mediaVideoItem2.getId()));
mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_16_9);
assertEquals("Check Aspect Ratio", MediaProperties.ASPECT_RATIO_16_9, mVideoEditor.getAspectRatio());
long storyBoardDuration = mediaVideoItem1.getTimelineDuration() + mediaVideoItem3.getTimelineDuration() + mediaImageItem1.getDuration() + mediaImageItem2.getDuration();
assertEquals("Story Board Duration", storyBoardDuration, mVideoEditor.getDuration());
}
use of android.media.videoeditor.TransitionCrossfade 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.TransitionCrossfade 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);
}
Aggregations