Search in sources :

Example 1 with ExtractAudioWaveformProgressListener

use of android.media.videoeditor.ExtractAudioWaveformProgressListener in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorAPITest method testMediaVideoItemGetWaveformData.

/**
     * To Test the Media Video API : GetWaveFormData and
     * extractAudioWaveFormData
     */
@LargeTest
public void testMediaVideoItemGetWaveformData() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
    final int videoItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName, videoItemRenderingMode);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    assertNull("WaveForm data", mediaVideoItem1.getWaveformData());
    final int[] progressWaveform = new int[105];
    mediaVideoItem1.extractAudioWaveform(new ExtractAudioWaveformProgressListener() {

        int i = 0;

        public void onProgress(int progress) {
            Log.i("WaveformData", "progress=" + progress);
            progressWaveform[i++] = progress;
        }
    });
    assertTrue("Progress of WaveForm data", mVideoEditorHelper.checkProgressCBValues(progressWaveform));
    assertNotNull("WaveForm data", mediaVideoItem1.getWaveformData());
    assertTrue("WaveForm Frame Duration", (mediaVideoItem1.getWaveformData().getFrameDuration() > 0 ? true : false));
    assertTrue("WaveForm Frame Count", (mediaVideoItem1.getWaveformData().getFramesCount() > 0 ? true : false));
    assertTrue("WaveForm Gain", (mediaVideoItem1.getWaveformData().getFrameGains().length > 0 ? true : false));
}
Also used : ExtractAudioWaveformProgressListener(android.media.videoeditor.ExtractAudioWaveformProgressListener) MediaVideoItem(android.media.videoeditor.MediaVideoItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 2 with ExtractAudioWaveformProgressListener

use of android.media.videoeditor.ExtractAudioWaveformProgressListener in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorAPITest method testAudioTrackWaveFormData.

/**
     * To Test the Audio Track API:Extract waveform data
     */
@LargeTest
public void testAudioTrackWaveFormData() throws Exception {
    /** Image item is added as dummy as Audio track cannot be added without
         * a media item in the story board
         */
    final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
    final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    final MediaImageItem mediaImageItem = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", imageItemFileName, 5000, imageItemRenderingMode);
    mVideoEditor.addMediaItem(mediaImageItem);
    final String audioFileName = INPUT_FILE_PATH + "AACLC_48KHz_256Kbps_s_1_17.3gp";
    final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "audioTrack", audioFileName);
    mVideoEditor.addAudioTrack(audioTrack);
    assertNull("WaveForm data", audioTrack.getWaveformData());
    final int[] progressUpdate = new int[105];
    mVideoEditor.generatePreview(new MediaProcessingProgressListener() {

        int i = 0;

        public void onProgress(Object item, int action, int progress) {
            progressUpdate[i++] = progress;
        }
    });
    final int[] progressWaveform = new int[105];
    audioTrack.extractAudioWaveform(new ExtractAudioWaveformProgressListener() {

        int i = 0;

        public void onProgress(int progress) {
            Log.i("AudioWaveformData", "progress=" + progress);
            progressWaveform[i++] = progress;
        }
    });
    assertTrue("Progress of WaveForm data", mVideoEditorHelper.checkProgressCBValues(progressWaveform));
    assertNotNull("WaveForm data", audioTrack.getWaveformData());
    assertTrue("WaveForm Frame Duration", (audioTrack.getWaveformData().getFrameDuration() > 0 ? true : false));
    assertTrue("WaveForm Frame Count", (audioTrack.getWaveformData().getFramesCount() > 0 ? true : false));
    assertTrue("WaveForm Gain", (audioTrack.getWaveformData().getFrameGains().length > 0 ? true : false));
}
Also used : ExtractAudioWaveformProgressListener(android.media.videoeditor.ExtractAudioWaveformProgressListener) MediaProcessingProgressListener(android.media.videoeditor.VideoEditor.MediaProcessingProgressListener) MediaImageItem(android.media.videoeditor.MediaImageItem) AudioTrack(android.media.videoeditor.AudioTrack) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

ExtractAudioWaveformProgressListener (android.media.videoeditor.ExtractAudioWaveformProgressListener)2 LargeTest (android.test.suitebuilder.annotation.LargeTest)2 AudioTrack (android.media.videoeditor.AudioTrack)1 MediaImageItem (android.media.videoeditor.MediaImageItem)1 MediaVideoItem (android.media.videoeditor.MediaVideoItem)1 MediaProcessingProgressListener (android.media.videoeditor.VideoEditor.MediaProcessingProgressListener)1