Search in sources :

Example 16 with EffectColor

use of android.media.videoeditor.EffectColor 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);
}
Also used : VideoEditor(android.media.videoeditor.VideoEditor) EffectColor(android.media.videoeditor.EffectColor) ExportProgressListener(android.media.videoeditor.VideoEditor.ExportProgressListener) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaImageItem(android.media.videoeditor.MediaImageItem) TransitionAlpha(android.media.videoeditor.TransitionAlpha) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 17 with EffectColor

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

the class VideoEditorPreviewTest method testPreviewWithRenderPreviewFrame.

/**
     * To test Preview : Preview of current Effects applied (with Render Preview
     * Frame)
     */
@LargeTest
public void testPreviewWithRenderPreviewFrame() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
    final Semaphore blockTillPreviewCompletes = new Semaphore(1);
    boolean flagForException = false;
    OverlayData overlayData1 = new OverlayData();
    previewStart = false;
    previewStop = false;
    final String overlayFilename1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaVideoItem);
    final EffectColor effectPink = mVideoEditorHelper.createEffectItem(mediaVideoItem, "effectNegativeOnMvi", 1000, 3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
    mediaVideoItem.addEffect(effectPink);
    mVideoEditor.generatePreview(new MediaProcessingProgressListener() {

        public void onProgress(Object item, int action, int progress) {
        }
    });
    final SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
    assertEquals("Render preview Frame at 5 Sec", 5000, mVideoEditor.renderPreviewFrame(surfaceHolder, 5000, overlayData1));
    assertEquals("Render preview Frame at 7 Sec", 7000, mVideoEditor.renderPreviewFrame(surfaceHolder, 7000, overlayData1));
    validatePreviewProgress(5000, -1, false, mVideoEditor.getDuration());
}
Also used : SurfaceHolder(android.view.SurfaceHolder) EffectColor(android.media.videoeditor.EffectColor) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaProcessingProgressListener(android.media.videoeditor.VideoEditor.MediaProcessingProgressListener) OverlayData(android.media.videoeditor.VideoEditor.OverlayData) Semaphore(java.util.concurrent.Semaphore) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 18 with EffectColor

use of android.media.videoeditor.EffectColor 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);
}
Also used : Rect(android.graphics.Rect) EffectColor(android.media.videoeditor.EffectColor) EffectKenBurns(android.media.videoeditor.EffectKenBurns) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaImageItem(android.media.videoeditor.MediaImageItem) 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