use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorExportTest method testExportAudio.
/**
* To Test Export : With Video and Image and An Audio BackGround Track
*/
@LargeTest
public void testExportAudio() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
final String audioTrackFilename = INPUT_FILE_PATH + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
mediaVideoItem.setExtractBoundaries(0, 10000);
mVideoEditor.addMediaItem(mediaVideoItem);
final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", imageItemFileName, 5000, MediaItem.RENDERING_MODE_BLACK_BORDER);
mVideoEditor.addMediaItem(mediaImageItem);
final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "a1", audioTrackFilename);
audioTrack.setExtractBoundaries(2000, 5000);
mVideoEditor.addAudioTrack(audioTrack);
audioTrack.disableDucking();
audioTrack.enableLoop();
audioTrack.setVolume(75);
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.getTimelineDuration() + mediaImageItem.getDuration()), MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorStressTest method testStressMultipleExport.
/**
* To stress test : Multiple Export
*
* @throws Exception
*/
@LargeTest
public void testStressMultipleExport() throws Exception {
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final String VideoItemFileName1 = INPUT_FILE_PATH + "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
final String VideoItemFileName2 = INPUT_FILE_PATH + "H264_BP_800x480_15fps_512kbps_1_17.mp4";
final String[] loggingInfo = new String[1];
final String outFilename = mVideoEditorHelper.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
int i = 0;
writeTestCaseHeader("testStressMultipleExport");
getBeginMemory();
final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, "m1", VideoItemFileName1, renderingMode);
mVideoEditor.addMediaItem(mediaItem1);
mediaItem1.setExtractBoundaries(0, 10000);
final MediaVideoItem mediaItem2 = new MediaVideoItem(mVideoEditor, "m2", VideoItemFileName2, renderingMode);
mVideoEditor.addMediaItem(mediaItem2);
mediaItem2.setExtractBoundaries(0, 15000);
for (i = 0; i < 50; i++) {
if (i % 4 == 0) {
final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9;
mVideoEditor.setAspectRatio(aspectRatio);
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_288, MediaProperties.BITRATE_256K, MediaProperties.ACODEC_AAC_LC, MediaProperties.VCODEC_H263, new ExportProgressListener() {
public void onProgress(VideoEditor ve, String outFileName, int progress) {
}
});
}
if (i % 4 == 1) {
final int aspectRatio = MediaProperties.ASPECT_RATIO_5_3;
mVideoEditor.setAspectRatio(aspectRatio);
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144, MediaProperties.BITRATE_384K, MediaProperties.ACODEC_AAC_LC, MediaProperties.VCODEC_MPEG4, new ExportProgressListener() {
public void onProgress(VideoEditor ve, String outFileName, int progress) {
}
});
}
if (i % 4 == 2) {
final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9;
mVideoEditor.setAspectRatio(aspectRatio);
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144, MediaProperties.BITRATE_512K, MediaProperties.ACODEC_AAC_LC, MediaProperties.VCODEC_H264, new ExportProgressListener() {
public void onProgress(VideoEditor ve, String outFileName, int progress) {
}
});
}
if (i % 4 == 3) {
final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
mVideoEditor.setAspectRatio(aspectRatio);
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_480, MediaProperties.BITRATE_800K, MediaProperties.ACODEC_AAC_LC, MediaProperties.VCODEC_H264, new ExportProgressListener() {
public void onProgress(VideoEditor ve, String outFileName, int progress) {
}
});
}
if (i % 10 == 0) {
getAfterMemory_updateLog(loggingInfo, false, i);
}
}
getAfterMemory_updateLog(loggingInfo, false, i);
/** Remove items and check for memory leak if any */
mVideoEditor.removeMediaItem("m2");
mVideoEditor.removeMediaItem("m1");
getAfterMemory_updateLog(loggingInfo, true, i);
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorHelper method createMediaItem.
/**
*This Method Create a Media Video Item with the specified params
*
* @return an Object of MediaVideoItem
*/
public MediaVideoItem createMediaItem(VideoEditor videoEditor, String MediaId, String filename, int renderingMode) {
MediaVideoItem mvi = null;
try {
mvi = new MediaVideoItem(videoEditor, MediaId, filename, renderingMode);
assertNotNull("Can not create an object of MediaVideoItem", mvi);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Can not create an object of Media Video Item with file name = " + filename + " Issue = " + e.toString());
} catch (IOException e) {
assertTrue("Can not create an object of Media Video Item with file name = " + filename + " Issue = " + e.toString(), false);
}
return mvi;
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class VideoEditorHelper method validateExport.
/**
* @param videoEditor
* @param fileName
* @param export_bitrate
* @param export_height
* @param startTime
* @param endTime
* @param vCodec
* @param aCodec
*/
public void validateExport(VideoEditor videoEditor, String fileName, int export_height, int startTime, int endTime, int vCodec, int aCodec) {
File tempFile = new File(fileName);
assertEquals("Exported FileName", tempFile.exists(), true);
final MediaVideoItem mvi = createMediaItem(videoEditor, "m1", fileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
Log.i(TAG, "VideoCodec for file = " + fileName + "\tExpected Video Codec = " + vCodec + "\tActual Video Codec = " + mvi.getVideoType());
assertEquals("Export: Video Codec Mismatch for file = " + fileName + "\t<expected> " + vCodec + "\t<actual> " + mvi.getVideoType(), vCodec, mvi.getVideoType());
Log.i(TAG, "AudioCodec for file = " + fileName + "\tExpected Audio Codec = " + aCodec + "\tActual Audio Codec = " + mvi.getAudioType());
assertEquals("Export: Audio Codec Mismatch for file = " + fileName + "\t<expected> " + aCodec + "\t<actual> " + mvi.getAudioType(), aCodec, mvi.getAudioType());
Log.i(TAG, "Height for file = " + fileName + "\tExpected Height = " + export_height + "\tActual VideoHeight = " + mvi.getHeight());
assertEquals("Export: height Mismatch for file " + fileName + "\t<expected> " + export_height + "\t<actual> " + mvi.getHeight(), export_height, mvi.getHeight());
if (startTime == 0) {
if (endTime != 0) {
Log.i(TAG, "TimeLine Expected = " + (startTime + endTime) + "\t VideoTime= " + mvi.getTimelineDuration());
assertTrue("Export :Timeline Duration Mismatch for file " + fileName + "<expected> " + (startTime + endTime) + "\t<actual> " + mvi.getTimelineDuration(), checkRange((startTime + endTime), mvi.getTimelineDuration(), 10));
}
} else {
Log.i(TAG, "TimeLine Expected = " + (endTime - startTime) + "\t VideoTime= " + mvi.getTimelineDuration());
assertTrue("Timeline Duration Mismatch for file " + fileName + "<expected> " + (endTime - startTime) + "\t<actual> " + mvi.getTimelineDuration(), checkRange((endTime - startTime), mvi.getTimelineDuration(), 10));
}
}
use of android.media.videoeditor.MediaVideoItem in project android_frameworks_base by ParanoidAndroid.
the class MediaItemThumbnailTest method testThumbnailH264VGAExceedingFileDuration.
/**
*To test ThumbnailList for H264 VGA ,Time exceeding file duration
*/
@LargeTest
public void testThumbnailH264VGAExceedingFileDuration() throws Exception {
final String videoItemFilename = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
boolean flagForException = false;
int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
try {
final MediaVideoItem mediaVideoItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename, renderingMode);
final int outWidth = mediaVideoItem.getWidth() / 2;
final int outHeight = mediaVideoItem.getHeight() / 2;
final long atTime = mediaVideoItem.getDuration() + 2000;
mediaVideoItem.getThumbnail(outWidth, outHeight, atTime);
} catch (IllegalArgumentException e) {
flagForException = true;
}
assertTrue("Exception in Extracting thumbanil with Invalid Time", flagForException);
}
Aggregations