use of android.media.videoeditor.MediaImageItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testMediaImageItemHeightWidth.
/**
* To Test the Media Image API : GetHeight and GetWidth
*/
@LargeTest
public void testMediaImageItemHeightWidth() throws Exception {
final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final MediaImageItem mediaImageItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", imageItemFileName, imageItemRenderingMode, 5000);
mVideoEditor.addMediaItem(mediaImageItem1);
assertEquals("Image Height = Image Scaled Height", mediaImageItem1.getScaledHeight(), mediaImageItem1.getHeight());
assertEquals("Image Width = Image Scaled Width", mediaImageItem1.getScaledWidth(), mediaImageItem1.getWidth());
}
use of android.media.videoeditor.MediaImageItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorAPITest method testEffectKenBurn.
private void testEffectKenBurn(final String imageItemFileName, final String MediaId) throws Exception {
final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, MediaId, imageItemFileName, 5000, imageItemRenderingMode);
mVideoEditor.addMediaItem(mediaImageItem);
final Rect startRect = new Rect((mediaImageItem.getHeight() / 3), (mediaImageItem.getWidth() / 3), (mediaImageItem.getHeight() / 2), (mediaImageItem.getWidth() / 2));
final Rect endRect = new Rect(0, 0, mediaImageItem.getWidth(), mediaImageItem.getHeight());
final EffectKenBurns kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2", startRect, endRect, 500, 3000);
assertNotNull("EffectKenBurns: " + imageItemFileName, kbEffectOnMediaItem);
mediaImageItem.addEffect(kbEffectOnMediaItem);
assertEquals("KenBurn Start Rect: " + imageItemFileName, startRect, kbEffectOnMediaItem.getStartRect());
assertEquals("KenBurn End Rect: " + imageItemFileName, endRect, kbEffectOnMediaItem.getEndRect());
}
use of android.media.videoeditor.MediaImageItem 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);
}
use of android.media.videoeditor.MediaImageItem in project XobotOS by xamarin.
the class VideoEditorImpl method parseMediaItem.
/**
* Parse the media item
*
* @param parser The parser
* @return The media item
*/
private MediaItem parseMediaItem(XmlPullParser parser) throws IOException {
final String mediaItemId = parser.getAttributeValue("", ATTR_ID);
final String type = parser.getAttributeValue("", ATTR_TYPE);
final String filename = parser.getAttributeValue("", ATTR_FILENAME);
final int renderingMode = Integer.parseInt(parser.getAttributeValue("", ATTR_RENDERING_MODE));
final MediaItem currentMediaItem;
if (MediaImageItem.class.getSimpleName().equals(type)) {
final long durationMs = Long.parseLong(parser.getAttributeValue("", ATTR_DURATION));
currentMediaItem = new MediaImageItem(this, mediaItemId, filename, durationMs, renderingMode);
} else if (MediaVideoItem.class.getSimpleName().equals(type)) {
final long beginMs = Long.parseLong(parser.getAttributeValue("", ATTR_BEGIN_TIME));
final long endMs = Long.parseLong(parser.getAttributeValue("", ATTR_END_TIME));
final int volume = Integer.parseInt(parser.getAttributeValue("", ATTR_VOLUME));
final boolean muted = Boolean.parseBoolean(parser.getAttributeValue("", ATTR_MUTED));
final String audioWaveformFilename = parser.getAttributeValue("", ATTR_AUDIO_WAVEFORM_FILENAME);
currentMediaItem = new MediaVideoItem(this, mediaItemId, filename, renderingMode, beginMs, endMs, volume, muted, audioWaveformFilename);
final long beginTimeMs = Long.parseLong(parser.getAttributeValue("", ATTR_BEGIN_TIME));
final long endTimeMs = Long.parseLong(parser.getAttributeValue("", ATTR_END_TIME));
((MediaVideoItem) currentMediaItem).setExtractBoundaries(beginTimeMs, endTimeMs);
final int volumePercent = Integer.parseInt(parser.getAttributeValue("", ATTR_VOLUME));
((MediaVideoItem) currentMediaItem).setVolume(volumePercent);
} else {
throw new IllegalArgumentException("Unknown media item type: " + type);
}
return currentMediaItem;
}
Aggregations