Search in sources :

Example 1 with OverlayFrame

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

the class VideoEditorHelper method createOverlay.

/**
     *This Method creates object of Type OverlayFrame
     *
     * @return OverlayFrame object
     */
public OverlayFrame createOverlay(MediaItem mediaItem, String overlayId, Bitmap bitmap, long startTimeMs, long durationMs) {
    OverlayFrame overLayFrame = null;
    overLayFrame = new OverlayFrame(mediaItem, overlayId, bitmap, startTimeMs, durationMs);
    return overLayFrame;
}
Also used : OverlayFrame(android.media.videoeditor.OverlayFrame)

Example 2 with OverlayFrame

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

the class VideoEditorAPITest method testFrameOverlayImageItem.

/**
     * To test Frame Overlay for Media Image Item
     */
@LargeTest
public void testFrameOverlayImageItem() throws Exception {
    final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg";
    final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    final String overlayFile2 = INPUT_FILE_PATH + "IMG_640x480_Overlay2.png";
    final MediaImageItem mediaImageItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", imageItemFilename1, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaImageItem1);
    final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, 640, 480);
    final OverlayFrame overlayFrame1 = mVideoEditorHelper.createOverlay(mediaImageItem1, "overlayId1", mBitmap, 5000, 5000);
    mediaImageItem1.addOverlay(overlayFrame1);
    assertEquals("Overlay : Media Item", mediaImageItem1, overlayFrame1.getMediaItem());
    assertTrue("Overlay Id", overlayFrame1.getId().equals("overlayId1"));
    assertEquals("Overlay Bitmap", mBitmap, overlayFrame1.getBitmap());
    assertEquals("Overlay Start Time", 5000, overlayFrame1.getStartTime());
    assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration());
    Bitmap upddateBmp = mVideoEditorHelper.getBitmap(overlayFile2, 640, 480);
    overlayFrame1.setBitmap(upddateBmp);
    assertEquals("Overlay Update Bitmap", upddateBmp, overlayFrame1.getBitmap());
    upddateBmp.recycle();
}
Also used : Bitmap(android.graphics.Bitmap) MediaImageItem(android.media.videoeditor.MediaImageItem) OverlayFrame(android.media.videoeditor.OverlayFrame) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 3 with OverlayFrame

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

the class VideoEditorAPITest method testFrameOverlaySetAndGetImage.

/**
     * To test Frame Overlay for Media Image Item : Set duration and Get
     * Duration
     */
@LargeTest
public void testFrameOverlaySetAndGetImage() throws Exception {
    final String videoItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg";
    final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    boolean flagForException = false;
    final MediaImageItem mediaImageItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaImageItem1);
    final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, 640, 480);
    final OverlayFrame overlayFrame1 = mVideoEditorHelper.createOverlay(mediaImageItem1, "overlayId1", mBitmap, 5000, 5000);
    mediaImageItem1.addOverlay(overlayFrame1);
    overlayFrame1.setDuration(5000);
    assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration());
    try {
        overlayFrame1.setDuration(mediaImageItem1.getDuration() + 10000);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Overlay Duration > Media Item Duration", flagForException);
    assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration());
    flagForException = false;
    try {
        overlayFrame1.setDuration(-1);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Overlay Duration = -1", flagForException);
}
Also used : Bitmap(android.graphics.Bitmap) MediaImageItem(android.media.videoeditor.MediaImageItem) OverlayFrame(android.media.videoeditor.OverlayFrame) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 4 with OverlayFrame

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

the class VideoEditorAPITest method testFrameOverlayVideoItem.

/**
     * To test Frame Overlay for Media Video Item
     */
