Search in sources :

Example 26 with MediaImageItem

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

the class VideoEditorAPITest method testMediaImageItemRenderingModes.

/**
     * To Test the Media Image API : Get and Set rendering Mode
     */
@LargeTest
public void testMediaImageItemRenderingModes() throws Exception {
    final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
    final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    boolean flagForException = false;
    final MediaImageItem mediaImageItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", imageItemFileName, imageItemRenderingMode, 5000);
    mVideoEditor.addMediaItem(mediaImageItem1);
    mediaImageItem1.setRenderingMode(MediaItem.RENDERING_MODE_CROPPING);
    assertEquals("MediaVideo Item rendering Mode", MediaItem.RENDERING_MODE_CROPPING, mediaImageItem1.getRenderingMode());
    try {
        mediaImageItem1.setRenderingMode(MediaItem.RENDERING_MODE_CROPPING + 911);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Media Item Invalid rendering Mode", flagForException);
    flagForException = false;
    try {
        mediaImageItem1.setRenderingMode(MediaItem.RENDERING_MODE_BLACK_BORDER - 11);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Media Item Invalid rendering Mode", flagForException);
    assertEquals("MediaVideo Item rendering Mode", MediaItem.RENDERING_MODE_CROPPING, mediaImageItem1.getRenderingMode());
    mediaImageItem1.setRenderingMode(MediaItem.RENDERING_MODE_STRETCH);
    assertEquals("MediaVideo Item rendering Mode", MediaItem.RENDERING_MODE_STRETCH, mediaImageItem1.getRenderingMode());
}
Also used : MediaImageItem(android.media.videoeditor.MediaImageItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 27 with MediaImageItem

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

the class VideoEditorAPITest method testTransitionSliding.

/**
     * To test Transition : Sliding with all behavior
     * SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST and Direction =
     * DIRECTION_RIGHT_OUT_LEFT_IN
     * ,DIRECTION_LEFT_OUT_RIGHT_IN,DIRECTION_TOP_OUT_BOTTOM_IN
     * ,DIRECTION_BOTTOM_OUT_TOP_IN
     */
@LargeTest
public void testTransitionSliding() throws Exception {
    final String videoItemFilename1 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
    final String videoItemFilename2 = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_128kbps_1_35.3gp";
    final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
    final String videoItemFilename3 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_192kbps_1_5.mp4";
    final String videoItemFilename4 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_256kbps_0_30.mp4";
    final String videoItemFilename5 = INPUT_FILE_PATH + "H263_profile0_176x144_10fps_96kbps_0_25.3gp";
    boolean flagForException = false;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem1.setExtractBoundaries(0, 15000);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    final MediaVideoItem mediaVideoItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem2.setExtractBoundaries(0, 15000);
    mVideoEditor.addMediaItem(mediaVideoItem2);
    final TransitionSliding transition1And2 = mVideoEditorHelper.createTSliding("transition1And2", mediaVideoItem1, mediaVideoItem2, 3000, Transition.BEHAVIOR_SPEED_UP, TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN);
    mVideoEditor.addTransition(transition1And2);
    assertTrue("Transition ID", transition1And2.getId().equals("transition1And2"));
    assertEquals("Transtion After Media item", mediaVideoItem1, transition1And2.getAfterMediaItem());
    assertEquals("Transtion Before Media item", mediaVideoItem2, transition1And2.getBeforeMediaItem());
    assertEquals("Transtion Duration", 3000, transition1And2.getDuration());
    assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_UP, transition1And2.getBehavior());
    assertEquals("Transition Sliding", TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN, transition1And2.getDirection());
    final MediaImageItem mediaImageItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaImageItem3);
    final TransitionSliding transition2And3 = mVideoEditorHelper.createTSliding("transition2And3", mediaVideoItem2, mediaImageItem3, 1000, Transition.BEHAVIOR_SPEED_DOWN, TransitionSliding.DIRECTION_LEFT_OUT_RIGHT_IN);
    mVideoEditor.addTransition(transition2And3);
    assertTrue("Transition ID", transition2And3.getId().equals("transition2And3"));
    assertEquals("Transtion After Media item", mediaVideoItem2, transition2And3.getAfterMediaItem());
    assertEquals("Transtion Before Media item", mediaImageItem3, transition2And3.getBeforeMediaItem());
    assertEquals("Transtion Duration", 1000, transition2And3.getDuration());
    assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_DOWN, transition2And3.getBehavior());
    assertEquals("Transition Sliding", TransitionSliding.DIRECTION_LEFT_OUT_RIGHT_IN, transition2And3.getDirection());
    final MediaVideoItem mediaVideoItem4 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem4.setExtractBoundaries(0, 18000);
    mVideoEditor.addMediaItem(mediaVideoItem4);
    final TransitionSliding transition3And4 = mVideoEditorHelper.createTSliding("transition3And4", mediaImageItem3, mediaVideoItem4, 5000, Transition.BEHAVIOR_LINEAR, TransitionSliding.DIRECTION_TOP_OUT_BOTTOM_IN);
    mVideoEditor.addTransition(transition3And4);
    assertTrue("Transition ID", transition3And4.getId().equals("transition3And4"));
    assertEquals("Transtion After Media item", mediaImageItem3, transition3And4.getAfterMediaItem());
    assertEquals("Transtion Before Media item", mediaVideoItem4, transition3And4.getBeforeMediaItem());
    assertEquals("Transtion Duration", 5000, transition3And4.getDuration());
    assertEquals("Transtion Behavior", Transition.BEHAVIOR_LINEAR, transition3And4.getBehavior());
    assertEquals("Transition Sliding", TransitionSliding.DIRECTION_TOP_OUT_BOTTOM_IN, transition3And4.getDirection());
    final MediaVideoItem mediaVideoItem5 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", videoItemFilename4, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaVideoItem5);
    final TransitionSliding transition4And5 = mVideoEditorHelper.createTSliding("transition4And5", mediaVideoItem4, mediaVideoItem5, 8000, Transition.BEHAVIOR_MIDDLE_FAST, TransitionSliding.DIRECTION_BOTTOM_OUT_TOP_IN);
    mVideoEditor.addTransition(transition4And5);
    assertTrue("Transition ID", transition4And5.getId().equals("transition4And5"));
    assertEquals("Transtion After Media item", mediaVideoItem4, transition4And5.getAfterMediaItem());
    assertEquals("Transtion Before Media item", mediaVideoItem5, transition4And5.getBeforeMediaItem());
    assertEquals("Transtion Duration", 8000, transition4And5.getDuration());
    assertEquals("Transtion Behavior", Transition.BEHAVIOR_MIDDLE_FAST, transition4And5.getBehavior());
    assertEquals("Transition Sliding", TransitionSliding.DIRECTION_BOTTOM_OUT_TOP_IN, transition4And5.getDirection());
    final MediaVideoItem mediaVideoItem6 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", videoItemFilename5, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem6.setExtractBoundaries(0, 20000);
    mVideoEditor.addMediaItem(mediaVideoItem6);
    final TransitionSliding transition5And6 = mVideoEditorHelper.createTSliding("transition5And6", mediaVideoItem5, mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_SLOW, TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN);
    mVideoEditor.addTransition(transition5And6);
    assertTrue("Transition ID", transition5And6.getId().equals("transition5And6"));
    assertEquals("Transtion After Media item", mediaVideoItem5, transition5And6.getAfterMediaItem());
    assertEquals("Transtion Before Media item", mediaVideoItem6, transition5And6.getBeforeMediaItem());
    assertEquals("Transtion Duration", 2000, transition5And6.getDuration());
    assertEquals("Transtion Behavior", Transition.BEHAVIOR_MIDDLE_SLOW, transition5And6.getBehavior());
    assertEquals("Transition Sliding", TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN, transition5And6.getDirection());
    flagForException = false;
    try {
        mVideoEditorHelper.createTSliding("transitiond6", mediaVideoItem5, mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_SLOW, TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN - 1);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Transition Sliding with Invalid Direction", flagForException);
    flagForException = false;
    try {
        mVideoEditorHelper.createTSliding("transitiond6", mediaVideoItem5, mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_FAST + 1, TransitionSliding.DIRECTION_BOTTOM_OUT_TOP_IN + 1);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Transition Sliding with Invalid behavior", flagForException);
    flagForException = false;
    try {
        mVideoEditorHelper.createTSliding("transitiond6", mediaVideoItem5, mediaVideoItem6, 2000, Transition.BEHAVIOR_SPEED_UP - 1, TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Transition Sliding with Invalid behavior", flagForException);
    flagForException = false;
    try {
        mVideoEditorHelper.createTSliding("transitiond6", mediaVideoItem5, mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_FAST + 1, TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Transition Sliding with Invalid behavior", flagForException);
}
Also used : TransitionSliding(android.media.videoeditor.TransitionSliding) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaImageItem(android.media.videoeditor.MediaImageItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 28 with MediaImageItem

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

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

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

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