android mp4 画面裁剪,说说Android的视频裁剪(二)

有关视频裁剪我在前面一篇博客中只是做了简单的说明,主要涉及到的知识准备在这篇博客中拿出来说一下。有兴趣的可以fork我的视频裁剪的项目源码,一起学习进步。

Github:https://github.com/iknow4/Android-Video-Trimmer

视频裁剪页如下图所示:

254e465da51f

图上面的视频播放用是VideoView来实现的,比较简单。我主要说说视频帧的读取和视频时间的选取。

视频帧的获取可以通过Android提供的MediaMetadataRetriever类来实现。

MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();

mediaMetadataRetriever.setDataSource(context, videoUri);

在MediaMetadataRetriever类中会调用到media_jni的这个库中的setDataSource()方法,最终使得我们可以获取视频的meta data,meta data是非常丰富的,足足有26种,足够满足我们的需求了。

/**

* The metadata key to retrieve the numeric string describing the

* order of the audio data source on its original recording.

*/

public static final int METADATA_KEY_CD_TRACK_NUMBER = 0;

/**

* The metadata key to retrieve the information about the album title

* of the data source.

*/

public static final int METADATA_KEY_ALBUM = 1;

/**

* The metadata key to retrieve the information about the artist of

* the data source.

*/

public static final int METADATA_KEY_ARTIST = 2;

/**

* The metadata key to retrieve the information about the author of

* the data source.

*/

public static final int METADATA_KEY_AUTHOR = 3;

/**

* The metadata key to retrieve the information about the composer of

* the data source.

*/

public static final int METADATA_KEY_COMPOSER = 4;

/**

* The metadata key to retrieve the date when the data source was created

* or modified.

*/

public static final int METADATA_KEY_DATE = 5;

/**

* The metadata key to retrieve the content type or genre of the data

* source.

*/

public static final int METADATA_KEY_GENRE = 6;

/**

* The metadata key to retrieve the data source title.

*/

public static final int METADATA_KEY_TITLE = 7;

/**

* The metadata key to retrieve the year when the data source was created

* or modified.

*/

public static final int METADATA_K

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值