Search in sources :

Example 16 with VideoEditor

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

the class VideoEditorExportTest method testExportWithoutMediaItems.

/**
     * To Test Export : Without any Media Items in the story Board
     *
     * @throws Exception
     */
@LargeTest
public void testExportWithoutMediaItems() throws Exception {
    boolean flagForException = false;
    try {
        final int[] progressUpdate = new int[100];
        mVideoEditor.export("/sdcard/Test.3gp", MediaProperties.HEIGHT_720, MediaProperties.BITRATE_800K, new ExportProgressListener() {

            int i = 0;

            public void onProgress(VideoEditor ve, String outFileName, int progress) {
                progressUpdate[i++] = progress;
            }
        });
        mVideoEditorHelper.checkProgressCBValues(progressUpdate);
    } catch (IllegalStateException e) {
        flagForException = true;
    }
    assertTrue("Export without any MediaItems", flagForException);
}
Also used : VideoEditor(android.media.videoeditor.VideoEditor) ExportProgressListener(android.media.videoeditor.VideoEditor.ExportProgressListener) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 17 with VideoEditor

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

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

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

Example 20 with VideoEditor

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

the class VideoEditorExportTest method testExportMergeTrim.

/**
     * To Test export : Merge and Trim different types of Video and Image files
     */
@LargeTest
public void testExportMergeTrim() throws Exception {
    final String videoItemFilename1 = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
    final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
    final String videoItemFilename2 = INPUT_FILE_PATH + "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
    final String videoItemFilename3 = INPUT_FILE_PATH + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4";
    final String imageItemFilename2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
    final String imageItemFilename3 = INPUT_FILE_PATH + "IMG_640x480.jpg";
    final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem1.setExtractBoundaries(2000, 7000);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    final MediaImageItem mediaImageItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFilename1, 3000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaImageItem2);
    final MediaVideoItem mediaVideoItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem3.setExtractBoundaries(0, 2000);
    mVideoEditor.addMediaItem(mediaVideoItem3);
    final MediaVideoItem mediaVideoItem4 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem4.setExtractBoundaries(mediaVideoItem4.getDuration() - 5000, mediaVideoItem4.getDuration());
    mVideoEditor.addMediaItem(mediaVideoItem4);
    final MediaImageItem mediaImageItem5 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", imageItemFilename2, 4000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaImageItem5);
    final MediaImageItem mediaImageItem6 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", imageItemFilename3, 2000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaImageItem6);
    mVideoEditor.generatePreview(new MediaProcessingProgressListener() {

        public void onProgress(Object item, int action, int progress) {
        }
    });
    try {
        final int[] progressUpdate = new int[100];
        mVideoEditor.export(outFilename, MediaProperties.HEIGHT_720, MediaProperties.BITRATE_800K, new ExportProgressListener() {

            int i = 0;

            public void onProgress(VideoEditor ve, String outFileName, int progress) {
                progressUpdate[i++] = progress;
            }
        });
        mVideoEditorHelper.checkProgressCBValues(progressUpdate);
    } catch (Exception e) {
        assertTrue("Error in Export" + e.toString(), false);
    }
    final long storyBoardDuration = mediaVideoItem1.getTimelineDuration() + mediaImageItem2.getDuration() + mediaVideoItem3.getTimelineDuration() + mediaVideoItem4.getTimelineDuration() + mediaImageItem5.getDuration() + mediaImageItem6.getDuration();
    mVideoEditorHelper.validateExport(mVideoEditor, outFilename, MediaProperties.HEIGHT_720, 0, storyBoardDuration, MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
    mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
Also used : VideoEditor(android.media.videoeditor.VideoEditor) ExportProgressListener(android.media.videoeditor.VideoEditor.ExportProgressListener) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaProcessingProgressListener(android.media.videoeditor.VideoEditor.MediaProcessingProgressListener) MediaImageItem(android.media.videoeditor.MediaImageItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

VideoEditor (android.media.videoeditor.VideoEditor)21 LargeTest (android.test.suitebuilder.annotation.LargeTest)19 MediaVideoItem (android.media.videoeditor.MediaVideoItem)15 ExportProgressListener (android.media.videoeditor.VideoEditor.ExportProgressListener)14 MediaImageItem (android.media.videoeditor.MediaImageItem)11 MediaProcessingProgressListener (android.media.videoeditor.VideoEditor.MediaProcessingProgressListener)11 EffectColor (android.media.videoeditor.EffectColor)6 TransitionAlpha (android.media.videoeditor.TransitionAlpha)6 OverlayData (android.media.videoeditor.VideoEditor.OverlayData)6 PreviewProgressListener (android.media.videoeditor.VideoEditor.PreviewProgressListener)6 SurfaceHolder (android.view.SurfaceHolder)6 TransitionCrossfade (android.media.videoeditor.TransitionCrossfade)5 IOException (java.io.IOException)5 TransitionSliding (android.media.videoeditor.TransitionSliding)4 Semaphore (java.util.concurrent.Semaphore)4 Bitmap (android.graphics.Bitmap)3 OverlayFrame (android.media.videoeditor.OverlayFrame)3 TransitionFadeBlack (android.media.videoeditor.TransitionFadeBlack)3 Rect (android.graphics.Rect)2 AudioTrack (android.media.videoeditor.AudioTrack)2