Search in sources :

Example 51 with MediaInfo

use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_advance by LanSoSdk.

the class ExtractVideoFrameDemoActivity method testGetFirstOnekey.

/**
 * 临时为了获取一个bitmap图片,临时测试. 可以用来作为视频的封面.
 *
 * @param src
 */
public static void testGetFirstOnekey(String src) {
    long decoderHandler = 0;
    IntBuffer mGLRgbBuffer;
    MediaInfo info = new MediaInfo(src);
    if (info.prepare()) {
        decoderHandler = AVDecoder.decoderInit(src);
        if (decoderHandler != 0) {
            mGLRgbBuffer = IntBuffer.allocate(info.vWidth * info.vHeight);
            mGLRgbBuffer.position(0);
            AVDecoder.decoderFrame(decoderHandler, -1, mGLRgbBuffer.array());
            AVDecoder.decoderRelease(decoderHandler);
            // 转换为bitmap
            Bitmap stitchBmp = Bitmap.createBitmap(info.vWidth, info.vHeight, Bitmap.Config.ARGB_8888);
            stitchBmp.copyPixelsFromBuffer(mGLRgbBuffer);
            /**
             * 这里是保存到文件, 仅仅用来测试, 实际您可以不用保存到文件.
             */
            // 您可以修改下, 然后返回bitmap
            savePng(stitchBmp);
            // 这里得到的图像在mGLRgbBuffer中, 可以用来返回一张图片.
            decoderHandler = 0;
        }
    } else {
        Log.e("TAG", "get first one key error!");
    }
}
Also used : Bitmap(android.graphics.Bitmap) MediaInfo(com.lansosdk.videoeditor.MediaInfo) IntBuffer(java.nio.IntBuffer)

Example 52 with MediaInfo

use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_advance by LanSoSdk.

the class CanvasLayerDemoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.canvaslayer_demo_layout);
    mVideoPath = getIntent().getStringExtra("videopath");
    mInfo = new MediaInfo(mVideoPath, false);
    if (mInfo.prepare() == false) {
        Log.e(TAG, " video path is error.finish\n");
        finish();
    }
    mDrawPadView = (DrawPadView) findViewById(R.id.id_canvaslayer_drawpadview);
    playVideo = (LinearLayout) findViewById(R.id.id_canvasLayer_saveplay);
    playVideo.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if (SDKFileUtils.fileExist(dstPath)) {
                Intent intent = new Intent(CanvasLayerDemoActivity.this, VideoPlayerActivity.class);
                intent.putExtra("videopath", dstPath);
                startActivity(intent);
            } else {
                Toast.makeText(CanvasLayerDemoActivity.this, "目标文件不存在", Toast.LENGTH_SHORT).show();
            }
        }
    });
    playVideo.setVisibility(View.GONE);
    // 在手机的默认路径下创建一个文件名,用来保存生成的视频文件,(在onDestroy中删除)
    editTmpPath = SDKFileUtils.newMp4PathInBox();
    dstPath = SDKFileUtils.newMp4PathInBox();
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub
            // showHintDialog();
            startPlayVideo();
        }
    }, 500);
}
Also used : MediaInfo(com.lansosdk.videoeditor.MediaInfo) CanvasRunnable(com.lansosdk.box.CanvasRunnable) OnClickListener(android.view.View.OnClickListener) Handler(android.os.Handler) Intent(android.content.Intent) View(android.view.View) DrawPadView(com.lansosdk.videoeditor.DrawPadView) TextView(android.widget.TextView)

Example 53 with MediaInfo

use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_advance by LanSoSdk.

