C ++ audio conversion (mp3 & # 8594; ogg) question

I was wondering if anyone knows how to convert an mp3 audio file to an ogg sound file. I know that there are programs that you can buy on the Internet, but I would rather just have my own application, which allowed me to convert as many files as I wanted.

+4
source share
5 answers

It is realistically simple. I would not use the SDK for Windows Media Format. Just because it overflows with work.

You need an MP3 decoder and an OGG encoder, as well as some code for gluing (opening files, setting up codecs, transferring raw audio around ect.)

For an MP3 decoder, I suggest you take a look at the liblame library or use this lib decryption http://www.codeproject.com/KB/audio-video/madlldlib.aspx as a starting point.

There are not many options for OGG. You need libogg and libvorbis. Easy. The sample codes that come with the libraries show you how to make the encoding.

Good luck.

+4
source

It is a bad idea. Quote from the Vorbis FAQ

You can convert any audio format to Ogg Vorbis. However, converting from one lossy format, such as MP3, to another lossy format, such as Vorbis, is generally a bad idea. Both MP3s and Vorbis Encoders achieve high compression ratios by throwing out parts of the audio signal that you probably won't hear. However, Vorbis MP3s and codecs are very different, so each of them is part of the audio, although there certainly is some overlap. Converting MP3s to Vorbis involves decoding the MP3 file back to an uncompressed format, such as WAV, and recompressing it using the Ogg Vorbis encoder. in decoded MP3, there will be no parts of the original audio that the MP3 encoder has chosen to reset. Ogg The Vorbis encoder then discards other audio components during data compression. At best, the result will be an Ogg file that sounds just like your original MP3, but it is most likely that the resulting file will sound worse than your original MP3. In no case, you will get a file that sounds better than the original MP3.

Since many music players can MP3 and Ogg, there is no reason that you have to switch all your files to one format or another. If you like Ogg Vorbis, then we would ask you to use it when you encode from the original, lossless audio sources (such as CDs). When encoding from originals, you will find that you can make Ogg files smaller or better (or both) than your MP3 files.

(If you need to convert from MP3 to Ogg, there are several conversion scripts available on Freshmeat .)

http://www.vorbis.com/faq/#transcode

And, for the sake of accuracy, from the same FAQ:

Ogg Ogg is the name of the Xiph.org container format for audio, video, and metadata.

Vorbis Vorbis is the name of a specific audio compression scheme designed for Ogg. Please note that other formats capable of being implemented in Ogg such as FLAC and Speex.

I assume it is theoretically possible to embed MP3 in Ogg, although I'm not sure why anyone would want to. FLAC is a lossless audio codec. Speex is a very lost audio codec optimized for speech encoding. Vorbis is a regular lossy audio codec. "Ogg audio", therefore, is a bit wrong. Augg Vorbis is the right term for what I think you mean.

All that said, if you still want to convert from MP3 to Ogg Vorbis, you could (a) try the Freshmeat link above, (b) look at other answers or (c) look at FFmpeg. FFmpeg is a universal library for converting many video and audio codecs and formats. It can do a lot of smart things. I heard that its Vorbis encoder is of poor quality by default, but it can be configured to use libvorbis instead of the built-in Vorbis encoder. (The last sentence may be obsolete now. I do not know.)

Note that FFmpeg will use LAME and libvorbis, just like you. This will not do anything new for you. It just gives you the ability to do all sorts of other conversions.

+2
source

You will need to decode mp3 and then encode to ogg.

One possibility is to use liblame for mp3 decoding and libogg / libvorbis for encoding in ogg. Or just use command line versions for them.

But I would not say that converting from one lossy format to another is a great idea.

+1
source

Foobar2000 ( http://www.foobar2000.org/ ) is free and simplifies the conversion between file formats. Converting from MP3 to OGG will require just a few clicks.

Keep in mind that switching from a lossy format to a lossy format will reduce sound quality more than switching from a lossless format (FLAC, CD Audio, Apple Lossless Codec) to a lossy format (MP3, OGG, M4A). If you have access to a lossless sound source, use it to convert.

+1
source

You can do this in C ++ with the Windows Media Format SDK .

I myself used only WMFSDK9. It contains a sample called UncompAVIToWMV that can help you get started. From the Readme:

It shows how to merge samples for audio and video streams from several AVIs and either combine them into similar streams or create a new stream based on the source stream profile. It also shows how to create an arbitrary stream, multi-pass encoding and adding SMPTE temporary codes.

0
source

Source: https://habr.com/ru/post/1285672/


All Articles