Search in sources :

Example 36 with MediaImageItem

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

the class MediaPropertiesTest method testPropertiesVGAImage.

/**
     *To test Media Properties for Image file of JPEG Type
     */
@LargeTest
public void testPropertiesVGAImage() throws Exception {
    final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.jpg";
    final int imageItemDuration = 10000;
    final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
    final int fileType = MediaProperties.FILE_JPEG;
    final int width = 640;
    final int height = MediaProperties.HEIGHT_480;
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final MediaImageItem mii = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", imageItemFilename, imageItemDuration, renderingMode);
    validateImageProperties(aspectRatio, fileType, width, height, mii);
}
Also used : MediaImageItem(android.media.videoeditor.MediaImageItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 37 with MediaImageItem

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

the class VideoEditorAPITest method testMediaImageItemOverlays.

/**
     * To Test the Media Image API : Get All Overlay, Get Overlay and remove
     * Overlay
     */
@LargeTest
public void testMediaImageItemOverlays() throws Exception {
    final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
    final String overlayItemFileName = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final MediaImageItem mediaImageItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", imageItemFileName, 12000, imageItemRenderingMode);
    mVideoEditor.addMediaItem(mediaImageItem1);
    assertTrue("Overlay List Size", (mediaImageItem1.getAllOverlays().size() == 0) ? true : false);
    assertNull("Overlay Item by ID", mediaImageItem1.getOverlay("xyz"));
    final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayItemFileName, 640, 480);
    final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaImageItem1, "overlayId", mBitmap, 5000, 5000);
    mediaImageItem1.addOverlay(overlayFrame);
    assertTrue("Overlay List Size", (mediaImageItem1.getAllOverlays().size() == 1) ? true : false);
    assertEquals("Overlay Item by Valid ID", overlayFrame, mediaImageItem1.getOverlay(overlayFrame.getId()));
    assertNull("Overlay Item by Invalid ID", mediaImageItem1.getOverlay("xyz"));
    assertNull("Remove Overlay Item by Invalid ID", mediaImageItem1.removeOverlay("xyz"));
    assertTrue("Overlay List Size", (mediaImageItem1.getAllOverlays().size() == 1) ? true : false);
    assertEquals("Overlay Removed", overlayFrame, mediaImageItem1.removeOverlay(overlayFrame.getId()));
    assertTrue("Overlay List Size", (mediaImageItem1.getAllOverlays().size() == 0) ? true : false);
    assertNull("Overlay Item by ID", mediaImageItem1.getOverlay("effectId"));
}
Also used : Bitmap(android.graphics.Bitmap) MediaImageItem(android.media.videoeditor.MediaImageItem) OverlayFrame(android.media.videoeditor.OverlayFrame) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 38 with MediaImageItem

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

the class VideoEditorAPITest method testEffectKenBurnSet.

/**
     * To test KenBurnEffect : Set StartRect and EndRect
     */
