Search in sources :

Example 6 with ExportProgressListener

use of android.media.videoeditor.VideoEditor.ExportProgressListener in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorExportTest method testExportMMS.

/**
     * To Test Export : With Video and Image : MMS use case
     *
     * @throws Exception
     */
@LargeTest
public void testExportMMS() 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_1600x1200.jpg";
    final String videoItemFilename2 = INPUT_FILE_PATH + "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
    final String maskFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
    final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
    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 TransitionCrossfade transition3 = mVideoEditorHelper.createTCrossFade("transition3", mediaItem3, null, 3500, Transition.BEHAVIOR_MIDDLE_SLOW);
    mVideoEditor.addTransition(transition3);
    final EffectColor effectColor = mVideoEditorHelper.createEffectItem(mediaItem2, "effect", 0, 3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
    mediaItem2.addEffect(effectColor);
    mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_11_9);
    try {
        final int[] progressUpdate = new int[100];
        mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144, 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();
    mVideoEditorHelper.validateExport(mVideoEditor, outFilename, MediaProperties.HEIGHT_144, 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) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaImageItem(android.media.videoeditor.MediaImageItem) TransitionCrossfade(android.media.videoeditor.TransitionCrossfade) TransitionAlpha(android.media.videoeditor.TransitionAlpha) EffectColor(android.media.videoeditor.EffectColor) TransitionSliding(android.media.videoeditor.TransitionSliding) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 7 with ExportProgressListener

use of android.media.videoeditor.VideoEditor.ExportProgressListener in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorExportTest method testExportAudio.

/**
     * To Test Export : With Video and Image and An Audio BackGround Track
     */
@LargeTest
public void testExportAudio() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
    final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
    final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
    final String audioTrackFilename = INPUT_FILE_PATH + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
    final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem.setExtractBoundaries(0, 10000);
    mVideoEditor.addMediaItem(mediaVideoItem);
    final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFileName, 5000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaImageItem);
    final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "a1", audioTrackFilename);
    audioTrack.setExtractBoundaries(2000, 5000);
    mVideoEditor.addAudioTrack(audioTrack);
    audioTrack.disableDucking();
    audioTrack.enableLoop();
    audioTrack.setVolume(75);
    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, (mediaVideoItem.getTimelineDuration() + mediaImageItem.getDuration()), MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
    mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
Also used : VideoEditor(android.media.videoeditor.VideoEditor) ExportProgressListener(android.media.videoeditor.VideoEditor.ExportProgressListener) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaProcessingProgressListener(android.media.videoeditor.VideoEditor.MediaProcessingProgressListener) MediaImageItem(android.media.videoeditor.MediaImageItem) AudioTrack(android.media.videoeditor.AudioTrack) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 8 with ExportProgressListener

use of android.media.videoeditor.VideoEditor.ExportProgressListener in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorStressTest method testStressMultipleExport.

/**
     * To stress test : Multiple Export
     *
     * @throws Exception
     */
@LargeTest
public void testStressMultipleExport() 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[] loggingInfo = new String[1];
    final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
    int i = 0;
    writeTestCaseHeader("testStressMultipleExport");
    getBeginMemory();
    final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, "m1", VideoItemFileName1, renderingMode);
    mVideoEditor.addMediaItem(mediaItem1);
    mediaItem1.setExtractBoundaries(0, 10000);
    final MediaVideoItem mediaItem2 = new MediaVideoItem(mVideoEditor, "m2", VideoItemFileName2, renderingMode);
    mVideoEditor.addMediaItem(mediaItem2);
    mediaItem2.setExtractBoundaries(0, 15000);
    for (i = 0; i < 50; i++) {
        if (i % 4 == 0) {
            final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9;
            mVideoEditor.setAspectRatio(aspectRatio);
            mVideoEditor.export(outFilename, MediaProperties.HEIGHT_288, MediaProperties.BITRATE_256K, MediaProperties.ACODEC_AAC_LC, MediaProperties.VCODEC_H263, new ExportProgressListener() {

                public void onProgress(VideoEditor ve, String outFileName, int progress) {
                }
            });
        }
        if (i % 4 == 1) {
            final int aspectRatio = MediaProperties.ASPECT_RATIO_5_3;
            mVideoEditor.setAspectRatio(aspectRatio);
            mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144, MediaProperties.BITRATE_384K, MediaProperties.ACODEC_AAC_LC, MediaProperties.VCODEC_MPEG4, new ExportProgressListener() {

                public void onProgress(VideoEditor ve, String outFileName, int progress) {
                }
            });
        }
        if (i % 4 == 2) {
            final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9;
            mVideoEditor.setAspectRatio(aspectRatio);
            mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144, MediaProperties.BITRATE_512K, MediaProperties.ACODEC_AAC_LC, MediaProperties.VCODEC_H264, new ExportProgressListener() {

                public void onProgress(VideoEditor ve, String outFileName, int progress) {
                }
            });
        }
        if (i % 4 == 3) {
            final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
            mVideoEditor.setAspectRatio(aspectRatio);
            mVideoEditor.export(outFilename, MediaProperties.HEIGHT_480, MediaProperties.BITRATE_800K, MediaProperties.ACODEC_AAC_LC, MediaProperties.VCODEC_H264, new ExportProgressListener() {

                public void onProgress(VideoEditor ve, String outFileName, int progress) {
                }
            });
        }
        if (i % 10 == 0) {
            getAfterMemory_updateLog(loggingInfo, false, i);
        }
    }
    getAfterMemory_updateLog(loggingInfo, false, i);
    /** Remove items and check for memory leak if any */
    mVideoEditor.removeMediaItem("m2");
    mVideoEditor.removeMediaItem("m1");
    getAfterMemory_updateLog(loggingInfo, true, i);
}
Also used : VideoEditor(android.media.videoeditor.VideoEditor) ExportProgressListener(android.media.videoeditor.VideoEditor.ExportProgressListener) MediaVideoItem(android.media.videoeditor.MediaVideoItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 9 with ExportProgressListener

use of android.media.videoeditor.VideoEditor.ExportProgressListener 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 10 with ExportProgressListener

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

Aggregations

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