Search in sources :

Example 26 with MediaVideoItem

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

the class MediaItemThumbnailTest method testThumbnailForMPEG4WVGAWithSetBoundaries.

/**
     * To test thumbnail / frame extraction with setBoundaries
     */
@LargeTest
public void testThumbnailForMPEG4WVGAWithSetBoundaries() throws Exception {
    final String videoItemFilename = INPUT_FILE_PATH + "MPEG4_SP_800x480_515kbps_15fps_AMR_NB_8KHz_12.2kbps_m_0_26.mp4";
    final int atTime = 10000;
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename, renderingMode);
    mediaVideoItem.setExtractBoundaries(1000, (mediaVideoItem.getDuration() - 21000));
    final int outWidth = (mediaVideoItem.getWidth() / 2);
    final int outHeight = (mediaVideoItem.getHeight() / 2);
    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 27 with MediaVideoItem

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

the class MediaItemThumbnailTest method testThumbnailListH264WVGAWithStartGreaterEnd.

/**
     *To test ThumbnailList for H264 WVGA with startTime > End Time
     */
@LargeTest
public void testThumbnailListH264WVGAWithStartGreaterEnd() throws Exception {
    final String videoItemFilename = INPUT_FILE_PATH + "H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final int tnCount = 10;
    boolean flagForException = false;
    final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename, renderingMode);
    final int outWidth = (mediaVideoItem.getWidth() / 2);
    final int outHeight = (mediaVideoItem.getHeight() / 2);
    final long thumbNailStartTime = mediaVideoItem.getDuration() / 2;
    final long thumbNailEndTime = thumbNailStartTime - 1000;
    try {
        mediaVideoItem.getThumbnailList(outWidth, outHeight, thumbNailStartTime, thumbNailEndTime, tnCount);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Thumbnail Extraction where start time > end time", flagForException);
}
Also used : MediaVideoItem(android.media.videoeditor.MediaVideoItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 28 with MediaVideoItem

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

the class MediaItemThumbnailTest method testThumbnailForH264VGADifferentDuration.

/**
     * Check the thumbnail / frame extraction precision at 0,100 and 200 ms
     */
@LargeTest
public void testThumbnailForH264VGADifferentDuration() throws Exception {
    final String videoItemFilename = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
    final int atTime = 0;
    final int atTime1 = 100;
    final int atTime2 = 200;
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename, renderingMode);
    final int outWidth = mediaVideoItem.getWidth();
    final int outHeight = mediaVideoItem.getHeight();
    final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth, outHeight, atTime);
    validateThumbnail(thumbNailBmp, outWidth, outHeight);
    // get Thumbnail @ 100ms
    final Bitmap thumbNailBmpAt100 = mediaVideoItem.getThumbnail(outWidth, outHeight, atTime1);
    validateThumbnail(thumbNailBmpAt100, outWidth, outHeight);
    // get Thumbnail @ 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 29 with MediaVideoItem

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

the class VideoEditorAPITest method testMediaVideoItemEffect.

/**
     * To Test the Media Video API : Get Effect, GetAllEffects, remove Effect
     */
@LargeTest
public void testMediaVideoItemEffect() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
    final int videoItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName, videoItemRenderingMode);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    assertTrue("Effect List Size", (mediaVideoItem1.getAllEffects().size() == 0) ? true : false);
    assertNull("Effect Item by ID", mediaVideoItem1.getEffect("xyx"));
    final EffectColor effectColor = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "Effecton MVi1", 0, 4000, EffectColor.TYPE_GRADIENT, EffectColor.GRAY);
    mediaVideoItem1.addEffect(effectColor);
    assertTrue("Effect List Size", (mediaVideoItem1.getAllEffects().size() == 1) ? true : false);
    assertEquals("Effect Item by Valid ID", effectColor, mediaVideoItem1.getEffect(effectColor.getId()));
    assertNull("Effect Item by Invalid ID", mediaVideoItem1.getEffect("xyz"));
    assertNull("Effect Item by Invalid ID", mediaVideoItem1.removeEffect("effectId"));
    assertTrue("Effect List Size", (mediaVideoItem1.getAllEffects().size() == 1) ? true : false);
    assertEquals("Effect Removed", effectColor, mediaVideoItem1.removeEffect(effectColor.getId()));
    assertTrue("Effect List Size", (mediaVideoItem1.getAllEffects().size() == 0) ? true : false);
    assertNull("Effect Item by ID", mediaVideoItem1.getEffect("effectId"));
}
Also used : EffectColor(android.media.videoeditor.EffectColor) MediaVideoItem(android.media.videoeditor.MediaVideoItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 30 with MediaVideoItem

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

the class VideoEditorAPITest method testMediaVideoItem.

/**
     * To Test Creation of Media Video Item.
     */
@LargeTest
public void testMediaVideoItem() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
    final int videoItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName, videoItemRenderingMode);
    assertTrue("Media Video ID", mediaVideoItem1.getId().equals("mediaVideoItem1"));
    assertTrue("Media Video Filename", mediaVideoItem1.getFilename().equals(videoItemFileName));
    assertEquals("Media Video Rendering Mode", videoItemRenderingMode, mediaVideoItem1.getRenderingMode());
    assertEquals("Media Video Item Duration", mediaVideoItem1.getDuration(), mediaVideoItem1.getTimelineDuration());
    assertEquals("Media Video Overlay", 0, mediaVideoItem1.getAllOverlays().size());
    assertEquals("Media Video Effect", 0, mediaVideoItem1.getAllEffects().size());
    assertNull("Media Video Begin transition", mediaVideoItem1.getBeginTransition());
    assertNull("Media Video End transition", mediaVideoItem1.getEndTransition());
    mediaVideoItem1.setExtractBoundaries(1000, 11000);
    boolean flagForException = false;
    if (mediaVideoItem1.getDuration() != mediaVideoItem1.getTimelineDuration()) {
        flagForException = true;
    }
    assertTrue("Media Video Item Duration & Timeline are same", flagForException);
}
Also used : 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