use of android.media.videoeditor.VideoEditor in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorExportTest method testExportTwoVideos.
/**
* To Test Export :Two Media Items added
*
* @throws Exception
*/
@LargeTest
public void testExportTwoVideos() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp";
final String videoItemFileName1 = INPUT_FILE_PATH + "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaVideoItem);
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaVideoItem1);
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);
}
mVideoEditorHelper.validateExport(mVideoEditor, outFilename, MediaProperties.HEIGHT_720, 0, (mediaVideoItem.getDuration() + mediaVideoItem1.getDuration()), MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
use of android.media.videoeditor.VideoEditor in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPreviewTest method validatePreviewProgress.
protected void validatePreviewProgress(int startMs, int endMs, boolean loop, long duration) throws Exception {
final int[] progressUpdate = new int[100];
final Semaphore blockTillPreviewCompletes = new Semaphore(1);
previewStart = false;
previewStop = false;
previewError = false;
mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
int i = 0;
public void onProgress(Object item, int action, int progress) {
progressUpdate[i++] = progress;
}
});
mVideoEditorHelper.checkProgressCBValues(progressUpdate);
final SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
long waitingTime = minWaitingTime;
if (endMs == -1) {
waitingTime += duration;
} else {
waitingTime += (endMs - startMs);
}
blockTillPreviewCompletes.acquire();
try {
mVideoEditor.startPreview(surfaceHolder, startMs, endMs, loop, 1, new PreviewProgressListener() {
public void onProgress(VideoEditor videoEditor, long timeMs, OverlayData overlayData) {
if (overlayData != null) {
if (overlayData.needsRendering()) {
overlayData.renderOverlay(MediaFrameworkTest.mDestBitmap);
mEventHandler.sendMessage(mEventHandler.obtainMessage(1, 2, 3));
}
}
}
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();
}
use of android.media.videoeditor.VideoEditor in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPreviewTest method testStartPreviewAddRemoveMediaItems.
/**
* To Test Preview : Add Media and Remove Media Item (Without any Media
* Items in the story Board)
*/
@LargeTest
public void testStartPreviewAddRemoveMediaItems() 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 alphaFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
boolean flagForException = false;
final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem.setExtractBoundaries(0, 15000);
mVideoEditor.addMediaItem(mediaVideoItem);
final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem);
final TransitionAlpha transition1And2 = mVideoEditorHelper.createTAlpha("transition", mediaVideoItem, mediaImageItem, 3000, Transition.BEHAVIOR_SPEED_UP, alphaFilename, 10, false);
mVideoEditor.addTransition(transition1And2);
final EffectColor effectColor = mVideoEditorHelper.createEffectItem(mediaImageItem, "effect", 5000, 3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
mediaImageItem.addEffect(effectColor);
assertEquals("removing Media item 1", mediaVideoItem, mVideoEditor.removeMediaItem(mediaVideoItem.getId()));
assertEquals("removing Media item 2", mediaImageItem, mVideoEditor.removeMediaItem(mediaImageItem.getId()));
try {
mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
public void onProgress(Object item, int action, int progress) {
}
});
final SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
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 with removed Media Items", flagForException);
}
use of android.media.videoeditor.VideoEditor in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorExportTest method testExportEffectOverlay.
/**
*To Test export : With Effect and Overlays on Different Media Items
*/
@LargeTest
public void testExportEffectOverlay() 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_15fps_1200Kbps_AACLC_48KHz_64kps_m_0_27.3gp";
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 String overlayFile = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem1.setExtractBoundaries(2000, 7000);
mVideoEditor.addMediaItem(mediaVideoItem1);
final EffectColor effectPink = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effectPink", 0, 2000, EffectColor.TYPE_COLOR, EffectColor.PINK);
mediaVideoItem1.addEffect(effectPink);
final EffectColor effectNegative = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effectNegative", 3000, 4000, EffectColor.TYPE_NEGATIVE, 0);
mediaVideoItem1.addEffect(effectNegative);
final MediaImageItem mediaImageItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFilename1, 3000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem2);
final EffectColor effectFifties = mVideoEditorHelper.createEffectItem(mediaImageItem2, "effectFifties", 0, 3000, EffectColor.TYPE_FIFTIES, 0);
mediaImageItem2.addEffect(effectFifties);
final MediaVideoItem mediaVideoItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaVideoItem3);
mediaVideoItem3.setExtractBoundaries(0, 8000);
final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile, 640, 480);
final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaVideoItem3, "overlay", mBitmap, 2000, 5000);
mediaVideoItem3.addOverlay(overlayFrame);
final EffectColor effectGreen = mVideoEditorHelper.createEffectItem(mediaVideoItem3, "effectGreen", 0, 2000, EffectColor.TYPE_COLOR, EffectColor.GREEN);
mediaVideoItem3.addEffect(effectGreen);
final MediaVideoItem mediaVideoItem4 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem4.setExtractBoundaries(mediaVideoItem4.getDuration() - 5000, mediaVideoItem4.getDuration());
mVideoEditor.addMediaItem(mediaVideoItem4);
final EffectColor effectSepia = mVideoEditorHelper.createEffectItem(mediaVideoItem4, "effectSepia", 0, 2000, EffectColor.TYPE_SEPIA, 0);
mediaVideoItem4.addEffect(effectSepia);
final MediaImageItem mediaImageItem5 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", imageItemFilename2, 4000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem5);
final EffectColor effectGray = mVideoEditorHelper.createEffectItem(mediaImageItem5, "effectGray", 0, 2000, EffectColor.TYPE_COLOR, EffectColor.GRAY);
mediaImageItem5.addEffect(effectGray);
final MediaImageItem mediaImageItem6 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", imageItemFilename3, 2000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem6);
final EffectColor effectGradient = mVideoEditorHelper.createEffectItem(mediaImageItem6, "effectGradient", 0, 2000, EffectColor.TYPE_GRADIENT, EffectColor.PINK);
mediaImageItem6.addEffect(effectGradient);
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);
}
use of android.media.videoeditor.VideoEditor in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorExportTest method testExportWithStorageFull.
/**
* To Test Export : Storage location having very less space (Less than 100
* KB)
*
* @throws Exception
*/
@LargeTest
public void testExportWithStorageFull() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH + "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
boolean flagForException = false;
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
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) {
flagForException = true;
}
assertTrue("Error in exporting file due to lack of storage space", flagForException);
}
Aggregations