Search in sources :

Example 16 with MediaImageItem

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

the class VideoEditorPerformance method testPerformanceGeneratePreviewWithTransitions.

/**
     * To test the performance of generatePreview : with Transitions
     *
     * @throws Exception
     */
@LargeTest
public void testPerformanceGeneratePreviewWithTransitions() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
    final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
    long averageTime = 0;
    final String[] loggingInfo = new String[1];
    final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor, "mediaItem1", videoItemFileName, renderingMode);
    mediaVideoItem.setExtractBoundaries(0, 10000);
    mVideoEditor.addMediaItem(mediaVideoItem);
    final MediaImageItem mediaImageItem = new MediaImageItem(mVideoEditor, "mediaItem2", imageItemFileName, 10000, renderingMode);
    mVideoEditor.addMediaItem(mediaImageItem);
    final TransitionCrossfade transitionCrossFade = new TransitionCrossfade("transitionCrossFade", mediaVideoItem, mediaImageItem, 5000, transitionBehavior);
    mVideoEditor.addTransition(transitionCrossFade);
    for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
        final long duration1 = SystemClock.uptimeMillis();
        mVideoEditor.generatePreview(new MediaProcessingProgressListener() {

            public void onProgress(Object item, int action, int progress) {
            }
        });
        final long duration2 = SystemClock.uptimeMillis();
        mVideoEditor.removeTransition(transitionCrossFade.getId());
        mVideoEditor.addTransition(transitionCrossFade);
        averageTime += (duration2 - duration1);
    }
    final long durationToAddObjects = averageTime;
    final float timeTaken = (float) durationToAddObjects * 1.0f / (float) NUM_OF_ITERATIONS;
    loggingInfo[0] = "Time taken to Generate Preview with transition :" + timeTaken;
    writeTimingInfo("testPerformanceGeneratePreviewWithTransitions:", loggingInfo);
}
Also used : MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaProcessingProgressListener(android.media.videoeditor.VideoEditor.MediaProcessingProgressListener) MediaImageItem(android.media.videoeditor.MediaImageItem) TransitionCrossfade(android.media.videoeditor.TransitionCrossfade) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 17 with MediaImageItem

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

the class VideoEditorStressTest method testStressAddRemoveTransition.

/**
     * To stress test transition
     *
     * @throws Exception
     */
@LargeTest
public void testStressAddRemoveTransition() throws Exception {
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final String VideoItemFileName1 = INPUT_FILE_PATH + "H264_BP_800x480_15fps_512kbps_1_17.mp4";
    final String ImageItemFileName2 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
    final String VideoItemFileName3 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
    final String maskFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
    final String[] loggingInfo = new String[1];
    int i = 0;
    writeTestCaseHeader("testStressAddRemoveTransition");
    getBeginMemory();
    for (i = 0; i < 50; i++) {
        if (i % 4 == 0) {
            final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, "m1" + i, VideoItemFileName1, renderingMode);
            mVideoEditor.addMediaItem(mediaItem1);
            mediaItem1.setExtractBoundaries(0, 10000);
            final TransitionCrossfade tranCrossfade = new TransitionCrossfade("transCF" + i, null, mediaItem1, 5000, Transition.BEHAVIOR_MIDDLE_FAST);
            mVideoEditor.addTransition(tranCrossfade);
        }
        if (i % 4 == 1) {
            final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, "m1" + i, VideoItemFileName1, renderingMode);
            mVideoEditor.addMediaItem(mediaItem1);
            mediaItem1.setExtractBoundaries(0, 10000);
            final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, "m2" + i, ImageItemFileName2, 10000, renderingMode);
            mVideoEditor.addMediaItem(mediaItem2);
            final TransitionAlpha transitionAlpha = mVideoEditorHelper.createTAlpha("transAlpha" + i, mediaItem1, mediaItem2, 5000, Transition.BEHAVIOR_SPEED_UP, maskFilename, 10, false);
            transitionAlpha.setDuration(4000);
            mVideoEditor.addTransition(transitionAlpha);
        }
        if (i % 4 == 2) {
            final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, "m2" + i, ImageItemFileName2, 10000, renderingMode);
            mVideoEditor.addMediaItem(mediaItem2);
            final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor, "m3" + i, VideoItemFileName3, renderingMode);
            mVideoEditor.addMediaItem(mediaItem3);
            mediaItem3.setExtractBoundaries(0, 10000);
            final TransitionAlpha transitionAlpha = mVideoEditorHelper.createTAlpha("transAlpha" + i, mediaItem2, mediaItem3, 5000, Transition.BEHAVIOR_SPEED_UP, maskFilename, 10, false);
            transitionAlpha.setDuration(4000);
            mVideoEditor.addTransition(transitionAlpha);
            mediaItem3.setExtractBoundaries(0, 6000);
            final TransitionSliding transition2And3 = mVideoEditorHelper.createTSliding("transSlide" + i, mediaItem2, mediaItem3, 3000, Transition.BEHAVIOR_MIDDLE_FAST, TransitionSliding.DIRECTION_LEFT_OUT_RIGHT_IN);
            mVideoEditor.addTransition(transition2And3);
        }
        if (i % 4 == 3) {
            final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor, "m3" + i, VideoItemFileName3, renderingMode);
            mVideoEditor.addMediaItem(mediaItem3);
            mediaItem3.setExtractBoundaries(0, 5000);
            final TransitionFadeBlack transition3 = mVideoEditorHelper.createTFadeBlack("transFB" + i, mediaItem3, null, 2500, Transition.BEHAVIOR_SPEED_UP);
            transition3.setDuration(500);
            mVideoEditor.addTransition(transition3);
        }
        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 % 4 == 0) {
            mVideoEditor.removeTransition("transCF" + i);
            mVideoEditor.removeMediaItem("m1" + i);
        }
        if (i % 4 == 1) {
            mVideoEditor.removeTransition("transAlpha" + i);
            mVideoEditor.removeMediaItem("m1" + i);
            mVideoEditor.removeMediaItem("m2" + i);
        }
        if (i % 4 == 2) {
            mVideoEditor.removeTransition("transSlide" + i);
            mVideoEditor.removeMediaItem("m2" + i);
            mVideoEditor.removeMediaItem("m3" + i);
        }
        if (i % 4 == 3) {
            mVideoEditor.removeMediaItem("m3" + i);
        }
        if (i % 10 == 0) {
            getAfterMemory_updateLog(loggingInfo, true, i);
        }
    }
    getAfterMemory_updateLog(loggingInfo, true, i);
}
Also used : TransitionFadeBlack(android.media.videoeditor.TransitionFadeBlack) TransitionSliding(android.media.videoeditor.TransitionSliding) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaImageItem(android.media.videoeditor.MediaImageItem) TransitionCrossfade(android.media.videoeditor.TransitionCrossfade) TransitionAlpha(android.media.videoeditor.TransitionAlpha) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 18 with MediaImageItem

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

