use of android.media.videoeditor.OverlayFrame 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.OverlayFrame in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testMediaImageItemOverlays.
/**
* To Test the Media Image API : Get All Overlay, Get Overlay and remove
* Overlay
*/
@LargeTest
public void testMediaImageItemOverlays() throws Exception {
final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
final String overlayItemFileName = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final MediaImageItem mediaImageItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", imageItemFileName, 12000, imageItemRenderingMode);
mVideoEditor.addMediaItem(mediaImageItem1);
assertTrue("Overlay List Size", (mediaImageItem1.getAllOverlays().size() == 0) ? true : false);
assertNull("Overlay Item by ID", mediaImageItem1.getOverlay("xyz"));
final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayItemFileName, 640, 480);
final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaImageItem1, "overlayId", mBitmap, 5000, 5000);
mediaImageItem1.addOverlay(overlayFrame);
assertTrue("Overlay List Size", (mediaImageItem1.getAllOverlays().size() == 1) ? true : false);
assertEquals("Overlay Item by Valid ID", overlayFrame, mediaImageItem1.getOverlay(overlayFrame.getId()));
assertNull("Overlay Item by Invalid ID", mediaImageItem1.getOverlay("xyz"));
assertNull("Remove Overlay Item by Invalid ID", mediaImageItem1.removeOverlay("xyz"));
assertTrue("Overlay List Size", (mediaImageItem1.getAllOverlays().size() == 1) ? true : false);
assertEquals("Overlay Removed", overlayFrame, mediaImageItem1.removeOverlay(overlayFrame.getId()));
assertTrue("Overlay List Size", (mediaImageItem1.getAllOverlays().size() == 0) ? true : false);
assertNull("Overlay Item by ID", mediaImageItem1.getOverlay("effectId"));
}
use of android.media.videoeditor.OverlayFrame in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testFrameOverlaySetAndGet.
/**
* To test Frame Overlay for Media Video Item : Set duration and Get
* Duration
*/
@LargeTest
public void testFrameOverlaySetAndGet() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH + "MPEG4_SP_640x480_30fps_512Kbps_0_27.mp4";
final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
boolean flagForException = false;
final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, 640, 480);
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaVideoItem1);
final OverlayFrame overlayFrame1 = mVideoEditorHelper.createOverlay(mediaVideoItem1, "overlayId1", mBitmap, 5000, 5000);
mediaVideoItem1.addOverlay(overlayFrame1);
overlayFrame1.setDuration(5000);
assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration());
try {
overlayFrame1.setDuration(mediaVideoItem1.getDuration() + 10000);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Overlay Duration > MediaVideo Item Duration", flagForException);
assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration());
flagForException = false;
try {
overlayFrame1.setDuration(-1);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Overlay Duration = -1", flagForException);
}
use of android.media.videoeditor.OverlayFrame in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorPerformance method testPerformanceOverlayVideoItem.
/**
* To test the performance of adding and removing the overlay to media item
*
* @throws Exception
*/
@LargeTest
public void testPerformanceOverlayVideoItem() throws Exception {
final String videoItemFileName1 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
final int videoItemStartTime1 = 0;
final int videoItemEndTime1 = 10000;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final String overlayFilename = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
final int overlayStartTime = 1000;
final int overlayDuration = 5000;
final String[] loggingInfo = new String[2];
MediaVideoItem mediaVideoItem = null;
try {
mediaVideoItem = new MediaVideoItem(mVideoEditor, "m0", videoItemFileName1, renderingMode);
mediaVideoItem.setExtractBoundaries(videoItemStartTime1, videoItemEndTime1);
} catch (Exception e1) {
assertTrue("Can not create Video Item with file name = " + e1.toString(), false);
}
final OverlayFrame[] overlayFrame = new OverlayFrame[NUM_OF_ITERATIONS];
final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFilename, 640, 480);
int timeTaken = 0;
long beginTime = SystemClock.uptimeMillis();
for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
overlayFrame[i] = new OverlayFrame(mediaVideoItem, "overlay" + i, mBitmap, overlayStartTime, overlayDuration);
mediaVideoItem.addOverlay(overlayFrame[i]);
}
timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
loggingInfo[0] = "Time taken to add & create Overlay :" + timeTaken;
beginTime = SystemClock.uptimeMillis();
for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
assertEquals("Removing Overlays", overlayFrame[i], mediaVideoItem.removeOverlay((overlayFrame[i].getId())));
}
timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
loggingInfo[1] = "\n\tTime taken to remove Overlay :" + timeTaken;
writeTimingInfo("testPerformanceOverlayVideoItem (in mSec)", loggingInfo);
}
use of android.media.videoeditor.OverlayFrame in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testMediaVideoItemOverlays.
/**
* To Test the Media Video API : Get All Overlay, Get Overlay and remove Overlay
*
*/
@LargeTest
public void testMediaVideoItemOverlays() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
final String overlayItemFileName = INPUT_FILE_PATH + "IMG_176x144_Overlay1.png";
final int videoItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName, videoItemRenderingMode);
mVideoEditor.addMediaItem(mediaVideoItem1);
assertTrue("Overlay List Size", (mediaVideoItem1.getAllOverlays().size() == 0) ? true : false);
assertNull("Overlay Item by ID", mediaVideoItem1.getOverlay("xyz"));
final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayItemFileName, 176, 144);
final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay(mediaVideoItem1, "overlayId", mBitmap, 5000, 5000);
mediaVideoItem1.addOverlay(overlayFrame);
assertTrue("Overlay List Size", (mediaVideoItem1.getAllOverlays().size() == 1) ? true : false);
assertEquals("Overlay Item by Valid ID", overlayFrame, mediaVideoItem1.getOverlay(overlayFrame.getId()));
assertNull("Overlay Item by Invalid ID", mediaVideoItem1.getOverlay("xyz"));
assertNull("Overlay Item by Invalid ID", mediaVideoItem1.removeOverlay("xyz"));
assertTrue("Overlay List Size", (mediaVideoItem1.getAllOverlays().size() == 1) ? true : false);
assertEquals("Overlay Removed", overlayFrame, mediaVideoItem1.removeOverlay(overlayFrame.getId()));
assertTrue("Overlay List Size", (mediaVideoItem1.getAllOverlays().size() == 0) ? true : false);
assertNull("Overlay Item by ID", mediaVideoItem1.getOverlay("effectId"));
}
Aggregations