@LargeTest
public void testEffectKenBurnSet() throws Exception {
    final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
    final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    boolean flagForException = false;
    final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", imageItemFileName, 5000, imageItemRenderingMode);
    mVideoEditor.addMediaItem(mediaImageItem);
    final Rect startRect = new Rect((mediaImageItem.getHeight() / 3), (mediaImageItem.getWidth() / 3), (mediaImageItem.getHeight() / 2), (mediaImageItem.getWidth() / 2));
    final Rect endRect = new Rect(0, 0, mediaImageItem.getWidth(), mediaImageItem.getHeight());
    EffectKenBurns kbEffectOnMediaItem = null;
    kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2", startRect, endRect, 500, 3000);
    assertNotNull("EffectKenBurns", kbEffectOnMediaItem);
    mediaImageItem.addEffect(kbEffectOnMediaItem);
    assertEquals("KenBurn Start Rect", startRect, kbEffectOnMediaItem.getStartRect());
    assertEquals("KenBurn End Rect", endRect, kbEffectOnMediaItem.getEndRect());
    final Rect startRect1 = new Rect((mediaImageItem.getHeight() / 5), (mediaImageItem.getWidth() / 5), (mediaImageItem.getHeight() / 4), (mediaImageItem.getWidth() / 4));
    final Rect endRect1 = new Rect(10, 10, mediaImageItem.getWidth() / 4, mediaImageItem.getHeight() / 4);
    /* Added newly to take care of removal set APIs */
    kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2_changed", startRect1, endRect1, 500, 3000);
    assertEquals("KenBurn Start Rect", startRect1, kbEffectOnMediaItem.getStartRect());
    assertEquals("KenBurn End Rect", endRect1, kbEffectOnMediaItem.getEndRect());
    final Rect zeroRect = new Rect(0, 0, 0, 0);
    try {
        kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2_zeroStart", zeroRect, endRect, 500, 3000);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Invalid Start Rect", flagForException);
    flagForException = false;
    try {
        kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2_zeroEnd", startRect, zeroRect, 500, 3000);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Invalid End Rect", flagForException);
}
Also used : Rect(android.graphics.Rect) EffectKenBurns(android.media.videoeditor.EffectKenBurns) MediaImageItem(android.media.videoeditor.MediaImageItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 39 with MediaImageItem

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

the class VideoEditorAPITest method testVideoEditorAPI.

/**
     * To test Video Editor API
     *
     * @throws Exception
     */
@LargeTest
public void testVideoEditorAPI() throws Exception {
    final String videoItemFileName1 = INPUT_FILE_PATH + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4";
    final String videoItemFileName2 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp";
    final String videoItemFileName3 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
    final String imageItemFileName1 = INPUT_FILE_PATH + "IMG_640x480.jpg";
    final String imageItemFileName2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
    final String audioFilename1 = INPUT_FILE_PATH + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
    final String audioFilename2 = INPUT_FILE_PATH + "AACLC_48KHz_256Kbps_s_1_17.3gp";
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    boolean flagForException = false;
    TransitionCrossfade transition2And4;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName1, renderingMode);
    mediaVideoItem1.setExtractBoundaries(0, 10000);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    final MediaVideoItem mediaVideoItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", videoItemFileName2, renderingMode);
    mediaVideoItem2.setExtractBoundaries(mediaVideoItem2.getDuration() / 4, mediaVideoItem2.getDuration() / 2);
    mVideoEditor.addMediaItem(mediaVideoItem2);
    final MediaVideoItem mediaVideoItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", videoItemFileName3, renderingMode);
    mediaVideoItem3.setExtractBoundaries(mediaVideoItem3.getDuration() / 2, mediaVideoItem3.getDuration());
    mVideoEditor.addMediaItem(mediaVideoItem3);
    final MediaImageItem mediaImageItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", imageItemFileName1, 5000, renderingMode);
    final MediaImageItem mediaImageItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", imageItemFileName2, 5000, renderingMode);
    List<MediaItem> mediaList = mVideoEditor.getAllMediaItems();
    assertEquals("Media Item List Size", 3, mediaList.size());
    mVideoEditor.insertMediaItem(mediaImageItem1, mediaVideoItem2.getId());
    mediaList = mVideoEditor.getAllMediaItems();
    assertEquals("Media Item List Size", 4, mediaList.size());
    assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0));
    assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1));
    assertEquals("Media item 4", mediaImageItem1, mediaList.get(2));
    assertEquals("Media item 3", mediaVideoItem3, mediaList.get(3));
    mVideoEditor.insertMediaItem(mediaImageItem2, mediaImageItem1.getId());
    mediaList = mVideoEditor.getAllMediaItems();
    assertEquals("Media Item List Size", 5, mediaList.size());
    assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0));
    assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1));
    assertEquals("Media item 4", mediaImageItem1, mediaList.get(2));
    assertEquals("Media item 5", mediaImageItem2, mediaList.get(3));
    assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4));
    mVideoEditor.moveMediaItem(mediaVideoItem1.getId(), mediaImageItem2.getId());
    mediaList = mVideoEditor.getAllMediaItems();
    assertEquals("Media Item List Size", 5, mediaList.size());
    assertEquals("Media item 2", mediaVideoItem2, mediaList.get(0));
    assertEquals("Media item 4", mediaImageItem1, mediaList.get(1));
    assertEquals("Media item 5", mediaImageItem2, mediaList.get(2));
    assertEquals("Media item 1", mediaVideoItem1, mediaList.get(3));
    assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4));
    assertEquals("Media Item 1", mediaVideoItem1, mVideoEditor.getMediaItem(mediaVideoItem1.getId()));
    flagForException = false;
    transition2And4 = null;
    try {
        transition2And4 = mVideoEditorHelper.createTCrossFade("transition2And4", mediaVideoItem2, mediaImageItem1, 2000, Transition.BEHAVIOR_MIDDLE_FAST);
        mVideoEditor.addTransition(transition2And4);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertFalse("Transition2and4 cannot be created", flagForException);
    TransitionCrossfade transition1And3 = null;
    flagForException = false;
    try {
        transition1And3 = mVideoEditorHelper.createTCrossFade("transition1And3", mediaVideoItem1, mediaVideoItem2, 5000, Transition.BEHAVIOR_MIDDLE_FAST);
        mVideoEditor.addTransition(transition1And3);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Transition1and3 cannot be created", flagForException);
    List<Transition> transitionList = mVideoEditor.getAllTransitions();
    assertEquals("Transition List", 1, transitionList.size());
    assertEquals("Transition 2", transition2And4, mVideoEditor.getTransition(transition2And4.getId()));
    final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "audioTrack", audioFilename1);
    mVideoEditor.addAudioTrack(audioTrack);
    List<AudioTrack> audioList = mVideoEditor.getAllAudioTracks();
    assertEquals("Audio List", 1, audioList.size());
    final AudioTrack audioTrack1 = mVideoEditorHelper.createAudio(mVideoEditor, "audioTrack1", audioFilename2);
    flagForException = false;
    try {
        mVideoEditor.addAudioTrack(audioTrack1);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Audio Track support is 1 ", flagForException);
    flagForException = false;
    try {
        mVideoEditor.insertAudioTrack(audioTrack1, "audioTrack");
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Audio Track supports is 1 ", flagForException);
    assertEquals("Removing AudioTrack", audioTrack, mVideoEditor.removeAudioTrack(audioTrack.getId()));
    assertEquals("Removing transition", transition2And4, mVideoEditor.removeTransition(transition2And4.getId()));
    assertEquals("Removing Media Item", mediaVideoItem2, mVideoEditor.removeMediaItem(mediaVideoItem2.getId()));
    mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_16_9);
    assertEquals("Check Aspect Ratio", MediaProperties.ASPECT_RATIO_16_9, mVideoEditor.getAspectRatio());
    long storyBoardDuration = mediaVideoItem1.getTimelineDuration() + mediaVideoItem3.getTimelineDuration() + mediaImageItem1.getDuration() + mediaImageItem2.getDuration();
    assertEquals("Story Board Duration", storyBoardDuration, mVideoEditor.getDuration());
}
Also used : MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaImageItem(android.media.videoeditor.MediaImageItem) TransitionCrossfade(android.media.videoeditor.TransitionCrossfade) MediaItem(android.media.videoeditor.MediaItem) Transition(android.media.videoeditor.Transition) AudioTrack(android.media.videoeditor.AudioTrack) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 40 with MediaImageItem

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

the class VideoEditorAPITest method testMediaImageItem.

/**
     * To Test Creation of Media Image Item.
     */
@LargeTest
public void testMediaImageItem() throws Exception {
    final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
    final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final MediaImageItem mediaImageItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", imageItemFileName, 5000, imageItemRenderingMode);
    assertTrue("Media Image ID", mediaImageItem1.getId().equals("mediaImageItem1"));
    assertTrue("Media IMage Filename", mediaImageItem1.getFilename().equals(imageItemFileName));
    assertEquals("Media Image Rendering Mode", imageItemRenderingMode, mediaImageItem1.getRenderingMode());
    assertEquals("Media Image Item Duration", mediaImageItem1.getDuration(), mediaImageItem1.getTimelineDuration());
    assertEquals("Media Image Overlay", 0, mediaImageItem1.getAllOverlays().size());
    assertEquals("Media Image Effect", 0, mediaImageItem1.getAllEffects().size());
    assertNull("Media Image Begin transition", mediaImageItem1.getBeginTransition());
    assertNull("Media Image End transition", mediaImageItem1.getEndTransition());
    assertEquals("Media Image Scaled Height", MediaProperties.HEIGHT_720, mediaImageItem1.getScaledHeight());
    assertEquals("Media Image Scaled Width", 960, mediaImageItem1.getScaledWidth());
    assertEquals("Media Image Aspect Ratio", MediaProperties.ASPECT_RATIO_4_3, mediaImageItem1.getAspectRatio());
    assertNotNull("Media Image Thumbnail", mediaImageItem1.getThumbnail(960, MediaProperties.HEIGHT_720, 2000));
}
Also used : MediaImageItem(android.media.videoeditor.MediaImageItem) 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