Search in sources :

Example 6 with TransitionFadeBlack

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

the class VideoEditorExportTest method testExportTransition.

/**
     *To Test export : With Transition on Different Media Items
     */
@LargeTest
public void testExportTransition() 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_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
    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 maskFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
    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 MediaVideoItem mediaItem4 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaItem4);
    mediaItem4.setExtractBoundaries(0, 8000);
    final TransitionCrossfade transition3And4 = mVideoEditorHelper.createTCrossFade("transition3", mediaItem3, mediaItem4, 3500, Transition.BEHAVIOR_MIDDLE_SLOW);
    mVideoEditor.addTransition(transition3And4);
    final MediaImageItem mediaItem5 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", imageItemFilename2, 7000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaItem5);
    final TransitionFadeBlack transition4And5 = mVideoEditorHelper.createTFadeBlack("transition4", mediaItem4, mediaItem5, 3500, Transition.BEHAVIOR_SPEED_DOWN);
    mVideoEditor.addTransition(transition4And5);
    final MediaImageItem mediaItem6 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", imageItemFilename3, 3000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaItem6);
    final TransitionSliding transition5And6 = mVideoEditorHelper.createTSliding("transition5", mediaItem5, mediaItem6, 1000, /*4000*/
    Transition.BEHAVIOR_SPEED_UP, TransitionSliding.DIRECTION_LEFT_OUT_RIGHT_IN);
    mVideoEditor.addTransition(transition5And6);
    final TransitionSliding transition6 = mVideoEditorHelper.createTSliding("transition6", mediaItem6, null, 1000, /*4000*/
    Transition.BEHAVIOR_SPEED_UP, TransitionSliding.DIRECTION_TOP_OUT_BOTTOM_IN);
    mVideoEditor.addTransition(transition6);
    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 = mediaItem1.getTimelineDuration() + mediaItem2.getTimelineDuration() + mediaItem3.getTimelineDuration() - transition2And3.getDuration() + mediaItem4.getTimelineDuration() - transition3And4.getDuration() + mediaItem5.getTimelineDuration() - transition4And5.getDuration() + mediaItem6.getTimelineDuration() - transition5And6.getDuration();
    mVideoEditorHelper.validateExport(mVideoEditor, outFilename, MediaProperties.HEIGHT_720, 0, storyBoardDuration, MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
    mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
Also used : VideoEditor(android.media.videoeditor.VideoEditor) ExportProgressListener(android.media.videoeditor.VideoEditor.ExportProgressListener) TransitionFadeBlack(android.media.videoeditor.TransitionFadeBlack) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaProcessingProgressListener(android.media.videoeditor.VideoEditor.MediaProcessingProgressListener) MediaImageItem(android.media.videoeditor.MediaImageItem) TransitionCrossfade(android.media.videoeditor.TransitionCrossfade) TransitionAlpha(android.media.videoeditor.TransitionAlpha) TransitionSliding(android.media.videoeditor.TransitionSliding) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 7 with TransitionFadeBlack

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

the class VideoEditorAPITest method testMediaImageItemTransitions.

/**
     * To Test the Media Image API : Get Before and after transition
     */
@LargeTest
public void testMediaImageItemTransitions() 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);
    assertNull("Begin Transition", mediaImageItem1.getBeginTransition());
    assertNull("End Transition", mediaImageItem1.getEndTransition());
    TransitionFadeBlack transition1 = mVideoEditorHelper.createTFadeBlack("transition1", mediaImageItem1, null, 0, Transition.BEHAVIOR_SPEED_UP);
    mVideoEditor.addTransition(transition1);
    assertEquals("Begin transition", transition1, mediaImageItem1.getEndTransition());
    assertNotNull("End Transition", mediaImageItem1.getEndTransition());
    assertTrue(mediaImageItem1.getEndTransition().getId().equals(transition1.getId()));
    assertTrue(mediaImageItem1.getEndTransition().getDuration() == transition1.getDuration() ? true : false);
    assertTrue(mediaImageItem1.getEndTransition().getBehavior() == transition1.getBehavior() ? true : false);
    TransitionFadeBlack transition2 = mVideoEditorHelper.createTFadeBlack("transition2", null, mediaImageItem1, 0, Transition.BEHAVIOR_SPEED_UP);
    mVideoEditor.addTransition(transition2);
    assertNotNull("Begin transition", mediaImageItem1.getBeginTransition());
    assertEquals("End Transition", transition2, mediaImageItem1.getBeginTransition());
    assertTrue(mediaImageItem1.getBeginTransition().getId().equals(transition2.getId()));
    assertTrue(mediaImageItem1.getBeginTransition().getDuration() == transition2.getDuration() ? true : false);
    assertTrue(mediaImageItem1.getBeginTransition().getBehavior() == transition2.getBehavior() ? true : false);
}
Also used : TransitionFadeBlack(android.media.videoeditor.TransitionFadeBlack) MediaImageItem(android.media.videoeditor.MediaImageItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 8 with TransitionFadeBlack

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

the class VideoEditorAPITest method testMediaVideoItemTransitions.

/**
     * To Test the Media Video API : Get Before and after transition
     */
@LargeTest
public void testMediaVideoItemTransitions() 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);
    assertNull("Begin Transition", mediaVideoItem1.getBeginTransition());
    assertNull("End Transition", mediaVideoItem1.getEndTransition());
    TransitionFadeBlack transition1 = mVideoEditorHelper.createTFadeBlack("transition1", mediaVideoItem1, null, 0, Transition.BEHAVIOR_SPEED_UP);
    mVideoEditor.addTransition(transition1);
    assertEquals("Begin transition", transition1, mediaVideoItem1.getEndTransition());
    assertNotNull("End Transition", mediaVideoItem1.getEndTransition());
    assertTrue(mediaVideoItem1.getEndTransition().getId().equals(transition1.getId()));
    assertTrue(mediaVideoItem1.getEndTransition().getDuration() == transition1.getDuration() ? true : false);
    assertTrue(mediaVideoItem1.getEndTransition().getBehavior() == transition1.getBehavior() ? true : false);
    TransitionFadeBlack transition2 = mVideoEditorHelper.createTFadeBlack("transition2", null, mediaVideoItem1, 0, Transition.BEHAVIOR_LINEAR);
    mVideoEditor.addTransition(transition2);
    assertNotNull("Begin transition", mediaVideoItem1.getBeginTransition());
    assertEquals("End Transition", transition2, mediaVideoItem1.getBeginTransition());
    assertTrue(mediaVideoItem1.getBeginTransition().getId().equals(transition2.getId()));
    assertTrue(mediaVideoItem1.getBeginTransition().getDuration() == transition2.getDuration() ? true : false);
    assertTrue(mediaVideoItem1.getBeginTransition().getBehavior() == transition2.getBehavior() ? true : false);
}
Also used : TransitionFadeBlack(android.media.videoeditor.TransitionFadeBlack) MediaVideoItem(android.media.videoeditor.MediaVideoItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

TransitionFadeBlack (android.media.videoeditor.TransitionFadeBlack)8 LargeTest (android.test.suitebuilder.annotation.LargeTest)7 MediaImageItem (android.media.videoeditor.MediaImageItem)6 MediaVideoItem (android.media.videoeditor.MediaVideoItem)6 TransitionAlpha (android.media.videoeditor.TransitionAlpha)4 TransitionCrossfade (android.media.videoeditor.TransitionCrossfade)4 TransitionSliding (android.media.videoeditor.TransitionSliding)4 VideoEditor (android.media.videoeditor.VideoEditor)3 ExportProgressListener (android.media.videoeditor.VideoEditor.ExportProgressListener)2 MediaProcessingProgressListener (android.media.videoeditor.VideoEditor.MediaProcessingProgressListener)2 Bitmap (android.graphics.Bitmap)1 Rect (android.graphics.Rect)1 AudioTrack (android.media.videoeditor.AudioTrack)1 EffectColor (android.media.videoeditor.EffectColor)1 EffectKenBurns (android.media.videoeditor.EffectKenBurns)1 OverlayFrame (android.media.videoeditor.OverlayFrame)1 Transition (android.media.videoeditor.Transition)1 OverlayData (android.media.videoeditor.VideoEditor.OverlayData)1 PreviewProgressListener (android.media.videoeditor.VideoEditor.PreviewProgressListener)1 SurfaceHolder (android.view.SurfaceHolder)1