Search in sources :

Example 11 with ExportProgressListener

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

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

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

Example 14 with ExportProgressListener

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

the class VideoEditorExportTest method testExportDuration1Hour.

/**
     * To Test Export :Media Item having duration of 1 Hour
     *
     * @throws Exception
     */
@Suppress
@LargeTest
public void testExportDuration1Hour() throws Exception {
    final String videoItemFilename1 = INPUT_FILE_PATH + "H264_BP_640x480_15fps_384kbps_60_0.mp4";
    final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
    final MediaVideoItem mediaItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaItem1);
    try {
        final int[] progressUpdate = new int[100];
        mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144, 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);
    }
    mVideoEditorHelper.validateExport(mVideoEditor, outFilename, MediaProperties.HEIGHT_720, 0, mediaItem1.getDuration(), 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) Suppress(android.test.suitebuilder.annotation.Suppress) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

VideoEditor (android.media.videoeditor.VideoEditor)14 ExportProgressListener (android.media.videoeditor.VideoEditor.ExportProgressListener)14 LargeTest (android.test.suitebuilder.annotation.LargeTest)14 MediaVideoItem (android.media.videoeditor.MediaVideoItem)11 MediaImageItem (android.media.videoeditor.MediaImageItem)8 MediaProcessingProgressListener (android.media.videoeditor.VideoEditor.MediaProcessingProgressListener)7 EffectColor (android.media.videoeditor.EffectColor)4 TransitionAlpha (android.media.videoeditor.TransitionAlpha)4 TransitionCrossfade (android.media.videoeditor.TransitionCrossfade)3 TransitionSliding (android.media.videoeditor.TransitionSliding)3 Bitmap (android.graphics.Bitmap)2 Rect (android.graphics.Rect)2 AudioTrack (android.media.videoeditor.AudioTrack)2 EffectKenBurns (android.media.videoeditor.EffectKenBurns)2 OverlayFrame (android.media.videoeditor.OverlayFrame)2 TransitionFadeBlack (android.media.videoeditor.TransitionFadeBlack)2 OverlayData (android.media.videoeditor.VideoEditor.OverlayData)1 PreviewProgressListener (android.media.videoeditor.VideoEditor.PreviewProgressListener)1 Suppress (android.test.suitebuilder.annotation.Suppress)1 SurfaceHolder (android.view.SurfaceHolder)1