Search in sources :

Example 6 with MediaImageItem

use of android.media.videoeditor.MediaImageItem 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 7 with MediaImageItem

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

the class VideoEditorAPITest method testFrameOverlayInvalidTimeImage.

/**
     * To test  Frame Overlay for  Media Image Item :Invalid StartTime and
     * Duration
     */
@LargeTest
public void testFrameOverlayInvalidTimeImage() 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);
    try {
        final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, 640, 480);
        mVideoEditorHelper.createOverlay(mediaImageItem1, "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(mediaImageItem1, "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(mediaImageItem1, "overlayId3", mBitmap, 2000, -1);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Overlay With Invalid Start Time", flagForException);
}
Also used : Bitmap(android.graphics.Bitmap) MediaImageItem(android.media.videoeditor.MediaImageItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 8 with MediaImageItem

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

the class VideoEditorAPITest method testNullAPIs.

/**
     * To test: NULL arguments to the Video Editor APIs
     *
     * @throws Exception
     */
@LargeTest
public void testNullAPIs() throws Exception {
    final String videoItemFilename1 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
    final String maskFilename = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    final String audioFileName = INPUT_FILE_PATH + "AACLC_48KHz_256Kbps_s_1_17.3gp";
    boolean flagForException = false;
    try {
        mVideoEditor.addAudioTrack(null);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Video Editor with null Audio Track", flagForException);
    flagForException = false;
    try {
        mVideoEditor.addMediaItem(null);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Video Editor with NULL Image Item ", flagForException);
    flagForException = false;
    try {
        mVideoEditor.addMediaItem(null);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Video Editor with NULL Video Item ", flagForException);
    MediaVideoItem mediaVideoItem1 = null;
    try {
        mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    } catch (IllegalArgumentException e) {
        assertTrue("Cannot Create Video Item", false);
    }
    mediaVideoItem1.setExtractBoundaries(0, 15000);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    flagForException = false;
    try {
        mediaVideoItem1.addEffect(null);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Video with null effect ", flagForException);
    flagForException = false;
    try {
        mediaVideoItem1.addOverlay(null);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Video with null overlay ", flagForException);
    final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", maskFilename, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaImageItem.setDuration(15000);
    mVideoEditor.addMediaItem(mediaImageItem);
    flagForException = false;
    try {
        mediaImageItem.addEffect(null);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Image with null effect ", flagForException);
    flagForException = false;
    try {
        mediaImageItem.addOverlay(null);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Image with null overlay ", flagForException);
    final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "audioTrack", audioFileName);
    mVideoEditor.addAudioTrack(audioTrack);
    flagForException = false;
    try {
        mVideoEditor.addTransition(null);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Added null transition ", flagForException);
    flagForException = false;
    try {
        mVideoEditor.addTransition(null);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Added null transition ", flagForException);
}
Also used : MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaImageItem(android.media.videoeditor.MediaImageItem) AudioTrack(android.media.videoeditor.AudioTrack) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 9 with MediaImageItem

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

the class MediaPropertiesTest method testPropertiesPNG.

/**
     *To test Media Properties for Image file of PNG Type
     */
@LargeTest
public void testPropertiesPNG() throws Exception {
    final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.png";
    final int imageItemDuration = 10000;
    final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
    final int fileType = MediaProperties.FILE_PNG;
    final int width = 640;
    final int 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 10 with MediaImageItem

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

the class MediaItemThumbnailTest method testThumbnailForInvalidFilePath.

/**
     *To test ThumbnailList for Invalid file path
     */
@LargeTest
public void testThumbnailForInvalidFilePath() throws Exception {
    final String imageItemFileName = INPUT_FILE_PATH + "/sdcard/abc.jpg";
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    boolean flagForException = false;
    try {
        final MediaImageItem mii = new MediaImageItem(mVideoEditor, "m1", imageItemFileName, 3000, renderingMode);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    } catch (IOException e) {
        flagForException = true;
    }
    assertTrue(" Invalid File Path", flagForException);
}
Also used : MediaImageItem(android.media.videoeditor.MediaImageItem) IOException(java.io.IOException) 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