use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_advance by LanSoSdk.
the class DemoFunctions method demoPaddingVideo.
/**
* 视频增加边框
*/
public static int demoPaddingVideo(VideoEditor editor, String srcVideo, String dstVideo) {
MediaInfo info = new MediaInfo(srcVideo);
if (info.prepare()) {
int bitrate = (int) (info.vBitRate * 1.5f);
if (bitrate > 2000 * 1000)
// 2M
bitrate = 2000 * 1000;
// 向外padding32个像素
int width = info.vCodecWidth + 32;
int height = info.vCodecHeight + 32;
return editor.executePadingVideo(srcVideo, info.vCodecName, width, height, 0, 0, dstVideo, (int) (info.vBitRate * 1.5f));
} else {
return -1;
}
}
use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_advance by LanSoSdk.
the class DemoFunctions method demoVideoConcat.
/**
* 视频拼接 ,
* <p>
* 为了方便演示,需要您的视频大于20秒(或用默认视频).先把原视频从(0到1/3处)和(2/3到结束)截取成两段,这样就有了两个独立的视频, 然后把这两段拼接在一起,来演示视频的拼接,
* 您实际可任意的组合,注意尽量视频的宽高比等参数一致,不然合成是可以,但有些播放器无法播放.
*/
public static int demoVideoConcat(VideoEditor editor, String srcVideo, String dstVideo) {
MediaInfo info = new MediaInfo(srcVideo);
int ret = -1;
if (info.prepare() && info.vDuration > 20) {
// 第一步:先创建三个视频文件,并剪切好视频.
String seg1 = SDKFileUtils.createFileInBox(info.fileSuffix);
String seg2 = SDKFileUtils.createFileInBox(info.fileSuffix);
String segTs1 = SDKFileUtils.createFileInBox("ts");
String segTs2 = SDKFileUtils.createFileInBox("ts");
ret = editor.executeVideoCutOut(srcVideo, seg1, 0, info.vDuration / 3);
ret = editor.executeVideoCutOut(srcVideo, seg2, info.vDuration * 2 / 3, info.vDuration);
// 第二步: 把他们转换为ts格式.
ret = editor.executeConvertMp4toTs(seg1, segTs1);
ret = editor.executeConvertMp4toTs(seg2, segTs2);
// 第三步: 把ts文件拼接成mp4
ret = editor.executeConvertTsToMp4(new String[] { segTs1, segTs2 }, dstVideo);
// 第四步: 删除之前的临时文件.
SDKFileUtils.deleteFile(segTs2);
SDKFileUtils.deleteFile(segTs1);
SDKFileUtils.deleteFile(seg2);
SDKFileUtils.deleteFile(seg1);
}
return ret;
}
use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_advance by LanSoSdk.
the class DemoFunctions method demoGetOneFrame.
/**
* 获取一张图片
*/
public static int demoGetOneFrame(VideoEditor editor, String srcVideo, String dstVideo) {
MediaInfo info = new MediaInfo(srcVideo);
if (info.prepare()) {
// 这里是保存的路径
String picPath = SDKFileUtils.createFileInBox("png");
Log.i("lansosdk", "picture save at " + picPath);
return editor.executeGetOneFrame(srcVideo, info.vCodecName, info.vDuration / 2, picPath);
} else {
return -1;
}
}
use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_advance by LanSoSdk.
the class DemoFunctions method demoVideoRotate90Clockwise.
/**
* 视频顺时针旋转90度
*/
public static int demoVideoRotate90Clockwise(VideoEditor editor, String srcVideo, String dstVideo) {
MediaInfo info = new MediaInfo(srcVideo);
if (info.prepare()) {
int bitrate = (int) (info.vBitRate * 1.5f);
if (bitrate > 2000 * 1000)
// 2M
bitrate = 2000 * 1000;
int ret = editor.executeVideoRotate90Clockwise(srcVideo, info.vCodecName, bitrate, dstVideo);
if (ret != 0) {
ret = editor.executeVideoRotate90Clockwise(srcVideo, "h264", bitrate, dstVideo);
}
return ret;
} else {
return -1;
}
}
use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_common by LanSoSdk.
the class DemoFunctions method demoAVSplite.
/**
* 演示音视频分离
*
* 音视频分离:\n把多媒体文件如mp4,flv等中的的音频和视频分离开,形成独立的音频文件和视频文件 \n\n
*/
public static int demoAVSplite(VideoEditor editor, String srcVideo, String dstVideo, String dstAudio) {
MediaInfo info = new MediaInfo(srcVideo);
int ret = -1;
if (info.prepare()) {
ret = editor.executeDeleteAudio(srcVideo, dstVideo);
ret = editor.executeDeleteVideo(srcVideo, dstAudio);
}
return ret;
}
Aggregations