Search in sources :

Example 26 with DrawPad

use of com.lansosdk.box.DrawPad in project LanSoEditor_advance by LanSoSdk.

the class ExecuteVideoLayerActivity method addDataLayer.

/**
 * 增加一个DataLayer, 数据图层. 数据图层是可以把外界的数据图片RGBA, 作为一个图层, 传到到DrawPad中.
 * <p>
 * 流程是: 把gif作为一个视频文件, 一帧一帧的解码,把解码得到的数据通过DataLayer传递到容器中.
 */
private void addDataLayer() {
    String gifPath = CopyDefaultVideoAsyncTask.copyFile(getApplicationContext(), "a.gif");
    gifInfo = new MediaInfo(gifPath);
    if (gifInfo.prepare()) {
        decoderHandler = BoxDecoder.decoderInit(gifPath);
        mGLRgbBuffer = IntBuffer.allocate(gifInfo.vWidth * gifInfo.vHeight);
        gifInterval = (int) (mInfo.vFrameRate / gifInfo.vFrameRate);
        dataLayer = mDrawPad.addDataLayer(gifInfo.vWidth, gifInfo.vHeight);
        /**
         * 容器中的onDrawPadThreadProgressListener监听,与 onDrawPadProgressListener不同的地方在于:
         * 此回调是在DrawPad渲染完一帧后,立即执行这个回调中的代码,不通过Handler传递出去.
         */
        mDrawPad.setDrawPadThreadProgressListener(new onDrawPadThreadProgressListener() {

            @Override
            public void onThreadProgress(DrawPad v, long currentTimeUs) {
                // TODO Auto-generated method stub
                if (dataLayer != null) {
                    if (canDrawNext()) {
                        int seekZero = -1;
                        if (decoderHandler != 0 && BoxDecoder.decoderIsEnd(decoderHandler)) {
                            seekZero = 0;
                        }
                        BoxDecoder.decoderFrame(decoderHandler, seekZero, mGLRgbBuffer.array());
                        dataLayer.pushFrameToTexture(mGLRgbBuffer);
                        mGLRgbBuffer.position(0);
                    }
                }
            }
        });
    }
}
Also used : DrawPad(com.lansosdk.box.DrawPad) MediaInfo(com.lansosdk.videoeditor.MediaInfo) com.lansosdk.box.onDrawPadThreadProgressListener(com.lansosdk.box.onDrawPadThreadProgressListener)

Example 27 with DrawPad

use of com.lansosdk.box.DrawPad in project LanSoEditor_advance by LanSoSdk.

the class ExecuteVideoLayerActivity method startDrawPad.

/**
 * 从这里开始演示.
 */
private void startDrawPad() {
    if (isExecuting)
        return;
    isExecuting = true;
    mDrawPad = new DrawPadVideoExecute(mContext, videoPath, 480, 480, 1000 * 1000, null, editTmpPath);
    mDrawPad.setUpdateMode(DrawPadUpdateMode.AUTO_FLUSH, (int) mInfo.vFrameRate);
    mDrawPad.setDrawPadErrorListener(new onDrawPadErrorListener() {

        @Override
        public void onError(DrawPad d, int what) {
            // TODO Auto-generated method stub
            mDrawPad.stopDrawPad();
            Log.e(TAG, "后台容器线程 运行失败,您请检查下是否码率分辨率设置过大,或者联系我们!...");
        }
    });
    /**
     * 设置DrawPad处理的进度监听, 回传的currentTimeUs单位是微秒.
     */
    mDrawPad.setDrawPadProgressListener(new onDrawPadProgressListener() {

        @Override
        public void onProgress(DrawPad v, long currentTimeUs) {
            // TODO Auto-generated method stub
            tvProgressHint.setText(String.valueOf(currentTimeUs));
            // 6秒后消失
            if (currentTimeUs > 6000000 && bitmapLayer != null)
                v.removeLayer(bitmapLayer);
            else if (// 3秒的时候,放大一倍.
            currentTimeUs > 3000000 && bitmapLayer != null)
                bitmapLayer.setScale(2.0f);
        }
    });
    /**
     * 设置DrawPad完成后的监听.
     */
    mDrawPad.setDrawPadCompletedListener(new onDrawPadCompletedListener() {

        @Override
        public void onCompleted(DrawPad v) {
            // TODO Auto-generated method stub
            tvProgressHint.setText("DrawPadExecute Completed!!!");
            isExecuting = false;
            if (isInsertAudio) {
                // 如果增加了其他声音, 则会在内部合成声音, 外界无需另外addAudio的操作, 这是和别的Drawpad操作不同之处.
                dstPath = editTmpPath;
            } else {
                if (SDKFileUtils.fileExist(editTmpPath)) {
                    boolean ret = VideoEditor.encoderAddAudio(videoPath, editTmpPath, SDKDir.TMP_DIR, dstPath);
                    if (ret == false) {
                        dstPath = editTmpPath;
                    }
                }
            }
            findViewById(R.id.id_video_edit_btn2).setEnabled(true);
        }
    });
    mDrawPad.setDrawPadThreadProgressListener(new onDrawPadThreadProgressListener() {

        @Override
        public void onThreadProgress(DrawPad v, long currentTimeUs) {
        // TODO Auto-generated method stub
        }
    });
    // mDrawPad.setUseMainVideoPts(true);
    addOtherAudio();
    // 在开启前,先设置为暂停录制,因为要增加一些图层.
    mDrawPad.pauseRecord();
    /**
     * 开始执行这个DrawPad
     */
    if (mDrawPad.startDrawPad()) {
        // 增加一些图层.
        addLayers();
    } else {
        Log.e(TAG, "后台容器线程  运行失败,您请检查下是否是路径设置有无, 请用MediaInfo.checkFile执行查看下....");
    }
}
Also used : DrawPad(com.lansosdk.box.DrawPad) DrawPadVideoExecute(com.lansosdk.videoeditor.DrawPadVideoExecute) com.lansosdk.box.onDrawPadErrorListener(com.lansosdk.box.onDrawPadErrorListener) com.lansosdk.box.onDrawPadProgressListener(com.lansosdk.box.onDrawPadProgressListener) com.lansosdk.box.onDrawPadThreadProgressListener(com.lansosdk.box.onDrawPadThreadProgressListener) com.lansosdk.box.onDrawPadCompletedListener(com.lansosdk.box.onDrawPadCompletedListener) Paint(android.graphics.Paint)