the class VideoEditorStressTest method testStressAddRemoveOverlay.

/**
     * To stress test overlay
     *
     * @throws Exception
     */
@LargeTest
public void testStressAddRemoveOverlay() throws Exception {
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final String VideoItemFileName1 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
    final String ImageItemFileName2 = INPUT_FILE_PATH + "IMG_640x480.jpg";
    final String OverlayFile3 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    final String OverlayFile4 = INPUT_FILE_PATH + "IMG_640x480_Overlay2.png";
    final String[] loggingInfo = new String[1];
    int i = 0;
    final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, "m1", VideoItemFileName1, renderingMode);
    mVideoEditor.addMediaItem(mediaItem1);
    final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, "m2", ImageItemFileName2, 10000, renderingMode);
    mVideoEditor.addMediaItem(mediaItem2);
    writeTestCaseHeader("testStressAddRemoveOverlay");
    getBeginMemory();
    for (i = 0; i < 50; i++) {
        if (i % 3 == 0) {
            mediaItem1.setExtractBoundaries(0, 10000);
            final Bitmap mBitmap = mVideoEditorHelper.getBitmap(OverlayFile3, 640, 480);
            final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaItem1, "overlay" + i, mBitmap, 1000, 5000);
            mediaItem1.addOverlay(overlayFrame);
            mediaItem1.removeOverlay("overlay" + i);
        }
        if (i % 3 == 1) {
            final Bitmap mBitmap = mVideoEditorHelper.getBitmap(OverlayFile4, 640, 480);
            final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaItem2, "overlay" + i, mBitmap, 1000, 5000);
            mediaItem2.addOverlay(overlayFrame);
            mediaItem2.removeOverlay("overlay" + i);
        }
        if (i % 3 == 2) {
            mediaItem1.setExtractBoundaries(0, 10000);
            final Bitmap mBitmap = mVideoEditorHelper.getBitmap(OverlayFile4, 640, 480);
            final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaItem1, "overlay" + i, mBitmap, 0, mediaItem1.getDuration());
            mediaItem1.addOverlay(overlayFrame);
            mediaItem1.removeOverlay("overlay" + i);
        }
        if (i % 10 == 0) {
            getAfterMemory_updateLog(loggingInfo, false, i);
        }
    }
    getAfterMemory_updateLog(loggingInfo, false, i);
}
Also used : Bitmap(android.graphics.Bitmap) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaImageItem(android.media.videoeditor.MediaImageItem) OverlayFrame(android.media.videoeditor.OverlayFrame) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 19 with MediaImageItem

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