@LargeTest
public void testFrameOverlayVideoItem() throws Exception {
    final String videoItemFilename1 = INPUT_FILE_PATH + "H263_profile0_176x144_10fps_256kbps_0_25.3gp";
    final String overlayFile1 = INPUT_FILE_PATH + "IMG_176x144_Overlay1.png";
    final String overlayFile2 = INPUT_FILE_PATH + "IMG_176x144_Overlay2.png";
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    final Bitmap mBitmap1 = mVideoEditorHelper.getBitmap(overlayFile1, 176, 144);
    final OverlayFrame overlayFrame1 = mVideoEditorHelper.createOverlay(mediaVideoItem1, "overlayId1", mBitmap1, 5000, 5000);
    mediaVideoItem1.addOverlay(overlayFrame1);
    assertEquals("Overlay : Media Item", mediaVideoItem1, overlayFrame1.getMediaItem());
    assertTrue("Overlay Id", overlayFrame1.getId().equals("overlayId1"));
    assertEquals("Overlay Bitmap", mBitmap1, overlayFrame1.getBitmap());
    assertEquals("Overlay Start Time", 5000, overlayFrame1.getStartTime());
    assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration());
    Bitmap upddateBmp = mVideoEditorHelper.getBitmap(overlayFile2, 176, 144);
    overlayFrame1.setBitmap(upddateBmp);
    assertEquals("Overlay Update Bitmap", upddateBmp, overlayFrame1.getBitmap());
    upddateBmp.recycle();
}
Also used : Bitmap(android.graphics.Bitmap) MediaVideoItem(android.media.videoeditor.MediaVideoItem) OverlayFrame(android.media.videoeditor.OverlayFrame) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 5 with OverlayFrame

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

the class VideoEditorPreviewTest method testPreviewWithOverlayEffectKenBurn.

/**
     * To test Preview : Preview of current work having Overlay and Effect
     * applied
     */
@LargeTest
public void testPreviewWithOverlayEffectKenBurn() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "H264_BP_640x480_30fps_192kbps_1_5.mp4";
    final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
    final String videoItemFileName1 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
    final String overlayFilename = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    final Semaphore blockTillPreviewCompletes = new Semaphore(1);
    previewStart = false;
    previewStop = false;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    final MediaImageItem mediaImageItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFileName, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaImageItem2);
    final MediaVideoItem mediaVideoItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaVideoItem3);
    final EffectColor effectColor = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "Effect1", 1000, 3000, EffectColor.TYPE_COLOR, EffectColor.GREEN);
    mediaVideoItem1.addEffect(effectColor);
    final Rect startRect = new Rect((mediaImageItem2.getHeight() / 3), (mediaImageItem2.getWidth() / 3), (mediaImageItem2.getHeight() / 2), (mediaImageItem2.getWidth() / 2));
    final Rect endRect = new Rect(0, 0, mediaImageItem2.getWidth(), mediaImageItem2.getHeight());
    final EffectKenBurns kbeffectOnMI2 = new EffectKenBurns(mediaImageItem2, "KBOnM2", startRect, endRect, 0, 10000);
    assertNotNull("EffectKenBurns", kbeffectOnMI2);
    mediaImageItem2.addEffect(kbeffectOnMI2);
    final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFilename, 640, 480);
    final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaVideoItem3, "OverlayID", mBitmap, (mediaImageItem2.getDuration() / 4), (mediaVideoItem3.getDuration() / 3));
    mediaVideoItem3.addOverlay(overlayFrame);
    validatePreviewProgress(5000, -1, false, mVideoEditor.getDuration());
}
Also used : Rect(android.graphics.Rect) Bitmap(android.graphics.Bitmap) EffectColor(android.media.videoeditor.EffectColor) EffectKenBurns(android.media.videoeditor.EffectKenBurns) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaImageItem(android.media.videoeditor.MediaImageItem) OverlayFrame(android.media.videoeditor.OverlayFrame) Semaphore(java.util.concurrent.Semaphore) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

OverlayFrame (android.media.videoeditor.OverlayFrame)15 Bitmap (android.graphics.Bitmap)14 LargeTest (android.test.suitebuilder.annotation.LargeTest)14 MediaVideoItem (android.media.videoeditor.MediaVideoItem)11 MediaImageItem (android.media.videoeditor.MediaImageItem)9 EffectColor (android.media.videoeditor.EffectColor)5 Rect (android.graphics.Rect)3 EffectKenBurns (android.media.videoeditor.EffectKenBurns)3 TransitionCrossfade (android.media.videoeditor.TransitionCrossfade)3 VideoEditor (android.media.videoeditor.VideoEditor)3 AudioTrack (android.media.videoeditor.AudioTrack)2 ExportProgressListener (android.media.videoeditor.VideoEditor.ExportProgressListener)2 MediaProcessingProgressListener (android.media.videoeditor.VideoEditor.MediaProcessingProgressListener)2 Semaphore (java.util.concurrent.Semaphore)2 MediaItem (android.media.videoeditor.MediaItem)1 Overlay (android.media.videoeditor.Overlay)1 TransitionAlpha (android.media.videoeditor.TransitionAlpha)1 TransitionFadeBlack (android.media.videoeditor.TransitionFadeBlack)1 TransitionSliding (android.media.videoeditor.TransitionSliding)1 File (java.io.File)1