Search in sources :

Example 1 with Overlay

use of android.media.videoeditor.Overlay 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)

Aggregations

Bitmap (android.graphics.Bitmap)1 MediaVideoItem (android.media.videoeditor.MediaVideoItem)1 Overlay (android.media.videoeditor.Overlay)1 OverlayFrame (android.media.videoeditor.OverlayFrame)1 LargeTest (android.test.suitebuilder.annotation.LargeTest)1 Semaphore (java.util.concurrent.Semaphore)1