the class Demo1LayerMothedActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.drawpad_layout);
    videoPath = getIntent().getStringExtra("videopath");
    mInfo = new MediaInfo(videoPath, false);
    if (mInfo.prepare() == false) {
        Toast.makeText(this, "传递过来的视频文件错误", Toast.LENGTH_SHORT).show();
        this.finish();
    }
    drawPadView = (DrawPadView) findViewById(R.id.DrawPad_view);
    initView();
    // 在手机的默认路径下创建一个文件名,用来保存生成的视频文件,(在onDestroy中删除)
    editTmpPath = SDKFileUtils.newMp4PathInBox();
    dstPath = SDKFileUtils.newMp4PathInBox();
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            startPlayVideo();
        }
    }, 300);
    playVideo.setVisibility(View.INVISIBLE);
}
Also used : MediaInfo(com.lansosdk.videoeditor.MediaInfo) Handler(android.os.Handler)

Example 54 with MediaInfo

use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_advance by LanSoSdk.

the class Demo2LayerMothedActivity method initDrawPad.

/**
 * Step1:  init Drawpad  初始化DrawPad
 */
private void initDrawPad(MediaPlayer mp) {
    mInfo = new MediaInfo(mVideoPath, false);
    if (mInfo.prepare()) {
        drawPadView.setUpdateMode(DrawPadUpdateMode.ALL_VIDEO_READY, 25);
        drawPadView.setRealEncodeEnable(480, 480, 1000000, (int) mInfo.vFrameRate, editTmpPath);
        /**
         * 设置当前DrawPad的宽度和高度,并把宽度自动缩放到父view的宽度,然后等比例调整高度.
         */
        drawPadView.setDrawPadSize(480, 480, new onDrawPadSizeChangedListener() {

            @Override
            public void onSizeChanged(int viewWidth, int viewHeight) {
                startDrawPad();
            }
        });
    }
}
Also used : com.lansosdk.box.onDrawPadSizeChangedListener(com.lansosdk.box.onDrawPadSizeChangedListener) MediaInfo(com.lansosdk.videoeditor.MediaInfo) Paint(android.graphics.Paint)

Example 55 with MediaInfo

use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_common by LanSoSdk.

the class DemoFunctions method demoAudioCut.

/**
 * 演示音频截取
 *
 * 音频剪切:\n剪切音频的长度,可以指定开始位置,指定结束位置.\n这里演示截取音频的前20秒或时长的一半,形成新的音频文件.
 */
public static int demoAudioCut(Context ctx, VideoEditor editor, String dstAudio) {
    String srcAudio = CopyDefaultVideoAsyncTask.copyFile(ctx, "honor30s2.m4a");
    MediaInfo info = new MediaInfo(srcAudio);
    if (info.prepare() && info.aCodecName != null) {
        if (info.aDuration > 15)
            return editor.executeAudioCutOut(srcAudio, dstAudio, 0, 15);
        else
            return editor.executeAudioCutOut(srcAudio, dstAudio, 0, info.aDuration / 2);
    } else {
        return -1;
    }
}
Also used : MediaInfo(com.lansosdk.videoeditor.MediaInfo)

Aggregations

MediaInfo (com.lansosdk.videoeditor.MediaInfo)59 Handler (android.os.Handler)12 com.lansosdk.box.onDrawPadSizeChangedListener (com.lansosdk.box.onDrawPadSizeChangedListener)9 Paint (android.graphics.Paint)8 TextView (android.widget.TextView)6 Intent (android.content.Intent)5 View (android.view.View)5 OnClickListener (android.view.View.OnClickListener)5 CanvasRunnable (com.lansosdk.box.CanvasRunnable)5 DrawPad (com.lansosdk.box.DrawPad)5 Bitmap (android.graphics.Bitmap)4 DrawPadView (com.lansosdk.videoeditor.DrawPadView)4 File (java.io.File)3 SurfaceTexture (android.graphics.SurfaceTexture)2 MediaPlayer (android.media.MediaPlayer)2 DisplayMetrics (android.util.DisplayMetrics)2 Surface (android.view.Surface)2 SurfaceTextureListener (android.view.TextureView.SurfaceTextureListener)2 VideoPlayerActivity (com.example.advanceDemo.VideoPlayerActivity)2 DrawPadVideoRunnable (com.lansosdk.box.DrawPadVideoRunnable)2