What MPEG4 encoder library to use? - c++

So I have a WIN32 app that records videos using DirectShow. Now I want to convert the .AVI files to .MP4.
I rather not use a custom filter in the source, since I don't want to have to register filters(admin needed). I also dont want to use a standalone application since it should be automatised. Preferbly I just want a library with a well documented API since im rather new to this. Then I can use it from my app to convert the .AVI files when they are done being recorded. Anyone can point me in a direction? Or have comments on my method of choice?
I'd be outmost grateful for any help and thanks in advance!

Because MPEG-4 codecs are not royalty free, finding suitable encoder might be not as easy as you could think of it. Microsoft does not provide Windows with the encoder, except H.264 (MPEG-4 Part 10) encoder in some editions of Windows 7, and only within Media Foundation (as opposed to DirectShow). If you are OK to be limited to those Windows 7 versions, Media Foundation might be a good option, MSDN offers samples to transcode file into file and it is reasonably easy and well documented.
There are third party solutions, there half made libraries you can leverage to encoder, there is FFmpeg which offers MPEG-4 Part 2 video encoder under LGPL, and MPEG-4 Part 10 through libx264 under GPL. And my understanding you might still be expected to pay royalties to MPEG-LA. FFmpeg might still be a good option to convert file to file because its command lnie interface is well documented (as opposed to libavformat/libavcodec API which are not so well documented on the contrary).
Another option is to use Windows Media codecs and compress into ASF/WMV files.

Libavcodec and libffmpeg -- an everything-to-everything media converter (includes library and command-line application): http://ffmpeg.org/

Related

how to use DirectShow to render audio in C++

I am just starting to learn DirectShow with C++. I need to use DirectShow to record the audio and write it to a WAV file on the disk. I heard from other people that Win 7 does not allow for rendering audio using DirectShow.
In addition, I would like to know how should I start with recoding audio using DirectShow with C++? If there is sample source, it would be great.
Thanks in advance.
I think you may have misunderstood these other people. Windows Media Foundation is aimed to be the successor of DirectShow, but DirectShow is still a very valid technology on Windows 7.
The easiest thing to accomplish what you want to do, is to get it right using the GraphEdit tool first ( I assume you want to do this programmatically).
Create a graph that contains your audio device, a WavDestFilter, and a file writer.
Source -> WavDest -> File Writer
Play the graph. Stop the graph and you should have created a .wav file with the recorded audio. If you can get this right, then you need to do the whole thing programmatically.
There are a couple of samples in the SDK that show you how to programmatically add filters to a graph and connect them, that should enable you to get started.
WRT the WavDestFilter, IIRC it might not be in all versions of the SDK, you'll have to find an appropriate one. You also need to build it, and regsvr32 it, so that it will show up in your list of available filters in GraphEdit.
If this all seems a bit much, I would read through the DirectShow documentation on MSDN to at least get an overview of DirectShow.

Analysing audio data for attributes at time intervals

I've been wanting to play around with audio parsing for a while now but I haven't really been able to find the correct library for what I want to do.
I basically just want to parse through a sound file and get amplitudes/frequencies and other relevant information at certain times during the song (like every 10 ms or so) so I can graph the data for example where the song speeds up a lot and where it gets really loud.
I've looked at OpenAL quite a bit but it doesn't look like it provides this ability, other than that I have not had much luck with finding out where to start. If anyone has done this or used a library which can do this a point in the right direction would be greatly appreciated. Thanks!
For parsing and decoding audio files I had good results with libsndfile, which runs on Windows/OSX/Linux and is open source (LGPL license). This library does not support mp3 (the author wants to avoid licensing issues), but it does support FLAC and Ogg/Vorbis.
If working with closed source libraries is not a problem for you, then an interesting option could be the Quicktime SDK from Apple. This SDK is available for OSX and Windows and is free for registered developers (you can register as an Apple developer for free as well). With the QT SDK you can parse all the file formats that the Quicktime Player supports, and that includes .mp3. The SDK gives you access to all the codecs installed by QuickTime, so you can read .mp3 files and have them decoded to PCM on the fly. Note that to use this SDK you have to have the free QuickTime Player installed.
As far as signal processing libraries I honestly can't recommend any, as I have written my own functions (for speech recognition, in case you are curious). There are a few open source projects that seem interesting listed in this page.
I recommend that you start simple, for example working on analyzing amplitude data, which is readily available from the PCM samples without having to do any processing. Being able to visualize the data is very useful, I have found Audacity to be an excellent visualization tool, and since it is open source you can build your own tests inside it.
Good luck!

combining separate audio and video files into one file C++

I am working on a C++ project with openCV. It is a simple web cam application with basic features like capturing pictures and videos. I have already been able to save video (w/o audio). Since openCV doesnot support audio processing, I was wondering if there is any way I can record audio separately in a different file and later combine those together to get one video file.
While searching on the internet, I did hear something about using ffmpeg with openCV. But I just cant figure out how to do it exactly.....
Can you guys help me? I would be very grateful... Thankyou!
P.S. I have used openCV and QT (for GUI)
As you said, opencv doesn't by itself deal with audio. However once you get a separate audio and video file, you can combine them using a technique called muxing. There are many many ways to do this. I use VirtualDub for most of my muxing needs, although it is windows only (not sure if that's a problem). I know ffmpeg is also capable of muxing (via the command line interface), I can't recall what the command is. There's also mplayer and a multitude of other programs out there to do this.
as far as i know openCV is good for video/image processing. To support audio processing, you can use other libraries e.g. PortAudio or C-sound.

Combine Video and Audio Streams (Qt, OpenCV, PortAudio,libsnd?)

I was wondering, how would I combine recorded audio and video into one if I have them in separate files? Preferably using OpenCV and PortAudio/libsnd.
Thanks in advance.
FFmpeg is used to decode and encode almost all popular formats. It can be used as an alternative to all of these. PortAudio will probably only be useful for audio playback, so unless you need to play the stuff back it won't be needed. In case you do need A/V playback, FFmpeg is also good (VLC uses it.)
You can refer ffmpeg
On linux try mencoder usually part of the mplayer package. It is fairly straight forward to use after reading through its man page.

Can one decode real media file to other media formats using any free C++ library?

Please provide some pointers on how to convert real media formats to other popular media formats using some C++ sdk(I guess Helix provides one but don't know how to use it).
I am a total newbie in the above area, any help would be highly appreciated.
libavcodec (a library behind ffmpeg and other heavily-used programs) supports some common Real video formats. See this page; the tutorial itself is obsolete, but there are linked updates such as An ffmpeg and SDL Tutorial
Helix may be an option, but keep in mind the actual Real Video codecs are only available as binaries, while libavcode is fully open source.
Don't expect this to be trivial, whichever library you use.