Search in sources :

Example 11 with DrawPad

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

the class TextureLayerDemoActivity method initDrawPad.

private void initDrawPad() {
    drawPadView.setUpdateMode(DrawPadUpdateMode.AUTO_FLUSH, 30);
    drawPadView.setOnDrawPadThreadProgressListener(new onDrawPadThreadProgressListener() {

        @Override
        public void onThreadProgress(DrawPad v, long currentTimeUs) {
            addTextureLayer();
        }
    });
    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.onDrawPadThreadProgressListener(com.lansosdk.box.onDrawPadThreadProgressListener)

Example 12 with DrawPad

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

the class VHeaderConcat method start.

public void start(Context ctx, String videoHeader, String recordVideo) {
    this.recordVideo = recordVideo;
    videoPath = videoHeader;
    mInfo = new MediaInfo(recordVideo);
    if (mInfo.prepare()) {
        int padWidth = mInfo.vWidth;
        int padHeight = mInfo.vHeight;
        if (mInfo.vRotateAngle == 90 || mInfo.vRotateAngle == 270) {
            padWidth = mInfo.vHeight;
            padHeight = mInfo.vWidth;
        }
        editTmpPath = SDKFileUtils.newMp4PathInBox();
        dstPath = SDKFileUtils.newMp4PathInBox();
        /**
         * 片头缩放成 recordVideo的尺寸.
         */
        mDrawPad = new DrawPadVideoExecute(ctx, videoPath, padWidth, padHeight, (int) (mInfo.vBitRate * 1.5f), null, editTmpPath);
        mDrawPad.setUseMainVideoPts(true);
        /**
         * 设置DrawPad处理完成后的监听.
         */
        mDrawPad.setDrawPadCompletedListener(new onDrawPadCompletedListener() {

            @Override
            public void onCompleted(DrawPad v) {
                // TODO Auto-generated method stub
                drawPadCompleted();
            }
        });
        mDrawPad.pauseRecord();
        if (mDrawPad.startDrawPad()) {
            // 开始恢复处理.
            mDrawPad.resumeRecord();
        }
    }
}
Also used : DrawPad(com.lansosdk.box.DrawPad) DrawPadVideoExecute(com.lansosdk.videoeditor.DrawPadVideoExecute) MediaInfo(com.lansosdk.videoeditor.MediaInfo) com.lansosdk.box.onDrawPadCompletedListener(com.lansosdk.box.onDrawPadCompletedListener)

Example 13 with DrawPad

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

the class CameraLayerFullPortActivity method initDrawPad.

/**
 * Step1: 开始运行 DrawPad 容器
 */
private void initDrawPad() {
    int padWidth = 544;
    int padHeight = 960;
    /**
     * 设置录制时的一些参数.
     */
    mDrawPadCamera.setRealEncodeEnable(padWidth, padHeight, 3000 * 1024, (int) 25, dstPath);
    /**
     * 设置录制处理进度监听.
     */
    mDrawPadCamera.setOnDrawPadProgressListener(drawPadProgressListener);
    /**
     * 相机前后置.是否设置滤镜.
     */
    mDrawPadCamera.setCameraParam(false, null, true);
    /**
     * 当手动聚焦的时候, 返回聚焦点的位置,让focusView去显示一个聚焦的动画.
     */
    mDrawPadCamera.setCameraFocusListener(new doFousEventListener() {

        @Override
        public void onFocus(int x, int y) {
            focusView.startFocus(x, y);
        }
    });
    mDrawPadCamera.setRecordMic(true);
    /**
     * UI界面有效后, 开始开启DrawPad线程, 来预览画面.
     */
    mDrawPadCamera.setOnViewAvailable(new onViewAvailable() {

        @Override
        public void viewAvailable(DrawPadCameraView v) {
            startDrawPad();
        }
    });
    mDrawPadCamera.setOnDrawPadErrorListener(new onDrawPadErrorListener() {

        @Override
        public void onError(DrawPad d, int what) {
            Log.e(TAG, "DrawPad容器线程运行出错!!!" + what);
        }
    });
}
Also used : DrawPad(com.lansosdk.box.DrawPad) DrawPadCameraView(com.lansosdk.videoeditor.DrawPadCameraView) DrawPadCameraView.doFousEventListener(com.lansosdk.videoeditor.DrawPadCameraView.doFousEventListener) DrawPadCameraView.onViewAvailable(com.lansosdk.videoeditor.DrawPadCameraView.onViewAvailable) com.lansosdk.box.onDrawPadErrorListener(com.lansosdk.box.onDrawPadErrorListener)

Example 14 with DrawPad

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

the class VideoOneDo method startDrawPad.

private boolean startDrawPad() {
    // 先判断有无裁剪画面
    if (cropHeight > 0 && cropWidth > 0) {
        fileParamter = new FileParameter();
        fileParamter.setDataSoure(videoPath);
        /**
         * 设置当前需要显示的区域 ,以左上角为0,0坐标.
         *
         * @param startX  开始的X坐标, 即从宽度的什么位置开始
         * @param startY  开始的Y坐标, 即从高度的什么位置开始
         * @param cropW   需要显示的宽度
         * @param cropH   需要显示的高度.
         */
        fileParamter.setShowRect(startX, startY, cropWidth, cropHeight);
        fileParamter.setStartTimeUs(startTimeUs);
        int padWidth = cropWidth;
        int padHeight = cropHeight;
        if (scaleHeight > 0 && scaleWidth > 0) {
            padWidth = scaleWidth;
            padHeight = scaleHeight;
        }
        float f = (float) (padHeight * padWidth) / (float) (fileParamter.info.vWidth * fileParamter.info.vHeight);
        float bitrate = f * fileParamter.info.vBitRate * compressFactor * 2.0f;
        drawPad = new DrawPadVideoExecute(context, fileParamter, padWidth, padHeight, (int) bitrate, videoFilter, dstPath);
    } else {
        // 没有裁剪
        int padWidth = srcInfo.getWidth();
        int padHeight = srcInfo.getHeight();
        float bitrate = (float) srcInfo.vBitRate * compressFactor * 1.5f;
        if (scaleHeight > 0 && scaleWidth > 0) {
            padWidth = scaleWidth;
            padHeight = scaleHeight;
            float f = (float) (padHeight * padWidth) / (float) (srcInfo.vWidth * srcInfo.vHeight);
            bitrate *= f;
        }
        drawPad = new DrawPadVideoExecute(context, videoPath, startTimeUs, padWidth, padHeight, (int) bitrate, videoFilter, dstPath);
    }
    drawPad.setUseMainVideoPts(true);
    drawPad.setDrawPadErrorListener(new onDrawPadErrorListener() {

        @Override
        public void onError(DrawPad d, int what) {
            if (monVideoOneDoErrorListener != null) {
                monVideoOneDoErrorListener.oError(VideoOneDo.this, VIDEOONEDO_ERROR_DRAWPAD);
            }
        }
    });
    /**
     * 设置DrawPad处理的进度监听, 回传的currentTimeUs单位是微秒.
     */
    drawPad.setDrawPadProgressListener(new onDrawPadProgressListener() {

        @Override
        public void onProgress(DrawPad v, long currentTimeUs) {
            progressCallback(v, currentTimeUs);
            if (monVideoOneDoProgressListener != null) {
                float time = (float) currentTimeUs / 1000000f;
                float percent = time / (float) tmpvDuration;
                // 保留两位小数.
                float b = (float) (Math.round(percent * 100)) / 100;
                if (b < 1.0f && monVideoOneDoProgressListener != null && isExecuting) {
                    monVideoOneDoProgressListener.onProgress(VideoOneDo.this, b);
                }
            }
            if (cutDurationUs > 0 && currentTimeUs > cutDurationUs) {
                // 设置了结束时间, 如果当前时间戳大于结束时间,则停止容器.
                drawPad.stopDrawPad();
            }
        }
    });
    // 容器内部的进度回调.
    drawPad.setDrawPadThreadProgressListener(new onDrawPadThreadProgressListener() {

        @Override
        public void onThreadProgress(DrawPad v, long currentTimeUs) {
            progressThreadCallback(v, currentTimeUs);
        }
    });
    /**
     * 设置DrawPad处理完成后的监听.
     */
    drawPad.setDrawPadCompletedListener(new onDrawPadCompletedListener() {

        @Override
        public void onCompleted(DrawPad v) {
            completeDrawPad();
        }
    });
    /**
     * 增加音频参数.
     */
    addAudioParamter();
    /**
     * 增加时间拉伸.
     */
    if (timeStretchArray != null) {
        drawPad.addTimeStretch(timeStretchArray);
    }
    if (timeRepeatArray != null) {
        drawPad.addTimeRepeat(timeRepeatArray);
    }
    if (timeFreezeArray != null) {
        drawPad.addTimeFreeze(timeFreezeArray);
    }
    drawPad.pauseRecord();
    if (drawPad.startDrawPad()) {
        videoLayer = drawPad.getMainVideoLayer();
        videoLayer.setScaledValue(videoLayer.getPadWidth(), videoLayer.getPadHeight());
        // 增加图片图层
        addBitmapLayer();
        // 增加文字图层.
        addCanvasLayer();
        // 开始恢复处理.
        drawPad.resumeRecord();
        return true;
    } else {
        return false;
    }
}
Also used : DrawPad(com.lansosdk.box.DrawPad) com.lansosdk.box.onDrawPadErrorListener(com.lansosdk.box.onDrawPadErrorListener) com.lansosdk.box.onDrawPadProgressListener(com.lansosdk.box.onDrawPadProgressListener) FileParameter(com.lansosdk.box.FileParameter) com.lansosdk.box.onDrawPadThreadProgressListener(com.lansosdk.box.onDrawPadThreadProgressListener) com.lansosdk.box.onDrawPadCompletedListener(com.lansosdk.box.onDrawPadCompletedListener) Paint(android.graphics.Paint)

Example 15 with DrawPad

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

the class BitmapPadExecute method init.

/**
 * 准备一下,
 * 执行建立DrawPad, 配置各种选项.
 *
 * @param width  读取图片时的宽度,
 * @param height 读取图片时的高度.
 * @return
 */
public boolean init(int width, int height) {
    // 创建pad,并设置禁止编码, outframe回调.
    mDrawPad = new DrawPadPictureExecute(mContext, width, height, -1, 25, 1000000, null);
    mDrawPad.setDisableEncode(true);
    mDrawPad.setOutFrameInDrawPad(true);
    mDrawPad.setCheckDrawPadSize(true);
    mDrawPad.setDrawPadOutFrameListener(true, new onDrawPadOutFrameListener() {

        @Override
        public void onDrawPadOutFrame(DrawPad v, Object obj, int type, long ptsUs) {
            // TODO Auto-generated method stub
            Bitmap bmp = (Bitmap) obj;
            if (bmp != null && mDrawPad != null) {
                mDrawPad.pauseRecord();
                mDrawPad.resetOutFrames();
                OutBmp = bmp;
                notifyReady();
            }
        }
    });
    /**
     * 设置暂停标志, 然后开启DrawPad
     */
    mDrawPad.pauseRecord();
    return mDrawPad.startDrawPad();
}
Also used : com.lansosdk.box.onDrawPadOutFrameListener(com.lansosdk.box.onDrawPadOutFrameListener) DrawPad(com.lansosdk.box.DrawPad) Bitmap(android.graphics.Bitmap)

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