Android sdk cut/trim video file

前端 未结 5 1423
庸人自扰
庸人自扰 2020-11-29 02:33

Is there any way to cut a video (mp4 or 3gp) on android, like use only the last 5 seconds of the movie... on iphone this is possible using the AVAssetExportSession but on an

5条回答
  •  迷失自我
    2020-11-29 03:15

    try this

    Intent trimVideoIntent = new Intent("com.android.camera.action.TRIM");
    
    // The key for the extra has been discovered from com.android.gallery3d.app.PhotoPage.KEY_MEDIA_ITEM_PATH
    trimVideoIntent.putExtra("media-item-path",FilePath);
    trimVideoIntent.setData(videoUri);
    
    // Check if the device can handle the Intent
    List list = getPackageManager().queryIntentActivities(trimVideoIntent, 0);
    if (null != list && list.size() > 0) {
        startActivity(trimVideoIntent); // Fires TrimVideo activity into being active
    }else {
        Toast.makeText(this, "not supported",Toast.LENGTH_SHORT).show();
    }
    

    its work on Gallery2 package installed devices

提交回复
热议问题