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!");
}
}
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);
}
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);
}
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();
}
});
}
}
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;
}
}
Aggregations