在C中动态地将wav转换为ogg或mp3

时间:2023-01-22 19:43:40

I've written a FUSE fs to access an audio cdrom. It's part of fuse-workspace, which offers access to all kinds of resources like SMB shares, FTP server (work in progress), and audio cd's. Much more work has to be done, to get access to exfat, vfat, ntfs, ipod etc and possibly other network resources like SSH.

我写了一个FUSE fs来访问音频cdrom。它是fuse-workspace的一部分,可以访问各种资源,如SMB共享,​​FTP服务器(正在进行的工作)和音频CD。还有很多工作要做,可以访问exfat,vfat,ntfs,ipod等以及可能的其他网络资源,比如SSH。

see:

https://github.com/stefbon/fuse-workspace

Now the audio cd reader works as follows:

现在音频CD阅读器的工作原理如下:

. when a client (a program which wants to read a piece from a wav track) a check is done the desired sectors have been read before. If so, then read these and ready.

。当客户端(想要从wav轨道读取一个片段的节目)进行检查时,之前已经读取了所需的扇区。如果是这样,那么请阅读并准备好。

. if not, send a read command to the "cd read" thread to get the desired sectors. When these are read, write these to a cached file and update the administration of "sectors read", and send a signal to the waiting read command that sectors are ready.

。如果不是,则向“cd read”线程发送读取命令以获得所需的扇区。读取这些内容后,将这些内容写入缓存文件并更新“扇区读取”的管理,并向扇区准备就绪的等待读取命令发送信号。

I've implemented a readahead function, which results in reading a wav file from the cd of 40-50 MB in 5 a 6 seconds. After this every sector is available from the file in the cache.

我已经实现了一个readahead函数,它可以在5秒6秒内从40-50 MB的cd中读取一个wav文件。在此之后,每个扇区都可以从缓存中的文件中获得。

This works very good, the only problem is that there are large wav files in the cache. (40-70 MB for every file). So I guess that decode.encode this audio tracks to another format like mp3 or ogg is a good option. Now, how can I do this?

这非常好用,唯一的问题是缓存中有大量的wav文件。 (每个文件40-70 MB)。所以我想解码这个音频跟踪到另一种格式如mp3或ogg是一个不错的选择。现在,我该怎么做?

In practice this means that the following functions have to be available:

实际上,这意味着必须提供以下功能:

. convert a location in a mp3 (or ogg) file (offset) to a location in a wav file and vice versa.

。将mp3(或ogg)文件中的位置(偏移)转换为wav文件中的位置,反之亦然。

. convert a buffer/offset from wav format to buffer/offset in mp3 (ogg) format.

。将缓冲区/偏移量从wav格式转换为mp3(ogg)格式的缓冲区/偏移量。

Can someone give me a hint?

有人可以给我一个暗示吗?

1 个解决方案

#1


0  

You could also consider the gstreamer framework which can allow you to even change formats on the fly or possibly generate both mp3 and ogg at the same time by splitting the pipeline.

您还可以考虑gstreamer框架,它可以让您甚至可以动态更改格式,或者通过拆分管道同时生成mp3和ogg。

I believe gstreamer is a standard package in Ubuntu but I haven't check recently. We were able to plug it in to a custom GTK widget without too much effort, maybe a couple days after starting from a blank slate.

我相信gstreamer是Ubuntu的标准软件包,但我最近没有检查过。我们能够毫不费力地将其插入到自定义GTK小部件中,可能是在从空白平板开始几天之后。

If you do need to record and playback in real-time you will have to consider kernel and hardware performance. We had a very noticeable delay from mic input to speaker output but it was not running on a real time system.

如果您确实需要实时记录和回放,则必须考虑内核和硬件性能。从麦克风输入到扬声器输出有一个非常明显的延迟,但它没有在实时系统上运行。

#1


0  

You could also consider the gstreamer framework which can allow you to even change formats on the fly or possibly generate both mp3 and ogg at the same time by splitting the pipeline.

您还可以考虑gstreamer框架,它可以让您甚至可以动态更改格式,或者通过拆分管道同时生成mp3和ogg。

I believe gstreamer is a standard package in Ubuntu but I haven't check recently. We were able to plug it in to a custom GTK widget without too much effort, maybe a couple days after starting from a blank slate.

我相信gstreamer是Ubuntu的标准软件包,但我最近没有检查过。我们能够毫不费力地将其插入到自定义GTK小部件中,可能是在从空白平板开始几天之后。

If you do need to record and playback in real-time you will have to consider kernel and hardware performance. We had a very noticeable delay from mic input to speaker output but it was not running on a real time system.

如果您确实需要实时记录和回放,则必须考虑内核和硬件性能。从麦克风输入到扬声器输出有一个非常明显的延迟,但它没有在实时系统上运行。