Android Open Source - Media-Pack Composer Media File Info Core Activity






From Project

Back to project page Media-Pack.

License

The source code is released under:

Apache License

If you think the Android project Media-Pack listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

//
//               INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in accordance with the terms of that agreement.
//        Copyright (c) 2013-2014 Intel Corporation. All Rights Reserved.
///*  ww  w. jav a2s . com*/

package com.intel.inde.mp.samples;

import android.view.SurfaceHolder;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import com.intel.inde.mp.domain.Resolution;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Locale;
import java.util.concurrent.TimeUnit;

public class ComposerMediaFileInfoCoreActivity extends ComposerTranscodeCoreActivity implements SurfaceHolder.Callback {

    private TextView sliderPositionTextView;
    private long sliderPosition = 0;

    @Override
    protected void setupUI()
    {
        buttonStart.setVisibility(View.GONE);
        buttonStop.setVisibility(View.GONE);

        findViewById(R.id.transcodeParametersLayout).setVisibility(View.GONE);

        sliderPositionTextView = (TextView) findViewById(R.id.pathInfo);

        SeekBar seekBar = new SeekBar(this);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        lp.setMargins(8, 8, 8, 0);
        seekBar.setLayoutParams(lp);
        seekBar.setProgress(0);
        seekBar.setMax(100);

        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            int progressChanged = 0;

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                progressChanged = progress;
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

                try {
                    // call preview method right here
                    sliderPosition = (long) ((double) progressChanged / (100.0) * (double) duration);
                    sliderPositionTextView.setText(String.format("slider position = %.1f sec\n", (double) sliderPosition / 10e5));
                    pathInfo.append(String.format("mediaFileName = %s\n", srcMediaName1));

                    ByteBuffer buffer = ByteBuffer.allocate(1);
                    mediaFileInfo.getFrameAtPosition(sliderPosition, buffer);
                } catch (NullPointerException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });

        LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);
        layout.addView(seekBar, 0);
    }

    protected void printFileInfo() {

        String videoInfoString = "No video info available\n";
        String audioInfoString = "No audio info available\n";

        sliderPositionTextView.setText(String.format("slider position = %.1f sec\n", (double) sliderPosition / 1e6));

        //video format
        try {
            Resolution resolution = videoFormat.getVideoFrameSize();
            String videoCodec = videoFormat.getVideoCodec();

            pathInfo =  (TextView) findViewById(R.id.pathInfo);
            pathInfo.append(String.format("mediaFileName = %s\n", srcMediaName1));

            durationInfo = (TextView) findViewById(R.id.durationInfo);
            durationInfo.setText(String.format("duration = %d sec", TimeUnit.MICROSECONDS.toSeconds(duration)));

            videoInfoString = String.format(Locale.getDefault(), "Video Info\n\n" +
                "video codec = %s\n" +
                "width = %d\n" +
                "height = %d\n\n",
                videoCodec, resolution.width(), resolution.height());

        } catch (NullPointerException e) {
            e.printStackTrace();
        }

        //audio format
        try {
            int aacProfile = audioFormat.getAudioProfile();
            String audioCodec = audioFormat.getAudioCodec();

            String mimeType = audioFormat.getMimeType();

            int channelCount = audioFormat.getAudioChannelCount();
            int sampleRate = audioFormat.getAudioSampleRateInHz();

            audioInfoString = String.format(Locale.getDefault(), "Audio Info\n\n" +
                "channel count = %d\n" +
                "sample rate = %d Hz\n" +
                "mime type = %s\n" +
                "aac profile = %d\n" +
                "audio codec = %s\n",
                channelCount, sampleRate, mimeType,
                aacProfile, audioCodec );

        } catch (NullPointerException e) {
            e.printStackTrace();
        }

        transcodeInfoView.setText(videoInfoString);
        transcodeInfoView.append(audioInfoString);
    }
}




Java Source Code List

com.intel.inde.mp.android.graphics.EglUtil.java
com.intel.inde.mp.android.graphics.FrameBuffer.java
com.intel.inde.mp.android.graphics.FullFrameTexture.java
com.intel.inde.mp.android.graphics.ShaderProgram.java
com.intel.inde.mp.android.graphics.VideoEffect.java
com.intel.inde.mp.effects.AudioEffect.java
com.intel.inde.mp.effects.AudioReader.java
com.intel.inde.mp.effects.GrayScaleEffect.java
com.intel.inde.mp.effects.InverseEffect.java
com.intel.inde.mp.effects.JpegSubstituteEffect.java
com.intel.inde.mp.effects.OverlayEffect.java
com.intel.inde.mp.effects.RotateEffect.java
com.intel.inde.mp.effects.SepiaEffect.java
com.intel.inde.mp.effects.SubstituteAudioEffect.java
com.intel.inde.mp.effects.TextOverlayEffect.java
com.intel.inde.mp.samples.ActivityWithTimeline.java
com.intel.inde.mp.samples.CameraCapturerActivity.java
com.intel.inde.mp.samples.CameraStreamerActivity.java
com.intel.inde.mp.samples.ComposerAudioEffectActivity.java
com.intel.inde.mp.samples.ComposerAudioEffectCoreActivity.java
com.intel.inde.mp.samples.ComposerCutActivity.java
com.intel.inde.mp.samples.ComposerCutCoreActivity.java
com.intel.inde.mp.samples.ComposerJoinActivity.java
com.intel.inde.mp.samples.ComposerJoinCoreActivity.java
com.intel.inde.mp.samples.ComposerMediaFileInfoActivity.java
com.intel.inde.mp.samples.ComposerMediaFileInfoCoreActivity.java
com.intel.inde.mp.samples.ComposerTranscodeActivity.java
com.intel.inde.mp.samples.ComposerTranscodeCoreActivity.java
com.intel.inde.mp.samples.ComposerVideoEffectActivity.java
com.intel.inde.mp.samples.ComposerVideoEffectCoreActivity.java
com.intel.inde.mp.samples.DemoListAdapter.java
com.intel.inde.mp.samples.DemoListItem.java
com.intel.inde.mp.samples.ExpandableSamplesListAdapter.java
com.intel.inde.mp.samples.FPSCounter.java
com.intel.inde.mp.samples.Format.java
com.intel.inde.mp.samples.GameCapturing.java
com.intel.inde.mp.samples.GameRenderer.java
com.intel.inde.mp.samples.GameStreaming.java
com.intel.inde.mp.samples.MediaStreamerActivity.java
com.intel.inde.mp.samples.MediaStreamerCoreActivity.java
com.intel.inde.mp.samples.RecognitionActivity.java
com.intel.inde.mp.samples.SamplesMainActivity.java
com.intel.inde.mp.samples.VideoCapture.java
com.intel.inde.mp.samples.VideoPlayerActivity.java
com.intel.inde.mp.samples.VideoStreamPlayerActivity.java
com.intel.inde.mp.samples.controls.CameraCaptureSettingsPopup.java
com.intel.inde.mp.samples.controls.GameGLSurfaceView.java
com.intel.inde.mp.samples.controls.PlaybackToolbar.java
com.intel.inde.mp.samples.controls.PopupMessage.java
com.intel.inde.mp.samples.controls.Popup.java
com.intel.inde.mp.samples.controls.RangeSelector.java
com.intel.inde.mp.samples.controls.TimelineItem.java
com.intel.inde.mp.samples.controls.TranscodeSurfaceView.java
com.intel.inde.mp.samples.controls.VideoPlayer.java