Search in sources :

Example 1 with ExportProgressListener

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

the class VideoEditorPerformance method testPerformanceExport.

/**
     * To test performance of Export
     *
     * @throws Exception
     */
@LargeTest
public void testPerformanceExport() throws Exception {
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final int outHeight = MediaProperties.HEIGHT_480;
    final int outBitrate = MediaProperties.BITRATE_256K;
    final int outVcodec = MediaProperties.VCODEC_H264;
    final String[] loggingInfo = new String[1];
    final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
    final String videoItemFileName1 = INPUT_FILE_PATH + "H264_BP_1080x720_30fps_12Mbps_AACLC_44.1khz_64kbps_s_1_17.mp4";
    final String imageItemFileName1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
    final String videoItemFileName2 = INPUT_FILE_PATH + "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_32kbps_m_1_17.3gp";
    final String imageItemFileName2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
    final String videoItemFileName3 = INPUT_FILE_PATH + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_161kbps_s_0_26.mp4";
    final String overlayFile = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    final String audioTrackFilename = INPUT_FILE_PATH + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
    final String maskFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
    final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, "m1", videoItemFileName1, renderingMode);
    mediaItem1.setExtractBoundaries(0, 20000);
    mVideoEditor.addMediaItem(mediaItem1);
    final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, "m2", imageItemFileName1, 10000, renderingMode);
    mVideoEditor.addMediaItem(mediaItem2);
    final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor, "m3", videoItemFileName2, renderingMode);
    mediaItem3.setExtractBoundaries(0, 20000);
    mVideoEditor.addMediaItem(mediaItem3);
    final MediaImageItem mediaItem4 = new MediaImageItem(mVideoEditor, "m4", imageItemFileName2, 10000, renderingMode);
    mVideoEditor.addMediaItem(mediaItem4);
    final MediaVideoItem mediaItem5 = new MediaVideoItem(mVideoEditor, "m5", videoItemFileName3, renderingMode);
    mediaItem5.setExtractBoundaries(0, 20000);
    mVideoEditor.addMediaItem(mediaItem5);
    /**
         * 7.Add TransitionAlpha, Apply this  Transition as Begin for Media Item 1
         *  with duration = 2 sec behavior = BEHAVIOR_LINEAR, mask file name =
         * TransitionSpiral_QVGA.jpg , blending percent = 50%, invert = true;
         * */
    final TransitionAlpha transition1 = mVideoEditorHelper.createTAlpha("transition1", null, mediaItem1, 2000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, true);
    mVideoEditor.addTransition(transition1);
    /**
         * 8.Add Transition Sliding between MediaItem 2 and 3 ,
         *  Sliding Direction  = DIRECTION_RIGHT_OUT_LEFT_IN,
         *  behavior  = BEHAVIOR_MIDDLE_FAST and duration = 4sec
         * */
    final TransitionSliding transition2And3 = mVideoEditorHelper.createTSliding("transition2", mediaItem2, mediaItem3, 4000, Transition.BEHAVIOR_MIDDLE_FAST, TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN);
    mVideoEditor.addTransition(transition2And3);
    /**
         * 9.Add Transition Crossfade between  Media Item 3 and 4,
         *  behavior = BEHAVIOR_MIDDLE_SLOW, duration = 3.5 sec
         * */
    final TransitionCrossfade transition3And4 = mVideoEditorHelper.createTCrossFade("transition3", mediaItem3, mediaItem4, 3500, Transition.BEHAVIOR_MIDDLE_SLOW);
    mVideoEditor.addTransition(transition3And4);
    /**
         * 10.Add Transition Fadeblack between  Media Item 4 and 5,
         *  behavior = BEHAVIOR_SPEED_DOWN, duration = 3.5 sec
         * */
    final TransitionFadeBlack transition4And5 = mVideoEditorHelper.createTFadeBlack("transition4", mediaItem4, mediaItem5, 3500, Transition.BEHAVIOR_SPEED_DOWN);
    mVideoEditor.addTransition(transition4And5);
    /**
         * 11.Add Effect 1 type="TYPE_SEPIA" to the MediaItem 1,
         *  start time=1sec and duration =4secs
         * */
    final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(mediaItem1, "effect1", 1000, 4000, EffectColor.TYPE_SEPIA, 0);
    mediaItem1.addEffect(effectColor1);
    /**
         * 12.Add Overlay 1  to the MediaItem 3: Frame Overlay with start time = 1 sec
         * duration = 4 sec with item  = IMG_640x480_Overlay1.png
         * */
    final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile, 640, 480);
    final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaItem3, "overlay", mBitmap, 1000, 4000);
    mediaItem3.addOverlay(overlayFrame);
    /**
         * 13.Add Effect 2 type="TYPE_NEGATIVE" to the MediaItem 2,
         *  start time=8sec and duration =2secs
         * */
    final EffectColor effectColor2 = mVideoEditorHelper.createEffectItem(mediaItem2, "effect2", 8000, 2000, EffectColor.TYPE_NEGATIVE, 0);
    mediaItem2.addEffect(effectColor2);
    /**
         * 14.Add Effect 3 type="TYPE_COLOR" to the MediaItem 3, color param = "PINK",
         *  start time=5 sec and duration =3secs
         * */
    final EffectColor effectColor3 = mVideoEditorHelper.createEffectItem(mediaItem3, "effect3", 5000, 3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
    mediaItem3.addEffect(effectColor3);
    /**
         * 15.Add Effect 4 type="TYPE_FIFTIES" to the MediaItem 4,
         *  start time=2 sec and duration =1secs
        * */
    final EffectColor effectColor4 = mVideoEditorHelper.createEffectItem(mediaItem4, "effect4", 2000, 1000, EffectColor.TYPE_FIFTIES, 0);
    mediaItem4.addEffect(effectColor4);
    /**
         * 16.Add KenBurnsEffect for MediaItem 4 with
         *  duration = 3 sec and startTime = 4 sec
         *  StartRect
         *  left = org_height/3  ;  top = org_width/3
         *  bottom = org_width/2  ;  right = org_height/2
         *  EndRect
         *  left = 0  ;  top = 0
         *  bottom =  org_height;  right =  org_width
         * */
    final Rect startRect = new Rect((mediaItem4.getHeight() / 3), (mediaItem4.getWidth() / 3), (mediaItem4.getHeight() / 2), (mediaItem4.getWidth() / 2));
    final Rect endRect = new Rect(0, 0, mediaItem4.getWidth(), mediaItem4.getHeight());
    final EffectKenBurns kbEffectOnMediaItem = new EffectKenBurns(mediaItem4, "KBOnM2", startRect, endRect, 4000, 3000);
    mediaItem4.addEffect(kbEffectOnMediaItem);
    /** 17.Add Audio Track,Set extract boundaries o to 10 sec.
         * */
    final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "audioTrack", audioTrackFilename);
    mVideoEditor.addAudioTrack(audioTrack);
    /** 18.Enable Looping for Audio Track.
         * */
    audioTrack.enableLoop();
    int timeTaken = 0;
    final long beginTime = SystemClock.uptimeMillis();
    try {
        mVideoEditor.export(outFilename, outHeight, outBitrate, new ExportProgressListener() {

            public void onProgress(VideoEditor ve, String outFileName, int progress) {
            }
        });
    } catch (Exception e) {
        assertTrue("Error in Export" + e.toString(), false);
    }
    mVideoEditorHelper.checkDeleteExistingFile(outFilename);
    timeTaken = calculateTimeTaken(beginTime, 1);
    loggingInfo[0] = "Time taken to do ONE export of storyboard duration " + mVideoEditor.getDuration() + " is :" + timeTaken;
    writeTimingInfo("testPerformanceExport (in mSec)", loggingInfo);
    mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
}
Also used : Rect(android.graphics.Rect) VideoEditor(android.media.videoeditor.VideoEditor) EffectKenBurns(android.media.videoeditor.EffectKenBurns) ExportProgressListener(android.media.videoeditor.VideoEditor.ExportProgressListener) TransitionFadeBlack(android.media.videoeditor.TransitionFadeBlack) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaImageItem(android.media.videoeditor.MediaImageItem) OverlayFrame(android.media.videoeditor.OverlayFrame) TransitionCrossfade(android.media.videoeditor.TransitionCrossfade) TransitionAlpha(android.media.videoeditor.TransitionAlpha) Bitmap(android.graphics.Bitmap) EffectColor(android.media.videoeditor.EffectColor) TransitionSliding(android.media.videoeditor.TransitionSliding) AudioTrack(android.media.videoeditor.AudioTrack) File(java.io.File) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 2 with ExportProgressListener

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

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

