Search in sources :

Example 6 with OverlayData

use of android.media.videoeditor.VideoEditor.OverlayData in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorPreviewTest method testPreviewDuringExport.

/**
     *To test Preview : Export during preview
     */
@LargeTest
public void testPreviewDuringExport() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "H264_BP_640x480_30fps_192kbps_1_5.mp4";
    final Semaphore blockTillPreviewCompletes = new Semaphore(1);
    previewStart = false;
    previewStop = false;
    previewError = false;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem1.setExtractBoundaries(0, 20000);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    mVideoEditor.generatePreview(new MediaProcessingProgressListener() {

        public void onProgress(Object item, int action, int progress) {
        }
    });
    long waitingTime = minWaitingTime + mVideoEditor.getDuration();
    blockTillPreviewCompletes.acquire();
    final String fileName = mVideoEditor.getPath() + "/test.3gp";
    final int height = MediaProperties.HEIGHT_480;
    final int bitrate = MediaProperties.BITRATE_512K;
    try {
        mVideoEditor.export(fileName, height, bitrate, new ExportProgressListener() {

            public void onProgress(VideoEditor ve, String outFileName, int progress) {
            }
        });
    } catch (IOException e) {
        assertTrue("UnExpected Error in Export" + e.toString(), false);
    }
    final SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
    try {
        mVideoEditor.startPreview(surfaceHolder, 5000, -1, false, 1, new PreviewProgressListener() {

            public void onProgress(VideoEditor videoEditor, long timeMs, OverlayData overlayData) {
            }

            public void onStart(VideoEditor videoEditor) {
                setPreviewStart();
            }

            public void onStop(VideoEditor videoEditor) {
                setPreviewStop();
                blockTillPreviewCompletes.release();
            }

            public void onError(VideoEditor videoEditor, int error) {
                setPreviewError();
                blockTillPreviewCompletes.release();
            }
        });
    } catch (Exception e) {
        blockTillPreviewCompletes.release();
    }
    blockTillPreviewCompletes.tryAcquire(waitingTime, TimeUnit.MILLISECONDS);
    mVideoEditor.stopPreview();
    assertTrue("Preview Failed to start", previewStart);
    assertTrue("Preview Failed to stop", previewStop);
    assertFalse("Preview Error occurred", previewError);
    blockTillPreviewCompletes.release();
}
Also used : VideoEditor(android.media.videoeditor.VideoEditor) ExportProgressListener(android.media.videoeditor.VideoEditor.ExportProgressListener) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaProcessingProgressListener(android.media.videoeditor.VideoEditor.MediaProcessingProgressListener) Semaphore(java.util.concurrent.Semaphore) IOException(java.io.IOException) IOException(java.io.IOException) SurfaceHolder(android.view.SurfaceHolder) PreviewProgressListener(android.media.videoeditor.VideoEditor.PreviewProgressListener) OverlayData(android.media.videoeditor.VideoEditor.OverlayData) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 7 with OverlayData

use of android.media.videoeditor.VideoEditor.OverlayData in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorPreviewTest method testPreviewWithRenderPreviewFrame.

/**
     * To test Preview : Preview of current Effects applied (with Render Preview
     * Frame)
     */
@LargeTest
public void testPreviewWithRenderPreviewFrame() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
    final Semaphore blockTillPreviewCompletes = new Semaphore(1);
    boolean flagForException = false;
    OverlayData overlayData1 = new OverlayData();
    previewStart = false;
    previewStop = false;
    final String overlayFilename1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaVideoItem);
    final EffectColor effectPink = mVideoEditorHelper.createEffectItem(mediaVideoItem, "effectNegativeOnMvi", 1000, 3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
    mediaVideoItem.addEffect(effectPink);
    mVideoEditor.generatePreview(new MediaProcessingProgressListener() {

        public void onProgress(Object item, int action, int progress) {
        }
    });
    final SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
    assertEquals("Render preview Frame at 5 Sec", 5000, mVideoEditor.renderPreviewFrame(surfaceHolder, 5000, overlayData1));
    assertEquals("Render preview Frame at 7 Sec", 7000, mVideoEditor.renderPreviewFrame(surfaceHolder, 7000, overlayData1));
    validatePreviewProgress(5000, -1, false, mVideoEditor.getDuration());
}
Also used : SurfaceHolder(android.view.SurfaceHolder) EffectColor(android.media.videoeditor.EffectColor) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaProcessingProgressListener(android.media.videoeditor.VideoEditor.MediaProcessingProgressListener) OverlayData(android.media.videoeditor.VideoEditor.OverlayData) Semaphore(java.util.concurrent.Semaphore) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 8 with OverlayData

use of android.media.videoeditor.VideoEditor.OverlayData in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorPreviewTest method testPreviewWithDurationGreaterThanMediaDuration.

