Android 从视频中提取音频

发布于 2025-01-12 00:34:46 字数 798 浏览 1 评论 0原文

我正在使用这个库 https://gist.github.com/ArsalRaza/132a6e99d59aa80b9861ae368bc786d0从我的视频中提取音频。我看到很多使用它的建议。但由于某种原因,我在以下内容中遇到了空指针异常

// Set up the orientation and starting time for extractor.
    MediaMetadataRetriever retrieverSrc = new MediaMetadataRetriever();
    retrieverSrc.setDataSource(srcPath);

但是当我调试 retrieverSrc 时,它不为空(这很明显,因为我已经在创建一个新实例)。

srcPathhttps://video.twimg.com/ext_tw_video/1499813059644305416/pu/vid/902x720/-b3JbGZm825Q6PwT.mp4

出了什么问题?

I am using this libraey https://gist.github.com/ArsalRaza/132a6e99d59aa80b9861ae368bc786d0 to extract audio from my video. I saw a lot of recommendations to use it. But for some reason I am getting a null pointer exception on the following.

// Set up the orientation and starting time for extractor.
    MediaMetadataRetriever retrieverSrc = new MediaMetadataRetriever();
    retrieverSrc.setDataSource(srcPath);

But when I debug retrieverSrc is not being null (this is obvious because I am already creating a new instance).

srcPath is https://video.twimg.com/ext_tw_video/1499813059644305416/pu/vid/902x720/-b3JbGZm825Q6PwT.mp4

What is going wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨敛清荷 2025-01-19 00:34:46

好的,所以我没有使用我正在使用的内容,而是使用了这个

MediaMetadataRetriever retrieverSrc = new MediaMetadataRetriever();
retrieverSrc.setDataSource(srcPath, new HashMap<String, String>());

注意我如何在第二个参数中添加 HashMap

Ok so instead of what I was using I used this

MediaMetadataRetriever retrieverSrc = new MediaMetadataRetriever();
retrieverSrc.setDataSource(srcPath, new HashMap<String, String>());

notice how I added a HashMap in the second parameter

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文