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();
}
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());
}
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();
}
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);
}
Aggregations