Search in sources :

Example 51 with MediaVideoItem

use of android.media.videoeditor.MediaVideoItem 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 52 with MediaVideoItem

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

the class VideoEditorPreviewTest method testPreviewOfEffects.

/**
     * To test Preview : Preview of current Effects applied
     */
@LargeTest
public void testPreviewOfEffects() throws Exception {
    final String videoItemFileName1 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
    final Semaphore blockTillPreviewCompletes = new Semaphore(1);
    previewStart = false;
    previewStop = false;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    final EffectColor effectNegative = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effectNegative", 0, 2000, EffectColor.TYPE_NEGATIVE, 0);
    mediaVideoItem1.addEffect(effectNegative);
    final EffectColor effectGreen = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effectGreen", 2000, 3000, EffectColor.TYPE_COLOR, EffectColor.GREEN);
    mediaVideoItem1.addEffect(effectGreen);
    final EffectColor effectFifties = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effectFifties", 5000, 4000, EffectColor.TYPE_FIFTIES, 0);
    mediaVideoItem1.addEffect(effectFifties);
    List<Effect> effectList = mediaVideoItem1.getAllEffects();
    assertEquals("Effect List Size", 3, effectList.size());
    assertEquals("Effect negative", effectNegative, effectList.get(0));
    assertEquals("Effect Green", effectGreen, effectList.get(1));
    assertEquals("Effect Fifties", effectFifties, effectList.get(2));
    mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_4_3);
    assertEquals("Aspect Ratio", MediaProperties.ASPECT_RATIO_4_3, mVideoEditor.getAspectRatio());
    final long storyboardDuration = mVideoEditor.getDuration();
    validatePreviewProgress(0, (int) (storyboardDuration / 2), false, (storyboardDuration / 2));
    assertEquals("Removing Effect : Negative", effectNegative, mediaVideoItem1.removeEffect(effectNegative.getId()));
    effectList = mediaVideoItem1.getAllEffects();
    assertEquals("Effect List Size", 2, effectList.size());
    assertEquals("Effect Green", effectGreen, effectList.get(0));
    assertEquals("Effect Fifties", effectFifties, effectList.get(1));
    validatePreviewProgress(0, -1, false, mVideoEditor.getDuration());
}
Also used : EffectColor(android.media.videoeditor.EffectColor) MediaVideoItem(android.media.videoeditor.MediaVideoItem) Effect(android.media.videoeditor.Effect) Semaphore(java.util.concurrent.Semaphore) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 53 with MediaVideoItem

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

the class VideoEditorPreviewTest method testPreviewWithOverlay.

/**
     * To test Preview : Preview of current Overlay applied
     */
@LargeTest
public void testPreviewWithOverlay() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp";
    final String overlayFilename1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    final String overlayFilename2 = INPUT_FILE_PATH + "IMG_640x480_Overlay2.png";
    final int previewFrom = 5000;
    final int previewTo = 10000;
    final boolean previewLoop = false;
    final int previewCallbackFrameCount = 1;
    final int setAspectRatio = MediaProperties.ASPECT_RATIO_4_3;
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final Semaphore blockTillPreviewCompletes = new Semaphore(1);
    previewStart = false;
    previewStop = false;
    boolean flagForException = false;
    final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName, renderingMode);
    mVideoEditor.addMediaItem(mediaVideoItem);
    mediaVideoItem.setExtractBoundaries(0, 10000);
    final Bitmap mBitmap1 = mVideoEditorHelper.getBitmap(overlayFilename1, 640, 480);
    final OverlayFrame overlayOnMvi1 = mVideoEditorHelper.createOverlay(mediaVideoItem, "OverlayOnMvi1", mBitmap1, 0, 5000);
    mediaVideoItem.addOverlay(overlayOnMvi1);
    final Bitmap mBitmap2 = mVideoEditorHelper.getBitmap(overlayFilename2, 640, 480);
    final OverlayFrame overlayOnMvi2 = mVideoEditorHelper.createOverlay(mediaVideoItem, "OverlayOnMvi2", mBitmap2, 5000, 9000);
    mediaVideoItem.addOverlay(overlayOnMvi2);
    List<Overlay> overlayList = mediaVideoItem.getAllOverlays();
    assertEquals("Overlay Size", 2, overlayList.size());
    assertEquals("Overlay 1", overlayOnMvi1, overlayList.get(0));
    assertEquals("Overlay 2", overlayOnMvi2, overlayList.get(1));
    mVideoEditor.setAspectRatio(setAspectRatio);
    validatePreviewProgress(0, /* previewFrom */
    -1, previewLoop, mVideoEditor.getDuration());
}
Also used : Bitmap(android.graphics.Bitmap) MediaVideoItem(android.media.videoeditor.MediaVideoItem) OverlayFrame(android.media.videoeditor.OverlayFrame) Semaphore(java.util.concurrent.Semaphore) Overlay(android.media.videoeditor.Overlay) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 54 with MediaVideoItem

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

