use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_advance by LanSoSdk.
the class Demo3LayerFilterActivity method getFirstFrame.
/**
* 先获取第一帧, 然后根据第一帧去获取所有滤镜.
*
* @param src
* @return
*/
public boolean getFirstFrame(String src) {
long decoderHandler = 0;
IntBuffer mGLRgbBuffer;
MediaInfo info = new MediaInfo(src, false);
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 bmp = Bitmap.createBitmap(info.vWidth, info.vHeight, Bitmap.Config.ARGB_8888);
bmp.copyPixelsFromBuffer(mGLRgbBuffer);
decoderHandler = 0;
// 拿到图片, 去获取多个滤镜.
getBitmapFilters(bmp, info.vRotateAngle);
return true;
}
}
return false;
}
use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_advance by LanSoSdk.
the class Demo3LayerFilterActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.filter_layer_demo_layout);
initView();
mVideoPath = getIntent().getStringExtra("videopath");
editTmpPath = SDKFileUtils.newMp4PathInBox();
dstPath = SDKFileUtils.newMp4PathInBox();
mInfo = new MediaInfo(mVideoPath, false);
if (mInfo.prepare()) {
new GetBitmapFiltersTask(mVideoPath).execute();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
startPlayVideo();
}
}, 100);
}
}
use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_advance by LanSoSdk.
the class DisplayFramesActivity method startGetFrames.
/**
* 从这里开始演示.
*/
private void startGetFrames() {
if (isExecuting)
return;
mInfo = new MediaInfo(videoPath);
if (mInfo.prepare() == false || mInfo.isHaveVideo() == false) {
return;
}
isExecuting = true;
/**
* 初始化.
*/
mExtractFrame = new ExtractVideoFrame(DisplayFramesActivity.this, videoPath);
if (mInfo.vWidth * mInfo.vHeight > 960 * 540) {
// 视频分辨率过大,则缩小一倍.
mExtractFrame.setBitmapWH(mInfo.vWidth / 2, mInfo.vHeight / 2);
}
if (mTpye == FRAME_TYPE_25) {
// 25帧, 先检查用 内存释放够,如果不够,再用SD卡来缓存.
mExtractFrame.setExtract25Frame();
long desireSize = mExtractFrame.getBitmapHeight() * mExtractFrame.getBitmapWidth() * 4 * 25;
long cachesize = BitmapLruCache.getMaxCacheSize();
if (desireSize > cachesize) {
mDiskCache = new MemoryDiskCache(getApplication());
} else {
mLruCache = new BitmapLruCache();
}
} else if (mTpye == FRAME_TYPE_60) {
mExtractFrame.setExtract60Frame();
mDiskCache = new MemoryDiskCache(getApplication());
} else {
// 不设置,则默认是全部解码
// 全部解码,则用DiskLruCache
mDiskCache = new MemoryDiskCache(getApplication());
}
if (mDiskCache != null) {
Log.i(TAG, "写入到 硬盘.....");
} else {
Log.i(TAG, "写入到 memory....");
}
/**
* 设置处理完成监听.
*/
mExtractFrame.setOnExtractCompletedListener(new onExtractVideoFrameCompletedListener() {
@Override
public void onCompleted(ExtractVideoFrame v) {
mImageAdapter.notifyDataSetChanged();
}
});
/**
* 设置处理进度监听.
*/
mExtractFrame.setOnExtractProgressListener(new onExtractVideoFrameProgressListener() {
/**
* 当前帧的画面回调,, ptsUS:当前帧的时间戳,单位微秒.
*/
@Override
public void onExtractBitmap(Bitmap bmp, long ptsUS) {
if (mDiskCache != null) {
mDiskCache.pushBitmap(bmp);
count++;
// if(count%10==0){
mImageAdapter.notifyDataSetChanged();
// }
} else if (mLruCache != null) {
mLruCache.pushBitmap(bmp);
count++;
// if(count%10==0){
mImageAdapter.notifyDataSetChanged();
// }
}
}
});
/**
* 开始执行. 或者你可以从指定地方开始解码.
* mExtractFrame.start(10*1000*1000);则从视频的10秒处开始提取.
*/
mExtractFrame.start();
}
use of com.lansosdk.videoeditor.MediaInfo 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);
}
}
}
});
}
}
use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_advance by LanSoSdk.
the class ExecuteVideoLayerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
mContext = getApplicationContext();
videoPath = getIntent().getStringExtra("videopath");
mInfo = new MediaInfo(videoPath);
mInfo.prepare();
setContentView(R.layout.execute_edit_demo_layout);
initUI();
// 在手机的默认路径下创建一个文件名,用来保存生成的视频文件,(在onDestroy中删除)
editTmpPath = SDKFileUtils.newMp4PathInBox();
if (SDKFileUtils.fileExist(editTmpPath)) {
SDKFileUtils.deleteFile(editTmpPath);
}
dstPath = SDKFileUtils.newMp4PathInBox();
}
Aggregations