Example 20 with MediaImageItem

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

the class VideoEditorStressTest method testStressOverlayTransKenBurn.

/**
     * To stress test Media Item,Overlays,Transitions and Ken Burn
     *
     * @throws Exception
     */
@LargeTest
public void testStressOverlayTransKenBurn() throws Exception {
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final String VideoItemFileName1 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
    final String ImageItemFileName2 = INPUT_FILE_PATH + "IMG_640x480.jpg";
    final String OverlayFile3 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    final String audioFilename4 = INPUT_FILE_PATH + "AACLC_44.1kHz_256kbps_s_1_17.mp4";
    int i = 0;
    final String[] loggingInfo = new String[1];
    writeTestCaseHeader("testStressOverlayTransKenBurn");
    getBeginMemory();
    for (i = 0; i < 10; i++) {
        final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, "m1" + i, VideoItemFileName1, renderingMode);
        mVideoEditor.addMediaItem(mediaItem1);
        mediaItem1.setExtractBoundaries(0, 10000);
        final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, "m2" + i, ImageItemFileName2, 10000, renderingMode);
        mVideoEditor.addMediaItem(mediaItem2);
        final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(mediaItem1, "effect1" + i, (mediaItem1.getDuration() - 4000), 4000, EffectColor.TYPE_SEPIA, 0);
        mediaItem1.addEffect(effectColor1);
        final TransitionCrossfade tranCrossfade = new TransitionCrossfade("transCF" + i, mediaItem1, mediaItem2, 4000, Transition.BEHAVIOR_MIDDLE_FAST);
        mVideoEditor.addTransition(tranCrossfade);
        final Bitmap mBitmap = mVideoEditorHelper.getBitmap(OverlayFile3, 640, 480);
        final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaItem1, "overlay" + i, mBitmap, 1000, 5000);
        mediaItem1.addOverlay(overlayFrame);
        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 == 5) {
            final AudioTrack audioTrack1 = new AudioTrack(mVideoEditor, "Audio Track1", audioFilename4);
            mVideoEditor.addAudioTrack(audioTrack1);
        }
        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++) {
        MediaImageItem m2 = (MediaImageItem) mVideoEditor.getMediaItem("m2" + i);
        MediaVideoItem m1 = (MediaVideoItem) mVideoEditor.getMediaItem("m1" + i);
        m2.removeEffect("KBOnM2" + i);
        m1.removeOverlay("overlay" + i);
        mVideoEditor.removeTransition("transCF" + i);
        m1.removeEffect("effect1" + i);
        mVideoEditor.removeMediaItem("m2" + i);
        mVideoEditor.removeMediaItem("m1" + i);
        if (i == 5) {
            mVideoEditor.removeAudioTrack("Audio Track1");
        }
        getAfterMemory_updateLog(loggingInfo, true, i);
    }
    getAfterMemory_updateLog(loggingInfo, true, i);
}
Also used : Bitmap(android.graphics.Bitmap) Rect(android.graphics.Rect) 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) AudioTrack(android.media.videoeditor.AudioTrack) TransitionCrossfade(android.media.videoeditor.TransitionCrossfade) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

MediaImageItem (android.media.videoeditor.MediaImageItem)59 LargeTest (android.test.suitebuilder.annotation.LargeTest)49 MediaVideoItem (android.media.videoeditor.MediaVideoItem)28 Bitmap (android.graphics.Bitmap)14 TransitionCrossfade (android.media.videoeditor.TransitionCrossfade)12 MediaProcessingProgressListener (android.media.videoeditor.VideoEditor.MediaProcessingProgressListener)12 MediaItem (android.media.videoeditor.MediaItem)11 VideoEditor (android.media.videoeditor.VideoEditor)11 Rect (android.graphics.Rect)10 AudioTrack (android.media.videoeditor.AudioTrack)10 EffectColor (android.media.videoeditor.EffectColor)10 OverlayFrame (android.media.videoeditor.OverlayFrame)9 TransitionAlpha (android.media.videoeditor.TransitionAlpha)9 EffectKenBurns (android.media.videoeditor.EffectKenBurns)8 ExportProgressListener (android.media.videoeditor.VideoEditor.ExportProgressListener)8 TransitionFadeBlack (android.media.videoeditor.TransitionFadeBlack)6 TransitionSliding (android.media.videoeditor.TransitionSliding)6 File (java.io.File)5 IOException (java.io.IOException)5 OverlayData (android.media.videoeditor.VideoEditor.OverlayData)3