Pet*_*ter 11 audio android inputstream
可以告诉我们如何将两个媒体文件合并/合并成一个?
我找到了一个主题,audioInputStream但现在它不支持android,以及java的所有代码.
在StackOverflow上,我在这里找到了这个链接,但在那里我找不到解决方案 - 这些链接只在流音频上.谁能告诉我?
PS和为什么我不能开始赏金?:(
小智 10
import java.io.*;
public class TwoFiles
{
public static void main(String args[]) throws IOException
{
FileInputStream fistream1 = new FileInputStream("C:\\Temp\\1.mp3"); // first source file
FileInputStream fistream2 = new FileInputStream("C:\\Temp\\2.mp3");//second source file
SequenceInputStream sistream = new SequenceInputStream(fistream1, fistream2);
FileOutputStream fostream = new FileOutputStream("C:\\Temp\\final.mp3");//destinationfile
int temp;
while( ( temp = sistream.read() ) != -1)
{
// System.out.print( (char) temp ); // to print at DOS prompt
fostream.write(temp); // to write to file
}
fostream.close();
sistream.close();
fistream1.close();
fistream2.close();
}
}
Run Code Online (Sandbox Code Playgroud)
考虑.mp3文件的两种情况:
在这种情况下,我们可以将第二个文件追加到第一个文件的末尾。可以使用Android上可用的File类来实现。
在这种情况下,必须对片段之一进行重新编码,以确保两个文件具有相同的采样频率和通道数。为此,我们需要解码MP3,获取PCM样本,对其进行处理以更改采样频率,然后重新编码为MP3。据我了解,android没有转码或重新编码API。一种选择是通过JNI使用外部库(例如lame / FFMPEG)进行重新编码。
| 归档时间: |
|
| 查看次数: |
13901 次 |
| 最近记录: |