Search in sources :

Example 6 with EffectKenBurns

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

Example 7 with EffectKenBurns

use of android.media.videoeditor.EffectKenBurns 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)

Example 8 with EffectKenBurns

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

the class VideoEditorAPITest method testEffectKenBurn.

private void testEffectKenBurn(final String imageItemFileName, final String MediaId) throws Exception {
    final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, MediaId, 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: " + imageItemFileName, kbEffectOnMediaItem);
    mediaImageItem.addEffect(kbEffectOnMediaItem);
    assertEquals("KenBurn Start Rect: " + imageItemFileName, startRect, kbEffectOnMediaItem.getStartRect());
    assertEquals("KenBurn End Rect: " + imageItemFileName, endRect, kbEffectOnMediaItem.getEndRect());
}
Also used : Rect(android.graphics.Rect) EffectKenBurns(android.media.videoeditor.EffectKenBurns) MediaImageItem(android.media.videoeditor.MediaImageItem)

Aggregations

Rect (android.graphics.Rect)8 EffectKenBurns (android.media.videoeditor.EffectKenBurns)8 MediaImageItem (android.media.videoeditor.MediaImageItem)8 LargeTest (android.test.suitebuilder.annotation.LargeTest)7 MediaVideoItem (android.media.videoeditor.MediaVideoItem)5 EffectColor (android.media.videoeditor.EffectColor)4 Bitmap (android.graphics.Bitmap)3 OverlayFrame (android.media.videoeditor.OverlayFrame)3 AudioTrack (android.media.videoeditor.AudioTrack)2 TransitionCrossfade (android.media.videoeditor.TransitionCrossfade)2 VideoEditor (android.media.videoeditor.VideoEditor)2 ExportProgressListener (android.media.videoeditor.VideoEditor.ExportProgressListener)2 MediaProcessingProgressListener (android.media.videoeditor.VideoEditor.MediaProcessingProgressListener)2 TransitionAlpha (android.media.videoeditor.TransitionAlpha)1 TransitionFadeBlack (android.media.videoeditor.TransitionFadeBlack)1 TransitionSliding (android.media.videoeditor.TransitionSliding)1 File (java.io.File)1 Semaphore (java.util.concurrent.Semaphore)1