sskodje / ScreenRecorderLib

A .NET library for screen recording in Windows, using native Microsoft Media Foundation for realtime encoding to h264 video or PNG images.
MIT License
414 stars 94 forks source link

Add AudioEncoderFormat #293

Open ansarmie opened 7 months ago

ansarmie commented 7 months ago

I noticed the MP4 container supports older audio codecs. Like Windows.Media.MediaProperties - MediaEncodingSubtypes.Mp3 Property.

Full list:

MPEG-4 (MP4) | MDN.

It would be nice if there was a possibility to add AudioEncoderFormat options similar to VideoEncoderFormat to expose the audio codec selection to the consumer of the library. And still default to AAC if unused.

Right now it looks like AAC is taken from a constant here:

CommonTypes.h - AUDIO_OPTIONS/AUDIO_ENCODING_FORMAT .

And then used here:

OutputManager.cpp - OutputManager::ConfigureOutputMediaTypes.

sskodje commented 7 months ago

Hi! I never got anything but AAC to work with H264 or HEVC in mp4 container using Media Foundation, which is why it is hardcoded. It is very poorly documented. That's a few years ago now, so if you can make it work, i'm more than happy to add options for it :)