如何从视频中提取音频 [英] how to extract audio from video

查看:70
本文介绍了如何从视频中提取音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个可以下载不同格式视频的安卓应用.它做得很完美.

I am working on an android app that can download videos in different formats.It done perfectly.

现在我想从下载的视频文件或可用的视频链接中提取音频.有没有办法通过以下任何一种方法从视频中提取音频

Now i want to extract audio from downloaded video file or available video link. Is there any way to extract audio from video by any of the following methods

1.直接从视频文件链接中提取音频

1.extract audio directly from a video file link

2.有没有适合android从视频文件中提取音频的库

2.is there any library that suitable for android to extract audio from a video files

感谢您的时间!

推荐答案

您可以使用名为 JAVE(Java 音频视频编码器)的库将视频编码为音频文件.

You can use a library called JAVE (Java Audio Video Encoder) to encode a video into an audio file.

  1. 此处下载 JAVE.
  2. 参考下面的代码片段从 MP4 编码到 MP3

代码:

File source = new File("source.mp4");
File target = new File("target.mp3");

AudioAttributes audioAttributes = new AudioAttributes();
audioAttributes.setCodec("libmp3lame")
    .setBitRate(new Integer(128000))
    .setChannels(new Integer(2))
    .setSamplingRate(new Integer(44100));
EncodingAttributes encodingAttributes = new EncodingAttributes();
encodingAttributes.setFormat("mp3")
    .setAudioAttributes(audioAttributes);

Encoder encoder = new Encoder();
encoder.encode(source, target, encodingAttributes); 

这篇关于如何从视频中提取音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