the class VideoEditorExportTest method testExportTwoVideos.

/**
     * To Test Export :Two Media Items added
     *
     * @throws Exception
     */
@LargeTest
public void testExportTwoVideos() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp";
    final String videoItemFileName1 = INPUT_FILE_PATH + "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
    final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
    final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaVideoItem);
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    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.getDuration() + mediaVideoItem1.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) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 4 with ExportProgressListener

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

the class VideoEditorExportTest method testExportEffectOverlay.

/**
     *To Test export : With Effect and Overlays on Different Media Items
     */
@LargeTest
public void testExportEffectOverlay() 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_15fps_1200Kbps_AACLC_48KHz_64kps_m_0_27.3gp";
    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 overlayFile = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem1.setExtractBoundaries(2000, 7000);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    final EffectColor effectPink = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effectPink", 0, 2000, EffectColor.TYPE_COLOR, EffectColor.PINK);
    mediaVideoItem1.addEffect(effectPink);
    final EffectColor effectNegative = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effectNegative", 3000, 4000, EffectColor.TYPE_NEGATIVE, 0);
    mediaVideoItem1.addEffect(effectNegative);
    final MediaImageItem mediaImageItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFilename1, 3000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaImageItem2);
    final EffectColor effectFifties = mVideoEditorHelper.createEffectItem(mediaImageItem2, "effectFifties", 0, 3000, EffectColor.TYPE_FIFTIES, 0);
    mediaImageItem2.addEffect(effectFifties);
    final MediaVideoItem mediaVideoItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaVideoItem3);
    mediaVideoItem3.setExtractBoundaries(0, 8000);
    final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile, 640, 480);
    final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaVideoItem3, "overlay", mBitmap, 2000, 5000);
    mediaVideoItem3.addOverlay(overlayFrame);
    final EffectColor effectGreen = mVideoEditorHelper.createEffectItem(mediaVideoItem3, "effectGreen", 0, 2000, EffectColor.TYPE_COLOR, EffectColor.GREEN);
    mediaVideoItem3.addEffect(effectGreen);
    final MediaVideoItem mediaVideoItem4 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem4.setExtractBoundaries(mediaVideoItem4.getDuration() - 5000, mediaVideoItem4.getDuration());
    mVideoEditor.addMediaItem(mediaVideoItem4);
    final EffectColor effectSepia = mVideoEditorHelper.createEffectItem(mediaVideoItem4, "effectSepia", 0, 2000, EffectColor.TYPE_SEPIA, 0);
    mediaVideoItem4.addEffect(effectSepia);
    final MediaImageItem mediaImageItem5 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", imageItemFilename2, 4000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaImageItem5);
    final EffectColor effectGray = mVideoEditorHelper.createEffectItem(mediaImageItem5, "effectGray", 0, 2000, EffectColor.TYPE_COLOR, EffectColor.GRAY);
    mediaImageItem5.addEffect(effectGray);
    final MediaImageItem mediaImageItem6 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", imageItemFilename3, 2000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaImageItem6);
    final EffectColor effectGradient = mVideoEditorHelper.createEffectItem(mediaImageItem6, "effectGradient", 0, 2000, EffectColor.TYPE_GRADIENT, EffectColor.PINK);
    mediaImageItem6.addEffect(effectGradient);
    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 = mediaVideoItem1.getTimelineDuration() + mediaImageItem2.getDuration() + mediaVideoItem3.getTimelineDuration() + mediaVideoItem4.getTimelineDuration() + mediaImageItem5.getDuration() + mediaImageItem6.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) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaProcessingProgressListener(android.media.videoeditor.VideoEditor.MediaProcessingProgressListener) MediaImageItem(android.media.videoeditor.MediaImageItem) OverlayFrame(android.media.videoeditor.OverlayFrame) Bitmap(android.graphics.Bitmap) EffectColor(android.media.videoeditor.EffectColor) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 5 with ExportProgressListener

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

the class VideoEditorExportTest method testExportWithStorageFull.

/**
     * To Test Export : Storage location having very less space (Less than 100
     * KB)
     *
     * @throws Exception
     */
@LargeTest
public void testExportWithStorageFull() throws Exception {
    final String videoItemFilename1 = INPUT_FILE_PATH + "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
    final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
    boolean flagForException = false;
    mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    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) {
        flagForException = true;
    }
    assertTrue("Error in exporting file due to lack of storage space", flagForException);
}
Also used : VideoEditor(android.media.videoeditor.VideoEditor) ExportProgressListener(android.media.videoeditor.VideoEditor.ExportProgressListener) 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