use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testFrameOverlayVideoItem.
/**
* To test Frame Overlay for Media Video Item
*/
@LargeTest
public void testFrameOverlayVideoItem() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH + "H263_profile0_176x144_10fps_256kbps_0_25.3gp";
final String overlayFile1 = INPUT_FILE_PATH + "IMG_176x144_Overlay1.png";
final String overlayFile2 = INPUT_FILE_PATH + "IMG_176x144_Overlay2.png";
final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaVideoItem1);
final Bitmap mBitmap1 = mVideoEditorHelper.getBitmap(overlayFile1, 176, 144);
final OverlayFrame overlayFrame1 = mVideoEditorHelper.createOverlay(mediaVideoItem1, "overlayId1", mBitmap1, 5000, 5000);
mediaVideoItem1.addOverlay(overlayFrame1);
assertEquals("Overlay : Media Item", mediaVideoItem1, overlayFrame1.getMediaItem());
assertTrue("Overlay Id", overlayFrame1.getId().equals("overlayId1"));
assertEquals("Overlay Bitmap", mBitmap1, overlayFrame1.getBitmap());
assertEquals("Overlay Start Time", 5000, overlayFrame1.getStartTime());
assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration());
Bitmap upddateBmp = mVideoEditorHelper.getBitmap(overlayFile2, 176, 144);
overlayFrame1.setBitmap(upddateBmp);
assertEquals("Overlay Update Bitmap", upddateBmp, overlayFrame1.getBitmap());
upddateBmp.recycle();
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testNullAPIs.
/**
* To test: NULL arguments to the Video Editor APIs
*
* @throws Exception
*/
@LargeTest
public void testNullAPIs() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
final String maskFilename = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
final String audioFileName = INPUT_FILE_PATH + "AACLC_48KHz_256Kbps_s_1_17.3gp";
boolean flagForException = false;
try {
mVideoEditor.addAudioTrack(null);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Video Editor with null Audio Track", flagForException);
flagForException = false;
try {
mVideoEditor.addMediaItem(null);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Video Editor with NULL Image Item ", flagForException);
flagForException = false;
try {
mVideoEditor.addMediaItem(null);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Video Editor with NULL Video Item ", flagForException);
MediaVideoItem mediaVideoItem1 = null;
try {
mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
} catch (IllegalArgumentException e) {
assertTrue("Cannot Create Video Item", false);
}
mediaVideoItem1.setExtractBoundaries(0, 15000);
mVideoEditor.addMediaItem(mediaVideoItem1);
flagForException = false;
try {
mediaVideoItem1.addEffect(null);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Video with null effect ", flagForException);
flagForException = false;
try {
mediaVideoItem1.addOverlay(null);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Video with null overlay ", flagForException);
final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", maskFilename, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaImageItem.setDuration(15000);
mVideoEditor.addMediaItem(mediaImageItem);
flagForException = false;
try {
mediaImageItem.addEffect(null);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Image with null effect ", flagForException);
flagForException = false;
try {
mediaImageItem.addOverlay(null);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Image with null overlay ", flagForException);
final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "audioTrack", audioFileName);
mVideoEditor.addAudioTrack(audioTrack);
flagForException = false;
try {
mVideoEditor.addTransition(null);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Added null transition ", flagForException);
flagForException = false;
try {
mVideoEditor.addTransition(null);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Added null transition ", flagForException);
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class MediaItemThumbnailTest method testThumbnailListMPEG4QCIF.
/**
*To test ThumbnailList for MPEG4 QCIF
*/
@LargeTest
public void testThumbnailListMPEG4QCIF() throws Exception {
final String videoItemFilename = INPUT_FILE_PATH + "MPEG4_SP_176x144_30fps_256kbps_AACLC_44.1kHz_96kbps_s_1_17.3gp";
final int tnCount = 10;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename, renderingMode);
final int outWidth = mediaVideoItem.getWidth() / 2;
final int outHeight = mediaVideoItem.getHeight() / 2;
final long startTime = mediaVideoItem.getDuration() / 2;
final long endTime = mediaVideoItem.getDuration();
final Bitmap[] thumbNailBmp = mediaVideoItem.getThumbnailList(outWidth, outHeight, startTime, endTime, tnCount);
assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
assertEquals("Thumbnail Count", tnCount, thumbNailBmp.length);
for (int i = 0; i < thumbNailBmp.length; i++) {
validateThumbnail(thumbNailBmp[i], outWidth, outHeight);
thumbNailBmp[i] = null;
}
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class MediaPropertiesTest method testPropertiesH264HD1280.
/**
*To test Media Properties for file H264 HD1280
*/
@LargeTest
public void testPropertiesH264HD1280() throws Exception {
final String videoItemFilename = INPUT_FILE_PATH + "H264_BP_1280x720_15fps_512kbps_AACLC_16khz_48kbps_s_1_17.mp4";
final int aspectRatio = MediaProperties.ASPECT_RATIO_16_9;
final int fileType = MediaProperties.FILE_MP4;
final int videoCodecType = MediaProperties.VCODEC_H264;
final int duration = 77600;
final int videoBitrate = 606000;
final int audioBitrate = 48000;
final int fps = 15;
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
final int audioSamplingFrequency = 16000;
final int audioChannel = 2;
final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
final int videoLevel = MediaProperties.H264Level.H264Level13;
final int width = 1280;
final int height = MediaProperties.HEIGHT_720;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename, renderingMode);
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration, videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType, audioSamplingFrequency, audioChannel, audioBitrate, mvi);
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class MediaPropertiesTest method testPropertiesH264MainLineProfile.
/**
*To test media properties for H.264 Main/Advanced profile.
*/
@LargeTest
public void testPropertiesH264MainLineProfile() throws Exception {
final String videoItemFilename = INPUT_FILE_PATH + "H264_MP_960x720_25fps_800kbps_AACLC_48Khz_192Kbps_s_1_17.mp4";
final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
final int videoCodecType = MediaProperties.VCODEC_H264;
final int fileType = MediaProperties.FILE_MP4;
final int duration = 77500;
final int videoBitrate = 800000;
final int audioBitrate = 192000;
final int fps = 25;
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
final int audioSamplingFrequency = 48000;
final int audioChannel = 2;
final int videoProfile = MediaProperties.H264Profile.H264ProfileMain;
final int videoLevel = MediaProperties.H264Level.H264Level31;
final int width = 960;
final int height = MediaProperties.HEIGHT_720;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename, renderingMode);
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration, videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType, audioSamplingFrequency, audioChannel, audioBitrate, mvi);
}
Aggregations