Problem encoding wav into ogg vorbis

可紊 提交于 2019-12-08 12:04:25

问题


I have an MFC application. I have audio data stored in wav format. My question is, how can I encode an array of those bytes into an ogg vorbis format?

I found an example:

http://svn.xiph.org/trunk/vorbis/examples/encoder_example.c

and tried to use it in my application. First, I tried to add it to my project and compile. I had to add files included in the above file, so I found them in the libraries libvorbis and libogg. And still I cannot link:

Error 4 error LNK2019: unresolved external symbol _oggpack_writetrunc referenced in function _vorbis_bitrate_addblock bitrate.obj
Error 2 error LNK2019: unresolved external symbol _oggpack_write referenced in function _vorbis_bitrate_addblock bitrate.obj
Error 8 error LNK2019: unresolved external symbol _oggpack_read referenced in function _vorbis_staticbook_unpack codebook.obj
Error 10 error LNK2019: unresolved external symbol _oggpack_look referenced in function _decode_packed_entry_number codebook.obj
Error 7 error LNK2019: unresolved external symbol _oggpack_get_buffer referenced in function _vorbis_bitrate_flushpacket bitrate.obj
Error 5 error LNK2019: unresolved external symbol _oggpack_bytes referenced in function _vorbis_bitrate_addblock bitrate.obj
Error 9 error LNK2019: unresolved external symbol _oggpack_adv referenced in function _decode_packed_entry_number codebook.obj
Error 3 error LNK2001: unresolved external symbol _oggpack_write codebook.obj
Error 6 error LNK2001: unresolved external symbol _oggpack_bytes codebook.obj

I could not find where those guys are defined. I would appreciate any help.

Thanks.


回答1:


libsndfile is a popular library for doing what you want.

As for your link errors, it looks like you're linking with code that's dependent on a library that defines symbols starting with "oggpack," so you'd need to include that library in your link. But using libsndfile may be a better solution.




回答2:


I had some luck with: gcc program.c -lvorbis -o program

I wish vorbis would make small working exampe that would work. I tried all there example and they are not very good.




回答3:


gcc p.c -lvorbisenc -o p
or
gcc p.c -lvorbis -lvorbisenc -o p

But I have not checked if it will encode a wav yet.



来源:https://stackoverflow.com/questions/5186558/problem-encoding-wav-into-ogg-vorbis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!