Search in sources :

Example 56 with MediaInfo

use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_common by LanSoSdk.

the class DemoFunctions method demoAVMerge.

/**
 * 演示音频和视频合成, 也可以认为是音频替换.
 *
 * 音视频合成:\n把一个纯音频文件和纯视频文件合并成一个mp4格式的多媒体文件, 如果源视频之前有音频,会首先删除音频部分. \n\n
 */
public static int demoAVMerge(Context ctx, VideoEditor editor, String srcVideo, String dstPath) {
    int ret = -1;
    MediaInfo info = new MediaInfo(srcVideo, false);
    if (info.prepare()) {
        String video2 = srcVideo;
        String video3 = null;
        // 如果源视频中有音频,则先删除音频
        if (info.isHaveAudio()) {
            video3 = SDKFileUtils.createFileInBox(info.fileSuffix);
            editor.executeDeleteAudio(video2, video3);
            video2 = video3;
        }
        String audio = CopyDefaultVideoAsyncTask.copyFile(ctx, "aac20s.aac");
        ret = editor.executeVideoMergeAudio(video2, audio, dstPath);
        SDKFileUtils.deleteFile(video3);
    }
    return ret;
}
Also used : MediaInfo(com.lansosdk.videoeditor.MediaInfo)

Example 57 with MediaInfo

use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_common by LanSoSdk.

the class MainActivity method checkPath.

private boolean checkPath() {
    if (isPermissionOk == false) {
        Toast.makeText(MainActivity.this, "请在系统中打开权限.", Toast.LENGTH_SHORT).show();
        return false;
    }
    if (tvVideoPath.getText() != null && tvVideoPath.getText().toString().isEmpty()) {
        Toast.makeText(MainActivity.this, "请输入视频地址", Toast.LENGTH_SHORT).show();
        return false;
    } else {
        String path = tvVideoPath.getText().toString();
        if ((new File(path)).exists() == false) {
            Toast.makeText(MainActivity.this, "文件不存在", Toast.LENGTH_SHORT).show();
            return false;
        } else {
            MediaInfo info = new MediaInfo(path, false);
            boolean ret = info.prepare();
            if (ret == false) {
                showHintDialog(R.string.sdk_checkerror);
            }
            return ret;
        }
    }
}
Also used : MediaInfo(com.lansosdk.videoeditor.MediaInfo) File(java.io.File)

Example 58 with MediaInfo

use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_common by LanSoSdk.

the class MediaInfoActivity method getMediaInfo.

private String getMediaInfo() {
    String retStr = "";
    MediaInfo info = new MediaInfo(videoPath);
    if (info.prepare()) {
        retStr += "文件路径: " + info.filePath + " \n";
        retStr += "文件名字: " + info.fileName + " \n";
        retStr += "文件后缀: " + info.fileSuffix + " \n";
        if (info.vCodecHeight > 0 && info.vCodecWidth > 0) {
            retStr += "\n视频信息----------------------\n";
            retStr += "宽度: " + info.vWidth + " \n";
            retStr += "高度: " + info.vHeight + " \n";
            retStr += "编码宽度: " + info.vCodecWidth + " \n";
            retStr += "编码高度: " + info.vCodecHeight + " \n";
            retStr += "总时长: " + info.vDuration + "(秒)" + " \n";
            retStr += "比特率(码率): " + info.vBitRate + " bit/s" + " \n";
            retStr += "帧率: " + info.vFrameRate + " frame/s" + " \n";
            retStr += "像素格式: " + info.vPixelFmt + " \n";
            retStr += "旋转角度: " + info.vRotateAngle + " \n";
            retStr += "总帧数: " + info.vTotalFrames + " \n";
            retStr += "是否有B帧: " + info.vHasBFrame + " \n";
            retStr += "可采用的解码器: ";
            if (info.vCodecName.equals("lansoh264_dec"))
                retStr += "h264,";
            retStr += info.vCodecName + " \n";
        }
        if (info.aBitRate > 0) {
            retStr += "\n音频信息----------------------\n";
            retStr += "时长: " + info.aDuration + "(秒)" + "\n";
            retStr += "采样率: " + info.aSampleRate + "\n";
            retStr += "通道数: " + info.aChannels + "\n";
            retStr += "总帧数: " + info.aTotalFrames + "\n";
            retStr += "比特率(码率): " + info.aBitRate + "\n";
            retStr += "最大比特率(最大码率): " + info.aMaxBitRate + "\n";
            retStr += "可采用的解码器: " + info.aCodecName + "\n";
        }
    } else {
        retStr = "无法获取文件的音视频信息,请检查您的文件是否是音视频文件.";
    }
    return retStr;
}
Also used : MediaInfo(com.lansosdk.videoeditor.MediaInfo)