/**
     * To test Preview : Preview of current Effects applied (with from time >
     * total duration)
     */
@LargeTest
public void testPreviewWithDurationGreaterThanMediaDuration() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "H264_BP_640x480_30fps_192kbps_1_5.mp4";
    final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    boolean flagForException = false;
    final Semaphore blockTillPreviewCompletes = new Semaphore(1);
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName, renderingMode);
    try {
        mediaVideoItem1.setExtractBoundaries(0, 20000);
    } catch (Exception e) {
        assertTrue("Exception during setExtract Boundaries", false);
    }
    mVideoEditor.addMediaItem(mediaVideoItem1);
    final SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
    long waitingTime = minWaitingTime + (mVideoEditor.getDuration() - 30000);
    if (waitingTime < 0) {
        waitingTime = minWaitingTime;
    }
    blockTillPreviewCompletes.acquire();
    try {
        mVideoEditor.startPreview(surfaceHolder, 30000, -1, true, 1, new PreviewProgressListener() {

            public void onProgress(VideoEditor videoEditor, long timeMs, OverlayData overlayData) {
            }

            public void onStart(VideoEditor videoEditor) {
                setPreviewStart();
            }

            public void onStop(VideoEditor videoEditor) {
                setPreviewStop();
                blockTillPreviewCompletes.release();
            }

            public void onError(VideoEditor videoEditor, int error) {
                setPreviewError();
                blockTillPreviewCompletes.release();
            }
        });
    } catch (IllegalArgumentException e) {
        blockTillPreviewCompletes.release();
        flagForException = true;
    }
    blockTillPreviewCompletes.tryAcquire(waitingTime, TimeUnit.MILLISECONDS);
    assertTrue("Expected Error in Preview", flagForException);
    mVideoEditor.stopPreview();
    blockTillPreviewCompletes.release();
}
Also used : SurfaceHolder(android.view.SurfaceHolder) VideoEditor(android.media.videoeditor.VideoEditor) PreviewProgressListener(android.media.videoeditor.VideoEditor.PreviewProgressListener) MediaVideoItem(android.media.videoeditor.MediaVideoItem) OverlayData(android.media.videoeditor.VideoEditor.OverlayData) Semaphore(java.util.concurrent.Semaphore) IOException(java.io.IOException) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 9 with OverlayData

use of android.media.videoeditor.VideoEditor.OverlayData in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorPreviewTest method testStartPreviewWithoutMediaItems.

/**
     * To Test Preview : Without any Media Items in the story Board
     */
@LargeTest
public void testStartPreviewWithoutMediaItems() throws Exception {
    boolean flagForException = false;
    final SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
    try {
        mVideoEditor.startPreview(surfaceHolder, 0, -1, false, 1, new PreviewProgressListener() {

            public void onProgress(VideoEditor videoEditor, long timeMs, OverlayData overlayData) {
            }

            public void onStart(VideoEditor videoEditor) {
                setPreviewStart();
            }

            public void onStop(VideoEditor videoEditor) {
                setPreviewStop();
            }

            public void onError(VideoEditor videoEditor, int error) {
                setPreviewError();
            }
        });
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Preview without Media Items", flagForException);
}
Also used : SurfaceHolder(android.view.SurfaceHolder) VideoEditor(android.media.videoeditor.VideoEditor) PreviewProgressListener(android.media.videoeditor.VideoEditor.PreviewProgressListener) OverlayData(android.media.videoeditor.VideoEditor.OverlayData) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

OverlayData (android.media.videoeditor.VideoEditor.OverlayData)9 SurfaceHolder (android.view.SurfaceHolder)9 LargeTest (android.test.suitebuilder.annotation.LargeTest)8 MediaVideoItem (android.media.videoeditor.MediaVideoItem)7 VideoEditor (android.media.videoeditor.VideoEditor)6 MediaProcessingProgressListener (android.media.videoeditor.VideoEditor.MediaProcessingProgressListener)6 PreviewProgressListener (android.media.videoeditor.VideoEditor.PreviewProgressListener)6 Semaphore (java.util.concurrent.Semaphore)5 IOException (java.io.IOException)4 MediaImageItem (android.media.videoeditor.MediaImageItem)3 EffectColor (android.media.videoeditor.EffectColor)2 TransitionAlpha (android.media.videoeditor.TransitionAlpha)2 TransitionCrossfade (android.media.videoeditor.TransitionCrossfade)2 AudioTrack (android.media.videoeditor.AudioTrack)1 MediaItem (android.media.videoeditor.MediaItem)1 Transition (android.media.videoeditor.Transition)1 TransitionFadeBlack (android.media.videoeditor.TransitionFadeBlack)1 TransitionSliding (android.media.videoeditor.TransitionSliding)1 ExportProgressListener (android.media.videoeditor.VideoEditor.ExportProgressListener)1