Search in sources :

Example 1 with VideoOneDo

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

the class VideoOneProcessActivity method startDrawPadProcess.

/**
 * 开始处理.
 */
private void startDrawPadProcess() {
    if (isRunning) {
        return;
    }
    videoOneDo = new VideoOneDo(getApplicationContext(), videoPath);
    videoOneDo.setOnVideoOneDoProgressListener(new onVideoOneDoProgressListener() {

        @Override
        public void onProgress(VideoOneDo v, float percent) {
            if (progressDialog != null) {
                progressDialog.setMessage("正在处理中..." + String.valueOf(percent * 100) + "%");
            }
        }
    });
    videoOneDo.setOnVideoOneDoCompletedListener(new onVideoOneDoCompletedListener() {

        @Override
        public void onCompleted(VideoOneDo v, String dstVideo) {
            dstPath = dstVideo;
            isRunning = false;
            cancelProgressDialog();
            showHintDialog("视频执行完毕, 点击开始预览结果.", true);
        }
    });
    if (isMusicEnable) {
        // 增加音乐
        String music = CopyFileFromAssets.copyAssets(mContext, "summer10s.mp3");
        videoOneDo.setBackGroundMusic(music, isMusicMix, 0.8f);
    // videoOneDo.setBackGroundMusic(music);
    // videoOneDo.setBackGroundMusic(music, isMusicMix, 0.5f, 1.5f);
    // videoOneDo.setBackGroundMusic(music, 3.0f, 8.0f, isMusicMix, 0.2f,2.0f);
    }
    if (isScaleEnable) {
        // 是否缩放.
        videoOneDo.setScaleWidth((int) (mInfo.getWidth() * scaleFactor), (int) (mInfo.getHeight() * scaleFactor));
    }
    if (isCompressEnable) {
        // 是否压缩
        videoOneDo.setCompressPercent(compressFactor);
    }
    if (// 是否时长剪切
    isCutDurationEnable) {
        videoOneDo.setStartPostion(startTimeUs);
        videoOneDo.setCutDuration(cutDurationUs);
    }
    if (isFilterEnable && mFilter != null) {
        // 是否增加滤镜.
        videoOneDo.setFilter(mFilter);
        // 因为滤镜对象只能被执行一次, 如再次执行,则需要重新创建对象.故这里使用后等于null,并设置UI为no
        mFilter = null;
        isFilterEnable = false;
        switchBackImage(R.id.id_oendo_filter_switch, isFilterEnable);
    }
    // 横屏OK
    if (isCropEnable) {
        // 是否画面裁剪
        // //这里为了代码清晰, 取视频中间的2/3画面为裁剪, 实际您可以任意裁剪.
        // 中间2/3,则裁剪掉1/3, 则左上角是一半,为1/6;
        int startX = mInfo.getWidth() / 6;
        int startY = mInfo.getHeight() / 6;
        int cropW = mInfo.getWidth() * 2 / 3;
        int cropH = mInfo.getHeight() * 2 / 3;
        videoOneDo.setCropRect(startX, startY, cropW, cropH);
    }
    if (isAddLogoEnable) {
        // 增加logo
        Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
        videoOneDo.setLogo(bmp, VideoOneDo.LOGO_POSITION_RIGHT_TOP);
    }
    if (isAddWordEnable) {
        // 增加文字.
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss ");
        // 获取当前时间
        Date curDate = new Date(System.currentTimeMillis());
        String str = formatter.format(curDate);
        videoOneDo.setText("蓝松SDK演示文字:" + str);
    }
    // 开始执行.
    if (videoOneDo.start()) {
        isRunning = true;
        showProgressDialog();
    } else {
        showHintDialog("视频执行错误!,请查看打印信息或联系我们.", false);
    }
}
Also used : Bitmap(android.graphics.Bitmap) com.lansosdk.videoeditor.onVideoOneDoProgressListener(com.lansosdk.videoeditor.onVideoOneDoProgressListener) com.lansosdk.videoeditor.onVideoOneDoCompletedListener(com.lansosdk.videoeditor.onVideoOneDoCompletedListener) VideoOneDo(com.lansosdk.videoeditor.VideoOneDo) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.sql.Date)

Example 2 with VideoOneDo

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

the class Demo3LayerFilterActivity method filterExecute.

private void filterExecute() {
    mProgressDialog = new ProgressDialog(Demo3LayerFilterActivity.this);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    mProgressDialog.setMessage("正在后台处理:");
    mProgressDialog.setCancelable(false);
    videoOneDo = new VideoOneDo(getApplicationContext(), mVideoPath);
    GPUImageFilter filter = FilterLibrary.getFilterList().getFilter(getApplicationContext(), currrentFilterName);
    videoOneDo.setFilter(filter);
    videoOneDo.setOnVideoOneDoProgressListener(new onVideoOneDoProgressListener() {

        @Override
        public void onProgress(VideoOneDo v, float percent) {
            if (mProgressDialog != null) {
                percent = percent * 100;
                mProgressDialog.setMessage("正在后台处理:" + percent + " %");
            }
        }
    });
    videoOneDo.setOnVideoOneDoCompletedListener(new onVideoOneDoCompletedListener() {

        @Override
        public void onCompleted(VideoOneDo v, String dstVideo) {
            if (mProgressDialog != null) {
                mProgressDialog.cancel();
                mProgressDialog = null;
            }
            dstPath = dstVideo;
            findViewById(R.id.id_filterdemo_saveplay).setVisibility(View.VISIBLE);
            videoOneDo.release();
            videoOneDo = null;
        }
    });
    if (videoOneDo.start()) {
        mProgressDialog.show();
    } else {
        Toast.makeText(getApplicationContext(), "后台运行失败,请查看打印信息", Toast.LENGTH_SHORT).show();
    }
}
Also used : GPUImageFilter(jp.co.cyberagent.lansongsdk.gpuimage.GPUImageFilter) com.lansosdk.videoeditor.onVideoOneDoProgressListener(com.lansosdk.videoeditor.onVideoOneDoProgressListener) com.lansosdk.videoeditor.onVideoOneDoCompletedListener(com.lansosdk.videoeditor.onVideoOneDoCompletedListener) VideoOneDo(com.lansosdk.videoeditor.VideoOneDo) ProgressDialog(android.app.ProgressDialog)

Aggregations

VideoOneDo (com.lansosdk.videoeditor.VideoOneDo)2 com.lansosdk.videoeditor.onVideoOneDoCompletedListener (com.lansosdk.videoeditor.onVideoOneDoCompletedListener)2 com.lansosdk.videoeditor.onVideoOneDoProgressListener (com.lansosdk.videoeditor.onVideoOneDoProgressListener)2 ProgressDialog (android.app.ProgressDialog)1 Bitmap (android.graphics.Bitmap)1 Date (java.sql.Date)1 SimpleDateFormat (java.text.SimpleDateFormat)1 GPUImageFilter (jp.co.cyberagent.lansongsdk.gpuimage.GPUImageFilter)1