Search in sources :

Example 1 with EffectColor

use of android.media.videoeditor.EffectColor in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorAPITest method testEffectSetgetDuration.

/**
     * To test Effect Color : Set duration and Get Duration
     */
@LargeTest
public void testEffectSetgetDuration() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "MPEG4_SP_640x480_30fps_512Kbps_0_27.mp4";
    final int videoItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    boolean flagForException = false;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName, videoItemRenderingMode);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect1", 1000, 2000, EffectColor.TYPE_COLOR, EffectColor.PINK);
    mediaVideoItem1.addEffect(effectColor1);
    effectColor1.setDuration(5000);
    assertEquals("Updated Effect Duration", 5000, effectColor1.getDuration());
    try {
        effectColor1.setDuration(mediaVideoItem1.getDuration() + 1000);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Effect Color duration > mediaVideoItemDuration", flagForException);
    assertEquals("Effect Duration", 5000, effectColor1.getDuration());
    flagForException = false;
    try {
        effectColor1.setDuration(-1);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Effect Color duration = -1", flagForException);
}
Also used : EffectColor(android.media.videoeditor.EffectColor) MediaVideoItem(android.media.videoeditor.MediaVideoItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 2 with EffectColor

use of android.media.videoeditor.EffectColor in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorAPITest method testMediaVideoItemEffect.

/**
     * To Test the Media Video API : Get Effect, GetAllEffects, remove Effect
     */
@LargeTest
public void testMediaVideoItemEffect() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
    final int videoItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName, videoItemRenderingMode);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    assertTrue("Effect List Size", (mediaVideoItem1.getAllEffects().size() == 0) ? true : false);
    assertNull("Effect Item by ID", mediaVideoItem1.getEffect("xyx"));
    final EffectColor effectColor = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "Effecton MVi1", 0, 4000, EffectColor.TYPE_GRADIENT, EffectColor.GRAY);
    mediaVideoItem1.addEffect(effectColor);
    assertTrue("Effect List Size", (mediaVideoItem1.getAllEffects().size() == 1) ? true : false);
    assertEquals("Effect Item by Valid ID", effectColor, mediaVideoItem1.getEffect(effectColor.getId()));
    assertNull("Effect Item by Invalid ID", mediaVideoItem1.getEffect("xyz"));
    assertNull("Effect Item by Invalid ID", mediaVideoItem1.removeEffect("effectId"));
    assertTrue("Effect List Size", (mediaVideoItem1.getAllEffects().size() == 1) ? true : false);
    assertEquals("Effect Removed", effectColor, mediaVideoItem1.removeEffect(effectColor.getId()));
    assertTrue("Effect List Size", (mediaVideoItem1.getAllEffects().size() == 0) ? true : false);
    assertNull("Effect Item by ID", mediaVideoItem1.getEffect("effectId"));
}
Also used : EffectColor(android.media.videoeditor.EffectColor) MediaVideoItem(android.media.videoeditor.MediaVideoItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 3 with EffectColor

use of android.media.videoeditor.EffectColor in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorAPITest method testMediaImageItemEffect.

/**
     * To Test the Media Image API : Get Effect, GetAllEffects, remove Effect
     */
@LargeTest
public void testMediaImageItemEffect() 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);
    assertTrue("Effect List Size", (mediaImageItem1.getAllEffects().size() == 0) ? true : false);
    assertNull("Effect Item by ID", mediaImageItem1.getEffect("xyx"));
    final EffectColor effectColor = mVideoEditorHelper.createEffectItem(mediaImageItem1, "Effecton MVi1", 0, 4000, EffectColor.TYPE_GRADIENT, EffectColor.GRAY);
    mediaImageItem1.addEffect(effectColor);
    assertTrue("Effect List Size", (mediaImageItem1.getAllEffects().size() == 1) ? true : false);
    assertEquals("Effect Item by Valid ID", effectColor, mediaImageItem1.getEffect(effectColor.getId()));
    assertNull("Effect Item by Invalid ID", mediaImageItem1.getEffect("xyz"));
    assertNull("Effect Item by Invalid ID", mediaImageItem1.removeEffect("effectId"));
    assertTrue("Effect List Size", (mediaImageItem1.getAllEffects().size() == 1) ? true : false);
    assertEquals("Effect Removed", effectColor, mediaImageItem1.removeEffect(effectColor.getId()));
    assertTrue("Effect List Size", (mediaImageItem1.getAllEffects().size() == 0) ? true : false);
    assertNull("Effect Item by ID", mediaImageItem1.getEffect("effectId"));
}
Also used : EffectColor(android.media.videoeditor.EffectColor) MediaImageItem(android.media.videoeditor.MediaImageItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 4 with EffectColor

use of android.media.videoeditor.EffectColor in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorPreviewTest method testPreviewWithOverlayEffectKenBurn.

/**
     * To test Preview : Preview of current work having Overlay and Effect
     * applied
     */
@LargeTest
public void testPreviewWithOverlayEffectKenBurn() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "H264_BP_640x480_30fps_192kbps_1_5.mp4";
    final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
    final String videoItemFileName1 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
    final String overlayFilename = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    final Semaphore blockTillPreviewCompletes = new Semaphore(1);
    previewStart = false;
    previewStop = false;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    final MediaImageItem mediaImageItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFileName, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaImageItem2);
    final MediaVideoItem mediaVideoItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaVideoItem3);
    final EffectColor effectColor = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "Effect1", 1000, 3000, EffectColor.TYPE_COLOR, EffectColor.GREEN);
    mediaVideoItem1.addEffect(effectColor);
    final Rect startRect = new Rect((mediaImageItem2.getHeight() / 3), (mediaImageItem2.getWidth() / 3), (mediaImageItem2.getHeight() / 2), (mediaImageItem2.getWidth() / 2));
    final Rect endRect = new Rect(0, 0, mediaImageItem2.getWidth(), mediaImageItem2.getHeight());
    final EffectKenBurns kbeffectOnMI2 = new EffectKenBurns(mediaImageItem2, "KBOnM2", startRect, endRect, 0, 10000);
    assertNotNull("EffectKenBurns", kbeffectOnMI2);
    mediaImageItem2.addEffect(kbeffectOnMI2);
    final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFilename, 640, 480);
    final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaVideoItem3, "OverlayID", mBitmap, (mediaImageItem2.getDuration() / 4), (mediaVideoItem3.getDuration() / 3));
    mediaVideoItem3.addOverlay(overlayFrame);
    validatePreviewProgress(5000, -1, false, mVideoEditor.getDuration());
}
Also used : Rect(android.graphics.Rect) Bitmap(android.graphics.Bitmap) EffectColor(android.media.videoeditor.EffectColor) EffectKenBurns(android.media.videoeditor.EffectKenBurns) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaImageItem(android.media.videoeditor.MediaImageItem) OverlayFrame(android.media.videoeditor.OverlayFrame) Semaphore(java.util.concurrent.Semaphore) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 5 with EffectColor

