我需要将flac文件分成多个部分。我正在使用jFLAC库读取flac文件
FLACDecoder decoder = new FLACDecoder(inputStream);然后我尝试解码父文件到SeekPoints
decoder.decode(seekPointFrom, seekPointTo);我也不太明白如何正确地获取秒值的搜索点。例如,我需要从0秒到150秒的第一个搜索点。如何获得正确的搜索点对象?Seekpoint cinstructor是
/**
* The constructor.
* @param sampleNumber The sample number of the target frame
* @param streamOffset The offset, in bytes, of the target frame with respect to beginning of the first frame
* @param frameSamples The number of samples in the target frame
*/
public SeekPoint(long sampleNumber, long streamOffset, int frameSamples) {
this.sampleNumber = sampleNumber;
this.streamOffset = streamOffset;
this.frameSamples = frameSamples;
}解码器也有一些监听程序,监听每个读取块操作。
@Override
public void processPCM(ByteData pcm) {
try {
outputStream.write(pcm.getData(), 0, pcm.getLen());
} catch (IOException e) {
e.printStackTrace();
}
}当写入完成时,我正准备播放新的flac文件,但我的播放器提示该文件不正确。我需要做什么才能打开我的flac文件?也许我需要在这个文件中写一些头文件或者别的什么?
发布于 2015-10-27 06:20:08
至于FLAC SeekPoints,不能保证会有一个对应于给定秒数的SeekPoints -整个音频文件中可能只有几个FLAC。
因此,我最近用seek函数更新了jFLAC,让你至少能找到最近的音频帧:https://github.com/nguillaumin/jflac/commit/585940af97157eb11b60c15cc8cb13ef3fc27ce3
关于写出新文件,解码的数据将在原始PCM样本中。因此,如果您想要一个有效的FLAC文件作为输出,则需要将其通过管道传输到FLAC编码器。或者,您可以写出一个Wave报头并转储原始PCM样本,然后将生成的Wave文件转换为FLAC文件。
https://stackoverflow.com/questions/11889302
复制相似问题