the class VideoEditorPreviewTest method testStartPreviewAddRemoveMediaItems.

/**
     * To Test Preview : Add Media and Remove Media Item (Without any Media
     * Items in the story Board)
     */
@LargeTest
public void testStartPreviewAddRemoveMediaItems() 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 alphaFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
    boolean flagForException = false;
    final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem.setExtractBoundaries(0, 15000);
    mVideoEditor.addMediaItem(mediaVideoItem);
    final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaImageItem);
    final TransitionAlpha transition1And2 = mVideoEditorHelper.createTAlpha("transition", mediaVideoItem, mediaImageItem, 3000, Transition.BEHAVIOR_SPEED_UP, alphaFilename, 10, false);
    mVideoEditor.addTransition(transition1And2);
    final EffectColor effectColor = mVideoEditorHelper.createEffectItem(mediaImageItem, "effect", 5000, 3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
    mediaImageItem.addEffect(effectColor);
    assertEquals("removing Media item 1", mediaVideoItem, mVideoEditor.removeMediaItem(mediaVideoItem.getId()));
    assertEquals("removing Media item 2", mediaImageItem, mVideoEditor.removeMediaItem(mediaImageItem.getId()));
    try {
        mVideoEditor.generatePreview(new MediaProcessingProgressListener() {

            public void onProgress(Object item, int action, int progress) {
            }
        });
        final SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
        mVideoEditor.startPreview(surfaceHolder, 0, -1, false, 1, new PreviewProgressListener() {

            public void onProgress(VideoEditor videoEditor, long timeMs, OverlayData overlayData) {
            }

            public void onStart(VideoEditor videoEditor) {
                setPreviewStart();
            }

            public void onStop(VideoEditor videoEditor) {
                setPreviewStop();
            }

            public void onError(VideoEditor videoEditor, int error) {
                setPreviewError();
            }
        });
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Preview with removed Media Items", flagForException);
}
Also used : VideoEditor(android.media.videoeditor.VideoEditor) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaProcessingProgressListener(android.media.videoeditor.VideoEditor.MediaProcessingProgressListener) MediaImageItem(android.media.videoeditor.MediaImageItem) TransitionAlpha(android.media.videoeditor.TransitionAlpha) SurfaceHolder(android.view.SurfaceHolder) EffectColor(android.media.videoeditor.EffectColor) PreviewProgressListener(android.media.videoeditor.VideoEditor.PreviewProgressListener) OverlayData(android.media.videoeditor.VideoEditor.OverlayData) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 55 with MediaVideoItem

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

the class VideoEditorPreviewTest method testPreviewWithTrim.

/**
     * To test Preview : Preview of current Trim applied (with default aspect
     * ratio)
     */
@LargeTest
public void testPreviewWithTrim() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "H264_BP_640x480_30fps_192kbps_1_5.mp4";
    final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName, MediaItem.RENDERING_MODE_CROPPING);
    final Semaphore blockTillPreviewCompletes = new Semaphore(1);
    boolean flagForException = false;
    previewStart = false;
    previewStop = false;
    mediaVideoItem.setExtractBoundaries(mediaVideoItem.getDuration() / 2, mediaVideoItem.getDuration());
    mVideoEditor.addMediaItem(mediaVideoItem);
    validatePreviewProgress(1000, -1, false, mVideoEditor.getDuration());
}
Also used : MediaVideoItem(android.media.videoeditor.MediaVideoItem) Semaphore(java.util.concurrent.Semaphore) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

MediaVideoItem (android.media.videoeditor.MediaVideoItem)119 LargeTest (android.test.suitebuilder.annotation.LargeTest)115 Bitmap (android.graphics.Bitmap)39 MediaImageItem (android.media.videoeditor.MediaImageItem)28 MediaProcessingProgressListener (android.media.videoeditor.VideoEditor.MediaProcessingProgressListener)17 EffectColor (android.media.videoeditor.EffectColor)16 TransitionCrossfade (android.media.videoeditor.TransitionCrossfade)15 VideoEditor (android.media.videoeditor.VideoEditor)15 AudioTrack (android.media.videoeditor.AudioTrack)12 OverlayFrame (android.media.videoeditor.OverlayFrame)11 ExportProgressListener (android.media.videoeditor.VideoEditor.ExportProgressListener)11 TransitionAlpha (android.media.videoeditor.TransitionAlpha)9 Semaphore (java.util.concurrent.Semaphore)9 OverlayData (android.media.videoeditor.VideoEditor.OverlayData)7 SurfaceHolder (android.view.SurfaceHolder)7 TransitionFadeBlack (android.media.videoeditor.TransitionFadeBlack)6 TransitionSliding (android.media.videoeditor.TransitionSliding)6 Rect (android.graphics.Rect)5 EffectKenBurns (android.media.videoeditor.EffectKenBurns)5 MediaItem (android.media.videoeditor.MediaItem)5