use of android.media.videoeditor.EffectColor in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorStressTest method testStressLoadAndSave.

/**
     * To stress test : load and save
     *
     * @throws Exception
     */
@LargeTest
public void testStressLoadAndSave() throws Exception {
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final String VideoItemFileName1 = INPUT_FILE_PATH + "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
    final String VideoItemFileName2 = INPUT_FILE_PATH + "H264_BP_800x480_15fps_512kbps_1_17.mp4";
    final String VideoItemFileName3 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp";
    final String ImageItemFileName4 = INPUT_FILE_PATH + "IMG_640x480.jpg";
    final String ImageItemFileName5 = INPUT_FILE_PATH + "IMG_176x144.jpg";
    final String OverlayFile6 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    final String[] loggingInfo = new String[1];
    int i = 0;
    final String[] projectPath = new String[10];
    writeTestCaseHeader("testStressLoadAndSave");
    getBeginMemory();
    for (i = 0; i < 10; i++) {
        projectPath[i] = mVideoEditorHelper.createRandomFile(PROJECT_LOCATION);
        final VideoEditor mVideoEditor1 = mVideoEditorHelper.createVideoEditor(projectPath[i]);
        final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor1, "m1", VideoItemFileName1, renderingMode);
        mVideoEditor1.addMediaItem(mediaItem1);
        mediaItem1.setExtractBoundaries(0, 10000);
        final MediaVideoItem mediaItem2 = new MediaVideoItem(mVideoEditor1, "m2", VideoItemFileName2, renderingMode);
        mVideoEditor1.addMediaItem(mediaItem2);
        mediaItem2.setExtractBoundaries(mediaItem2.getDuration() / 4, mediaItem2.getDuration() / 2);
        final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor1, "m3", VideoItemFileName3, renderingMode);
        mVideoEditor1.addMediaItem(mediaItem3);
        mediaItem3.setExtractBoundaries(mediaItem3.getDuration() / 2, mediaItem3.getDuration());
        final MediaImageItem mediaItem4 = new MediaImageItem(mVideoEditor1, "m4", ImageItemFileName4, 5000, renderingMode);
        mVideoEditor1.addMediaItem(mediaItem4);
        final MediaImageItem mediaItem5 = new MediaImageItem(mVideoEditor1, "m5", ImageItemFileName5, 5000, renderingMode);
        mVideoEditor1.addMediaItem(mediaItem5);
        final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(mediaItem3, "effect1", 10000, 2000, EffectColor.TYPE_COLOR, EffectColor.GREEN);
        mediaItem3.addEffect(effectColor1);
        final Bitmap mBitmap = mVideoEditorHelper.getBitmap(OverlayFile6, 640, 480);
        final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaItem4, "overlay", mBitmap, 4000, 1000);
        mediaItem4.addOverlay(overlayFrame);
        final TransitionCrossfade tranCrossfade = new TransitionCrossfade("transCF", mediaItem1, mediaItem2, 5000, Transition.BEHAVIOR_MIDDLE_FAST);
        mVideoEditor1.addTransition(tranCrossfade);
        final EffectColor effectColor2 = mVideoEditorHelper.createEffectItem(mediaItem4, "effect2", 0, mediaItem4.getDuration(), EffectColor.TYPE_COLOR, EffectColor.PINK);
        mediaItem4.addEffect(effectColor2);
        mVideoEditor1.generatePreview(new MediaProcessingProgressListener() {

            public void onProgress(Object item, int action, int progress) {
            }
        });
        mVideoEditor1.save();
        mVideoEditor1.release();
        getAfterMemory_updateLog(loggingInfo, false, i);
    }
    getAfterMemory_updateLog(loggingInfo, false, i);
    /** Remove items and check for memory leak if any */
    for (i = 0; i < 10; i++) {
        final VideoEditor mVideoEditor1b = VideoEditorFactory.load(projectPath[i], true);
        List<MediaItem> mediaList = mVideoEditor1b.getAllMediaItems();
        assertEquals("Media Item List Size", 5, mediaList.size());
        mediaList.get(3).removeEffect("effect1");
        mediaList.get(3).removeEffect("effect2");
        mediaList.get(2).removeOverlay("overlay");
        mVideoEditor1b.removeTransition("transCF");
        mVideoEditor1b.removeMediaItem("m5");
        mVideoEditor1b.removeMediaItem("m4");
        mVideoEditor1b.removeMediaItem("m3");
        mVideoEditor1b.removeMediaItem("m2");
        mVideoEditor1b.removeMediaItem("m1");
        mVideoEditor1b.release();
        getAfterMemory_updateLog(loggingInfo, true, i);
    }
    getAfterMemory_updateLog(loggingInfo, true, i);
}
Also used : VideoEditor(android.media.videoeditor.VideoEditor) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaProcessingProgressListener(android.media.videoeditor.VideoEditor.MediaProcessingProgressListener) MediaImageItem(android.media.videoeditor.MediaImageItem) OverlayFrame(android.media.videoeditor.OverlayFrame) TransitionCrossfade(android.media.videoeditor.TransitionCrossfade) Bitmap(android.graphics.Bitmap) EffectColor(android.media.videoeditor.EffectColor) MediaItem(android.media.videoeditor.MediaItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

EffectColor (android.media.videoeditor.EffectColor)18 LargeTest (android.test.suitebuilder.annotation.LargeTest)17 MediaVideoItem (android.media.videoeditor.MediaVideoItem)16 MediaImageItem (android.media.videoeditor.MediaImageItem)10 TransitionCrossfade (android.media.videoeditor.TransitionCrossfade)6 VideoEditor (android.media.videoeditor.VideoEditor)6 MediaProcessingProgressListener (android.media.videoeditor.VideoEditor.MediaProcessingProgressListener)6 Bitmap (android.graphics.Bitmap)5 OverlayFrame (android.media.videoeditor.OverlayFrame)5 Rect (android.graphics.Rect)4 EffectKenBurns (android.media.videoeditor.EffectKenBurns)4 TransitionAlpha (android.media.videoeditor.TransitionAlpha)4 ExportProgressListener (android.media.videoeditor.VideoEditor.ExportProgressListener)4 Semaphore (java.util.concurrent.Semaphore)3 AudioTrack (android.media.videoeditor.AudioTrack)2 TransitionSliding (android.media.videoeditor.TransitionSliding)2 OverlayData (android.media.videoeditor.VideoEditor.OverlayData)2 SurfaceHolder (android.view.SurfaceHolder)2 Effect (android.media.videoeditor.Effect)1 MediaItem (android.media.videoeditor.MediaItem)1