Example 59 with MediaInfo

use of com.lansosdk.videoeditor.MediaInfo in project LanSoEditor_common by LanSoSdk.

the class VideoPlayerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.player_layout);
    textureView = (TextureRenderView) findViewById(R.id.surface1);
    videoPath = getIntent().getStringExtra("videopath");
    TextView tvScreen = (TextView) findViewById(R.id.id_palyer_screenhinit);
    TextView tvVideoRatio = (TextView) findViewById(R.id.id_palyer_videoRatio);
    TextView tvVideoDuration = (TextView) findViewById(R.id.id_palyer_videoduration);
    tvSizeHint = (TextView) findViewById(R.id.id_palyer_videosizehint);
    // 获取屏幕密度(方法2)
    DisplayMetrics dm = new DisplayMetrics();
    dm = getResources().getDisplayMetrics();
    screenWidth = dm.widthPixels;
    screenHeight = dm.heightPixels;
    String str = "当前屏幕分辨率:";
    str += String.valueOf(screenWidth);
    str += "x";
    str += String.valueOf(screenHeight);
    tvScreen.setText(str);
    mInfo = new MediaInfo(videoPath, false);
    if (mInfo.prepare() == false) {
        showHintDialog();
        isSupport = false;
    } else {
        isSupport = true;
        str = "当前视频分辨率:";
        str += String.valueOf(mInfo.vWidth);
        str += "x";
        str += String.valueOf(mInfo.vHeight);
        tvVideoRatio.setText(str);
        str = "当前视频时长:";
        str += String.valueOf(mInfo.vDuration);
        str += "\n文件大小:" + new File(videoPath).length();
        tvVideoDuration.setText(str);
    }
    textureView.setSurfaceTextureListener(new SurfaceTextureListener() {

        @Override
        public void onSurfaceTextureUpdated(SurfaceTexture surface) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
        // TODO Auto-generated method stub
        }

        @Override
        public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
            // TODO Auto-generated method stub
            return false;
        }

        @Override
        public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
            // TODO Auto-generated method stub
            if (isSupport) {
                // play(new Surface(surface));
                startVPlayer(new Surface(surface));
            }
        }
    });
}
Also used : MediaInfo(com.lansosdk.videoeditor.MediaInfo) SurfaceTexture(android.graphics.SurfaceTexture) SurfaceTextureListener(android.view.TextureView.SurfaceTextureListener) TextView(android.widget.TextView) DisplayMetrics(android.util.DisplayMetrics) File(java.io.File) Surface(android.view.Surface)

Aggregations

MediaInfo (com.lansosdk.videoeditor.MediaInfo)59 Handler (android.os.Handler)12 com.lansosdk.box.onDrawPadSizeChangedListener (com.lansosdk.box.onDrawPadSizeChangedListener)9 Paint (android.graphics.Paint)8 TextView (android.widget.TextView)6 Intent (android.content.Intent)5 View (android.view.View)5 OnClickListener (android.view.View.OnClickListener)5 CanvasRunnable (com.lansosdk.box.CanvasRunnable)5 DrawPad (com.lansosdk.box.DrawPad)5 Bitmap (android.graphics.Bitmap)4 DrawPadView (com.lansosdk.videoeditor.DrawPadView)4 File (java.io.File)3 SurfaceTexture (android.graphics.SurfaceTexture)2 MediaPlayer (android.media.MediaPlayer)2 DisplayMetrics (android.util.DisplayMetrics)2 Surface (android.view.Surface)2 SurfaceTextureListener (android.view.TextureView.SurfaceTextureListener)2 VideoPlayerActivity (com.example.advanceDemo.VideoPlayerActivity)2 DrawPadVideoRunnable (com.lansosdk.box.DrawPadVideoRunnable)2