Search in sources :

Example 86 with MediaVideoItem

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

the class MediaItemThumbnailTest method testThumbnailMPEG4withMorethanFileDuration.

/**
     * To test thumbnail / frame extraction on MPEG4 (time beyond file duration).
     */
@LargeTest
public void testThumbnailMPEG4withMorethanFileDuration() throws Exception {
    final String videoItemFilename = INPUT_FILE_PATH + "MPEG4_SP_176x144_30fps_256kbps_AACLC_44.1kHz_96kbps_s_1_17.3gp";
    boolean flagForException = false;
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename, renderingMode);
    final int outWidth = mediaVideoItem.getWidth() / 2;
    final int outHeight = mediaVideoItem.getHeight() / 2;
    final long atTime = mediaVideoItem.getDuration() + 100;
    try {
        final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth, outHeight, atTime);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Thumbnail duration is more than file duration", flagForException);
}
Also used : Bitmap(android.graphics.Bitmap) MediaVideoItem(android.media.videoeditor.MediaVideoItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 87 with MediaVideoItem

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

the class MediaItemThumbnailTest method testThumbnailWithWidth.

/**
     * Check the thumbnail for Width = 10
     */
@LargeTest
public void testThumbnailWithWidth() throws Exception {
    final String videoItemFilename = INPUT_FILE_PATH + "MPEG4_SP_176x144_30fps_256kbps_AACLC_44.1kHz_96kbps_s_1_17.3gp";
    final int atTime = 1000;
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename, renderingMode);
    final int outWidth = 10;
    final int outHeight = mediaVideoItem.getHeight();
    final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth, outHeight, atTime);
    validateThumbnail(thumbNailBmp, outWidth, outHeight);
}
Also used : Bitmap(android.graphics.Bitmap) MediaVideoItem(android.media.videoeditor.MediaVideoItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 88 with MediaVideoItem

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

the class MediaItemThumbnailTest method testThumbnailForMP4VGA.

/**
     *Check the thumbnail / frame extraction precision at
     * FileDuration,FileDuration/2 + 100 andFileDuration/2 + 200 ms
     */
@LargeTest
public void testThumbnailForMP4VGA() throws Exception {
    final String videoItemFilename = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_256kbps_0_30.mp4";
    final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename, MediaItem.RENDERING_MODE_BLACK_BORDER);
    final int outWidth = mediaVideoItem.getWidth();
    final int outHeight = mediaVideoItem.getHeight();
    final long atTime = mediaVideoItem.getDuration() / 2;
    final long atTime1 = atTime + 100;
    final long atTime2 = atTime + 200;
    // get Thumbnail @ duration/2
    final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth, outHeight, atTime);
    validateThumbnail(thumbNailBmp, outWidth, outHeight);
    // get Thumbnail @ duration/2 + 100ms
    final Bitmap thumbNailBmpAt100 = mediaVideoItem.getThumbnail(outWidth, outHeight, atTime1);
    validateThumbnail(thumbNailBmpAt100, outWidth, outHeight);
    // get Thumbnail @ duration/2 + 200ms
    final Bitmap thumbNailBmpAt200 = mediaVideoItem.getThumbnail(outWidth, outHeight, atTime2);
    validateThumbnail(thumbNailBmpAt200, outWidth, outHeight);
}
Also used : Bitmap(android.graphics.Bitmap) MediaVideoItem(android.media.videoeditor.MediaVideoItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 89 with MediaVideoItem

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

the class VideoEditorAPITest method testEffectInvalidStartTimeAndDuration.

/**
     * To test Effect Color : with Invalid StartTime and Duration
     */
@LargeTest
public void testEffectInvalidStartTimeAndDuration() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_32kbps_m_1_17.3gp";
    final int videoItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    boolean flagForException = false;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName, videoItemRenderingMode);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    try {
        mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect1", 400000000, 2000, EffectColor.TYPE_COLOR, EffectColor.GREEN);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Effect with invalid StartTime", flagForException);
    flagForException = false;
    try {
        mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect1", -1, 2000, EffectColor.TYPE_COLOR, EffectColor.GREEN);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Effect with invalid StartTime", flagForException);
    flagForException = false;
    try {
        mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect1", 2000, -1, EffectColor.TYPE_COLOR, EffectColor.GREEN);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Effect with invalid Duration", flagForException);
}
Also used : MediaVideoItem(android.media.videoeditor.MediaVideoItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 90 with MediaVideoItem

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

the class VideoEditorAPITest method testFrameOverlayInvalidTime.

/**
     * To test Frame Overlay for Media Video Item : Set duration and Get
     * Duration
     */
@LargeTest
public void testFrameOverlayInvalidTime() throws Exception {
    final String videoItemFilename1 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp";
    final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    boolean flagForException = false;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    try {
        final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, 640, 480);
        mVideoEditorHelper.createOverlay(mediaVideoItem1, "overlayId1", mBitmap, 400000000, 2000);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Overlay With Invalid Start Time", flagForException);
    flagForException = false;
    try {
        final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, 640, 480);
        mVideoEditorHelper.createOverlay(mediaVideoItem1, "overlayId2", mBitmap, -1, 2000);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Overlay With Invalid Start Time", flagForException);
    flagForException = false;
    try {
        final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, 640, 480);
        mVideoEditorHelper.createOverlay(mediaVideoItem1, "overlayId3", mBitmap, 2000, -1);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Overlay With Invalid Start Time", flagForException);
}
Also used : Bitmap(android.graphics.Bitmap) MediaVideoItem(android.media.videoeditor.MediaVideoItem) 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