使用的Ogg Vorbis工作 [英] Working with Ogg Vorbis

查看:210
本文介绍了使用的Ogg Vorbis工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的Ogg Vorbis文件,我需要做两次手术用它:

I have an ogg vorbis file and I have to do two operations with it:

  1. 切割文件的一部分,从一个位置移动到另一个
  2. 与现有的合并另一个文件

我如何在C#中实现这两个操作?

How can I realize these two operations in C#?

推荐答案

我会考虑的libogg C文档中,并找出如何用C做到这一点。然后用包装过libogg写的几乎是相同的code在C#。

I'd look into the c documentation for libogg, and figure out how to do this with c. And then write almost the same code in C# using a wrapper over libogg.

我已经创建了libogg和使用互操作助理libvorbis低水平包装: https://github.com/$c$csInChaos/Xiph/blob /master/LowLevel.cs

I've created a low level wrapper over libogg and libvorbis using the interop assistant: https://github.com/CodesInChaos/Xiph/blob/master/LowLevel.cs

该项目还包含了一些更高级别的结构,但我不认为他们会是你在做什么有用的。

That project also contains some higher level constructs, but I don't think they'll be useful for what you're doing.

顺便说一句,如果文件之间的流ID不同,你可以简单地附加一个文件到另一个创造,发挥两个流顺序一个有效的文件。

BTW if the stream IDs between the files differ, you can simply append a file to another creating a valid file that plays both streams in sequence.

您可能需要读取输入文件分组明智使用解码的API,然后聪明的写入组合的数据进行分组。可能更换流ID和granulepos在两者之间。

You probably need to read the input files packet wise using the decoding API, and then write the combined data out packet wise. Possibly replacing the stream ID and granulepos in between.

流ID是一个整数,标识的OGG文件的子。要附加多个这样的子,你可以简单地确保他们有不同的ID,然后写入数据。

StreamID is an integer that identifies substreams in an ogg file. To append multiple such substreams you can simply ensure that they have a different ID and then write the data.

分离是比较讨厌的一点,因为granulepos是codeC相关的时间戳,而我不记得它是如何定义Vorbis格式。这里还有一个问题是,你不能简单地分成一包的中间无需重新编码。

Splitting is a bit more annoying, since granulepos is a codec dependent timestamp, and I don't remember how it is defined for vorbis. Another problem here is that you can't simply split in the middle of a packet without reencoding.

这篇关于使用的Ogg Vorbis工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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