Example 28 with DrawPad

use of com.lansosdk.box.DrawPad in project LanSoEditor_advance by LanSoSdk.

the class BitmapLayerFilterDemoActivity method initDrawPad.

/**
 * Step1: 初始化DrawPad
 */
private void initDrawPad() {
    // 设置为自动刷新模式, 帧率为25
    drawPadView.setUpdateMode(DrawPadUpdateMode.AUTO_FLUSH, 30);
    // 使能实时录制,并设置录制后视频的宽度和高度, 码率, 帧率,保存路径.
    drawPadView.setRealEncodeEnable(480, 480, 1200 * 1000, (int) 30, dstPath);
    drawPadView.setOnDrawPadCompletedListener(new onDrawPadCompletedListener() {

        @Override
        public void onCompleted(DrawPad v) {
            // TODO Auto-generated method stub
            if (isDestorying == false) {
                if (SDKFileUtils.fileExist(dstPath)) {
                    findViewById(R.id.id_DrawPad_saveplay).setVisibility(View.VISIBLE);
                }
                toastStop();
            }
        }
    });
    drawPadView.setOnDrawPadProgressListener(new onDrawPadProgressListener() {

        @Override
        public void onProgress(DrawPad v, long currentTimeUs) {
            if (// 26秒.多出一秒,让图片走完.
            currentTimeUs >= 20 * 1000 * 1000) {
                drawPadView.stopDrawPad();
            }
        }
    });
    // 设置DrawPad的宽高, 这里设置为480x480,如果您已经在xml中固定大小,则不需要再次设置,
    // 可以直接调用startDrawPad来开始录制.
    drawPadView.setDrawPadSize(480, 480, new onDrawPadSizeChangedListener() {

        @Override
        public void onSizeChanged(int viewWidth, int viewHeight) {
            startDrawPad();
        }
    });
}
Also used : DrawPad(com.lansosdk.box.DrawPad) com.lansosdk.box.onDrawPadSizeChangedListener(com.lansosdk.box.onDrawPadSizeChangedListener) com.lansosdk.box.onDrawPadProgressListener(com.lansosdk.box.onDrawPadProgressListener) com.lansosdk.box.onDrawPadCompletedListener(com.lansosdk.box.onDrawPadCompletedListener)

Aggregations

DrawPad (com.lansosdk.box.DrawPad)28 com.lansosdk.box.onDrawPadProgressListener (com.lansosdk.box.onDrawPadProgressListener)16 com.lansosdk.box.onDrawPadSizeChangedListener (com.lansosdk.box.onDrawPadSizeChangedListener)10 Paint (android.graphics.Paint)9 com.lansosdk.box.onDrawPadCompletedListener (com.lansosdk.box.onDrawPadCompletedListener)9 com.lansosdk.box.onDrawPadThreadProgressListener (com.lansosdk.box.onDrawPadThreadProgressListener)9 com.lansosdk.box.onDrawPadErrorListener (com.lansosdk.box.onDrawPadErrorListener)7 DrawPadCameraView (com.lansosdk.videoeditor.DrawPadCameraView)5 DrawPadCameraView.onViewAvailable (com.lansosdk.videoeditor.DrawPadCameraView.onViewAvailable)5 MediaInfo (com.lansosdk.videoeditor.MediaInfo)5 DrawPadCameraView.doFousEventListener (com.lansosdk.videoeditor.DrawPadCameraView.doFousEventListener)4 com.lansosdk.box.onDrawPadOutFrameListener (com.lansosdk.box.onDrawPadOutFrameListener)3 DrawPadVideoExecute (com.lansosdk.videoeditor.DrawPadVideoExecute)3 Bitmap (android.graphics.Bitmap)2 DrawPadView (com.lansosdk.videoeditor.DrawPadView)2 DrawPadView.onViewAvailable (com.lansosdk.videoeditor.DrawPadView.onViewAvailable)2 DialogInterface (android.content.DialogInterface)1 Surface (android.view.Surface)1 OnClickListener (android.view.View.OnClickListener)1 DrawPadAllExecute (com.lansosdk.box.DrawPadAllExecute)1