首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jFLAC。拆分FLAC文件

jFLAC。拆分FLAC文件
EN

Stack Overflow用户
提问于 2012-08-10 01:59:54
回答 1查看 1.2K关注 0票数 3

我需要将flac文件分成多个部分。我正在使用jFLAC库读取flac文件

代码语言:javascript
复制
FLACDecoder decoder = new FLACDecoder(inputStream);

然后我尝试解码父文件到SeekPoints

代码语言:javascript
复制
decoder.decode(seekPointFrom, seekPointTo);

我也不太明白如何正确地获取秒值的搜索点。例如,我需要从0秒到150秒的第一个搜索点。如何获得正确的搜索点对象?Seekpoint cinstructor是

代码语言:javascript
复制
/**
 * 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;
}

解码器也有一些监听程序,监听每个读取块操作。

代码语言:javascript
复制
 @Override
    public void processPCM(ByteData pcm) {
        try {
            outputStream.write(pcm.getData(), 0, pcm.getLen());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

当写入完成时,我正准备播放新的flac文件,但我的播放器提示该文件不正确。我需要做什么才能打开我的flac文件?也许我需要在这个文件中写一些头文件或者别的什么?

EN

回答 1

Stack Overflow用户

发布于 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文件。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11889302

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档