use of android.media.videoeditor.EffectColor in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPreviewTest method testStartPreviewAddRemoveMediaItems.
/**
* To Test Preview : Add Media and Remove Media Item (Without any Media
* Items in the story Board)
*/
@LargeTest
public void testStartPreviewAddRemoveMediaItems() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String alphaFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
boolean flagForException = false;
final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem.setExtractBoundaries(0, 15000);
mVideoEditor.addMediaItem(mediaVideoItem);
final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem);
final TransitionAlpha transition1And2 = mVideoEditorHelper.createTAlpha("transition", mediaVideoItem, mediaImageItem, 3000, Transition.BEHAVIOR_SPEED_UP, alphaFilename, 10, false);
mVideoEditor.addTransition(transition1And2);
final EffectColor effectColor = mVideoEditorHelper.createEffectItem(mediaImageItem, "effect", 5000, 3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
mediaImageItem.addEffect(effectColor);
assertEquals("removing Media item 1", mediaVideoItem, mVideoEditor.removeMediaItem(mediaVideoItem.getId()));
assertEquals("removing Media item 2", mediaImageItem, mVideoEditor.removeMediaItem(mediaImageItem.getId()));
try {
mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
public void onProgress(Object item, int action, int progress) {
}
});
final SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
mVideoEditor.startPreview(surfaceHolder, 0, -1, false, 1, new PreviewProgressListener() {
public void onProgress(VideoEditor videoEditor, long timeMs, OverlayData overlayData) {
}
public void onStart(VideoEditor videoEditor) {
setPreviewStart();
}
public void onStop(VideoEditor videoEditor) {
setPreviewStop();
}
public void onError(VideoEditor videoEditor, int error) {
setPreviewError();
}
});
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Preview with removed Media Items", flagForException);
}
use of android.media.videoeditor.EffectColor in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorExportTest method testExportEffectOverlay.
/**
*To Test export : With Effect and Overlays on Different Media Items
*/
@LargeTest
public void testExportEffectOverlay() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String videoItemFilename2 = INPUT_FILE_PATH + "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_64kps_m_0_27.3gp";
final String videoItemFilename3 = INPUT_FILE_PATH + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4";
final String imageItemFilename2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
final String imageItemFilename3 = INPUT_FILE_PATH + "IMG_640x480.jpg";
final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
final String overlayFile = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem1.setExtractBoundaries(2000, 7000);
mVideoEditor.addMediaItem(mediaVideoItem1);
final EffectColor effectPink = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effectPink", 0, 2000, EffectColor.TYPE_COLOR, EffectColor.PINK);
mediaVideoItem1.addEffect(effectPink);
final EffectColor effectNegative = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effectNegative", 3000, 4000, EffectColor.TYPE_NEGATIVE, 0);
mediaVideoItem1.addEffect(effectNegative);
final MediaImageItem mediaImageItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFilename1, 3000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem2);
final EffectColor effectFifties = mVideoEditorHelper.createEffectItem(mediaImageItem2, "effectFifties", 0, 3000, EffectColor.TYPE_FIFTIES, 0);
mediaImageItem2.addEffect(effectFifties);
final MediaVideoItem mediaVideoItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaVideoItem3);
mediaVideoItem3.setExtractBoundaries(0, 8000);
final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile, 640, 480);
final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaVideoItem3, "overlay", mBitmap, 2000, 5000);
mediaVideoItem3.addOverlay(overlayFrame);
final EffectColor effectGreen = mVideoEditorHelper.createEffectItem(mediaVideoItem3, "effectGreen", 0, 2000, EffectColor.TYPE_COLOR, EffectColor.GREEN);
mediaVideoItem3.addEffect(effectGreen);
final MediaVideoItem mediaVideoItem4 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem4.setExtractBoundaries(mediaVideoItem4.getDuration() - 5000, mediaVideoItem4.getDuration());
mVideoEditor.addMediaItem(mediaVideoItem4);
final EffectColor effectSepia = mVideoEditorHelper.createEffectItem(mediaVideoItem4, "effectSepia", 0, 2000, EffectColor.TYPE_SEPIA, 0);
mediaVideoItem4.addEffect(effectSepia);
final MediaImageItem mediaImageItem5 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", imageItemFilename2, 4000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem5);
final EffectColor effectGray = mVideoEditorHelper.createEffectItem(mediaImageItem5, "effectGray", 0, 2000, EffectColor.TYPE_COLOR, EffectColor.GRAY);
mediaImageItem5.addEffect(effectGray);
final MediaImageItem mediaImageItem6 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", imageItemFilename3, 2000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem6);
final EffectColor effectGradient = mVideoEditorHelper.createEffectItem(mediaImageItem6, "effectGradient", 0, 2000, EffectColor.TYPE_GRADIENT, EffectColor.PINK);
mediaImageItem6.addEffect(effectGradient);
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);
}
final long storyBoardDuration = mediaVideoItem1.getTimelineDuration() + mediaImageItem2.getDuration() + mediaVideoItem3.getTimelineDuration() + mediaVideoItem4.getTimelineDuration() + mediaImageItem5.getDuration() + mediaImageItem6.getDuration();
mVideoEditorHelper.validateExport(mVideoEditor, outFilename, MediaProperties.HEIGHT_720, 0, storyBoardDuration, MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
use of android.media.videoeditor.EffectColor 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.EffectColor in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorHelper method createEffectItem.
/**
*This Method Create a Effect with the specified params
*
* @return an Object of EffectColor
*/
public EffectColor createEffectItem(MediaItem mediaItem, String effectId, long startTime, long duration, int effectType, int colorType) {
EffectColor effectonMVI = null;
effectonMVI = new EffectColor(mediaItem, effectId, startTime, duration, effectType, colorType);
return effectonMVI;
}
use of android.media.videoeditor.EffectColor in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testAllEffects.
/**
* To test Effect Color.
*/
@LargeTest
public void testAllEffects() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH + "MPEG4_SP_640x480_30fps_512Kbps_0_27.mp4";
boolean flagForException = false;
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaVideoItem1);
final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect1", 1000, 1000, EffectColor.TYPE_COLOR, EffectColor.PINK);
mediaVideoItem1.addEffect(effectColor1);
assertEquals("Associated Media Item", mediaVideoItem1, effectColor1.getMediaItem());
assertTrue("Effect Id", effectColor1.getId().equals("effect1"));
assertEquals("Effect StartTime", 1000, effectColor1.getStartTime());
assertEquals("Effect EndTime", 1000, effectColor1.getDuration());
assertEquals("Effect Type", EffectColor.TYPE_COLOR, effectColor1.getType());
assertEquals("Effect Color", EffectColor.PINK, effectColor1.getColor());
final EffectColor effectColor2 = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect2", 2000, 1000, EffectColor.TYPE_COLOR, EffectColor.GRAY);
mediaVideoItem1.addEffect(effectColor2);
assertEquals("Associated Media Item", mediaVideoItem1, effectColor2.getMediaItem());
assertTrue("Effect Id", effectColor2.getId().equals("effect2"));
assertEquals("Effect StartTime", 2000, effectColor2.getStartTime());
assertEquals("Effect EndTime", 1000, effectColor2.getDuration());
assertEquals("Effect Type", EffectColor.TYPE_COLOR, effectColor2.getType());
assertEquals("Effect Color", EffectColor.GRAY, effectColor2.getColor());
final EffectColor effectColor3 = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect3", 3000, 1000, EffectColor.TYPE_COLOR, EffectColor.GREEN);
mediaVideoItem1.addEffect(effectColor3);
assertEquals("Associated Media Item", mediaVideoItem1, effectColor3.getMediaItem());
assertTrue("Effect Id", effectColor3.getId().equals("effect3"));
assertEquals("Effect StartTime", 3000, effectColor3.getStartTime());
assertEquals("Effect EndTime", 1000, effectColor3.getDuration());
assertEquals("Effect Type", EffectColor.TYPE_COLOR, effectColor3.getType());
assertEquals("Effect Color", EffectColor.GREEN, effectColor3.getColor());
final EffectColor effectColor4 = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect4", 4000, 1000, EffectColor.TYPE_GRADIENT, EffectColor.PINK);
mediaVideoItem1.addEffect(effectColor4);
assertEquals("Associated Media Item", mediaVideoItem1, effectColor4.getMediaItem());
assertTrue("Effect Id", effectColor4.getId().equals("effect4"));
assertEquals("Effect StartTime", 4000, effectColor4.getStartTime());
assertEquals("Effect EndTime", 1000, effectColor4.getDuration());
assertEquals("Effect Type", EffectColor.TYPE_GRADIENT, effectColor4.getType());
assertEquals("Effect Color", EffectColor.PINK, effectColor4.getColor());
final EffectColor effectColor5 = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect5", 5000, 1000, EffectColor.TYPE_GRADIENT, EffectColor.GRAY);
mediaVideoItem1.addEffect(effectColor5);
assertEquals("Associated Media Item", mediaVideoItem1, effectColor5.getMediaItem());
assertTrue("Effect Id", effectColor5.getId().equals("effect5"));
assertEquals("Effect StartTime", 5000, effectColor5.getStartTime());
assertEquals("Effect EndTime", 1000, effectColor5.getDuration());
assertEquals("Effect Type", EffectColor.TYPE_GRADIENT, effectColor5.getType());
assertEquals("Effect Color", EffectColor.GRAY, effectColor5.getColor());
final EffectColor effectColor6 = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect6", 6000, 1000, EffectColor.TYPE_GRADIENT, EffectColor.GREEN);
mediaVideoItem1.addEffect(effectColor6);
assertEquals("Associated Media Item", mediaVideoItem1, effectColor6.getMediaItem());
assertTrue("Effect Id", effectColor6.getId().equals("effect6"));
assertEquals("Effect StartTime", 6000, effectColor6.getStartTime());
assertEquals("Effect EndTime", 1000, effectColor6.getDuration());
assertEquals("Effect Type", EffectColor.TYPE_GRADIENT, effectColor6.getType());
assertEquals("Effect Color", EffectColor.GREEN, effectColor6.getColor());
final EffectColor effectColor7 = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect7", 7000, 1000, EffectColor.TYPE_FIFTIES, 0);
mediaVideoItem1.addEffect(effectColor7);
assertEquals("Associated Media Item", mediaVideoItem1, effectColor7.getMediaItem());
assertTrue("Effect Id", effectColor7.getId().equals("effect7"));
assertEquals("Effect StartTime", 7000, effectColor7.getStartTime());
assertEquals("Effect EndTime", 1000, effectColor7.getDuration());
assertEquals("Effect Type", EffectColor.TYPE_FIFTIES, effectColor7.getType());
assertEquals("Effect Color", -1, effectColor7.getColor());
final EffectColor effectColor8 = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect8", 8000, 1000, EffectColor.TYPE_SEPIA, 0);
mediaVideoItem1.addEffect(effectColor8);
assertEquals("Associated Media Item", mediaVideoItem1, effectColor8.getMediaItem());
assertTrue("Effect Id", effectColor8.getId().equals("effect8"));
assertEquals("Effect StartTime", 8000, effectColor8.getStartTime());
assertEquals("Effect EndTime", 1000, effectColor8.getDuration());
assertEquals("Effect Type", EffectColor.TYPE_SEPIA, effectColor8.getType());
assertEquals("Effect Color", -1, effectColor8.getColor());
final EffectColor effectColor9 = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect9", 9000, 1000, EffectColor.TYPE_NEGATIVE, 0);
mediaVideoItem1.addEffect(effectColor9);
assertEquals("Associated Media Item", mediaVideoItem1, effectColor9.getMediaItem());
assertTrue("Effect Id", effectColor9.getId().equals("effect9"));
assertEquals("Effect StartTime", 9000, effectColor9.getStartTime());
assertEquals("Effect EndTime", 1000, effectColor9.getDuration());
assertEquals("Effect Type", EffectColor.TYPE_NEGATIVE, effectColor9.getType());
assertEquals("Effect Color", -1, effectColor9.getColor());
try {
mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect9", 9000, 1000, EffectColor.TYPE_COLOR - 1, 0);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Effect type Invalid", flagForException);
flagForException = false;
try {
mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect9", 9000, 1000, EffectColor.TYPE_FIFTIES + 1, 0);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Effect type Invalid", flagForException);
try {
mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect10", 10000, 1000, EffectColor.TYPE_FIFTIES + EffectColor.TYPE_GRADIENT, 0);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Effect type Invalid", flagForException);
}
Aggregations