DirectShow video compressors enumeration issue - directx

I am trying to find available DirectShow video encoders, using following code:
ICreateDevEnumPtr pEnm(CLSID_SystemDeviceEnum,NULL,CLSCTX_INPROC_SERVER);
// Video Compressor
if(pEnm!= NULL)
{
IEnumMonikerPtr pEnumMoniker;
hr = pEnm->CreateClassEnumerator(CLSID_VideoCompressorCategory,&pEnumMoniker,0);
//......
}
However, some video compressors installed in the system (Windows 10 x64) have different category.
For example "Microsoft MPEG-2 Encoder" and "VisioForge H264 Encoder" have category {083863F1-70DE-11d0-BD40-00A0C911CE86} - CLSID_LegacyAmFilterCategory
If I use CLSID_LegacyAmFilterCategory instead of CLSID_VideoCompressorCategory in my code, I get a lot of irrelevant objects.
Can you suggest the proper way to enumerate the DirectShow video compressors installed in the system ?

There is no better way and most likely you don't need any other way. You need this enumeration to eventually check availability of specific codec of interest and instantiate it. It is hard to imagine that you are building an application capable to pick some arbitrary installed codec and be able to use it, you normally deal with compression codecs you are well familiar with, esp. H.264 video compression codecs which have certain specific configuration methods etc. For the codecs you are familiar with you would want to have codec specific instantiation and configuration ways, one might need a discovery through enumeration, another would be available for instantiation via CLSID directly.

Related

Will there be any trace if I encode video with my laptop?

As the title says
I want to know if there are anything that will help someone to trace the laptop or machine used for encoding the video?
Also is there any trace in image file too? Like I watermark with ffmpeg and my machine code is added into metadata of that image?
With ffmpeg, no. Add -bitexact to be sure.
Depending on the applicatzion you are using, container and codec you are encoding to, this is possible.
For ffmpeg i am not aware that it puts any machine related stuff into any format or codec.
Even when you are using external encoders instead of built-in ones like AMD or NVIDIA stuff, currently the codecs do not allow to put such data into the stream.
Sure, future audio/video codecs might allow such metadata in order to find out if the encoder is licensed correctly, but as by now i am not aware of such stuff.
What cameras do for example to overcome the lack of codecs and formats support for storage of this information is to just write some xml along to the media file where they store serial number and such.
If there was such information contained, analyzer tools like "mediainfo" would show this info. I am not yet affiliated with mediainfo Sarl.

Does the ExtAudioFile API ever use hardware to decode audio?

I am using the ExtAudioFile interface to decode audio, and would like to know whether it ever makes use of hardware-assisted audio decoding.
The docs for the kExtAudioFileProperty_CodecManufacturer property say:
Use this property in iOS to choose between a hardware or software encoder, by specifying kAppleHardwareAudioCodecManufacturer or kAppleSoftwareAudioCodecManufacturer.
This seems to indicate that ExtAudioFile can indeed make use of decoding hardware.
Elsewhere, in the Audio Format Services docs, I find:
Hardware-based codecs can be used only when playing or recording using Audio Queue Services or using interfaces, such as AV Foundation, which use Audio Queue Services. In particular, you cannot use hardware-based audio codecs with OpenAL or when using the I/O audio unit.
... which is not completely clear; if ExtAudioFile uses Audio Queue Services in its implementation, then maybe it can make use of hardware, but we don't actually know how it is implemented.
I tried to test at runtime whether the hardware was being used, but this itself proved difficult. One method, given in the Audio Format Services reference, is to use AudioFormatGetProperty to test the kAudioFormatProperty_HardwareCodecCapabilities property. But the sample code does not work, always returning kAudioFormatUnsupportedPropertyError. (After searching online, I found a few other questions from people who have this problem, but no reports of ever using it successfully.)
So... I'm wondering if anyone knows of any way to test for certain whether the hardware decoder is currently active (in which case I could test for myself whether ExtAudioFile is using it). Or alternatively if anyone has any definitive knowledge of whether ExtAudioFile does use hardware (not based solely on the vague mentions in the Apple docs).
Specifying kAppleHardwareAudioCodecManufacturer with ExtAudioFileSetProperty() appears to enable hardware decoding, because it fails with kAudioConverterErr_HardwareInUse when there is already one audio file open with that codec set, and with kAudioQueueErr_InvalidCodecAccess when the audio category is set to one that does not (according to the documentation) enable hardware decoding.
However, after profiling with Instruments, I found that performance was slightly worse with hardware decoding enabled, which I still can't explain...

Is there a simple DirectShow filter that can mix audio together of the exact same format?

I have a DirectShow application written in Delphi 6 using the DSPACK component library. I want to be able to mix together audio coming from the output pins from multiple Capture Filters that are set to the exact same media format. Is there an open source or "sdk sample" filter that does this?
I know that intelligent mixing is a big deal and that I'd most likely have to buy a commercial library to do that. But all I need is a DirectShow filter that can accept wave audio input from multiple output pins and does a straight addition of the samples received. I know there are Tee Filter's for splitting a single stream into multiple streams (one-to-many), but I need something that does the opposite (many-to-one), preferably with format checking on each input connection attempt so that any attempt to attach an output pin with a different media format than the ones already added is thwarted with an error. Is there anything out there?
Not sure about anything available out of the box, however it would be definitely a third party component.
The complexity of creating this custom filter is not very high (it is not a rocket science in terms of creating such component yourself for specific need). You basically need to have all input audio converted to the same PCM format, match the timestamps, add the data and then deliver via output pin.

Snapshot using vlc (to get snapshot on RAM)

I was planning to use the vlc library to decode an H.264 based RTSP stream and extract each frame from it (convert vlc picture to IplImage). I have done a bit of exploration of the vlc code and concluded that there is a function called libvlc_video_take_snapshot which does a similar thing. However the captured frame in this case is saved on the hard disk which I wish to avoid due to the real time nature of my application. What would be the best way to do this? Would it be possible without modifying the vlc source (I want to avoid recompilation if possible). I have heard of vmem etc but could not really figure out what it does and how to use it.
The picture_t structure is internal to the library, how can we get an access to the same.
Awaiting your response.
P.S. Earlier I tried doing this using FFMPEG, however the ffmpeg library has a lot of issues while decoding an H.264 based RTSP stream on windows and hence I had to switch to VLC.
Regards,
Saurabh Gandhi

Selecting a Video Encoder for Windows

My software encodes videos using the standard Windows AVIFile functionality. That means, it can use all the DirectShow Codecs that are installed.
I recommend my users to download the XVid Codec themselves, but that's inconvenient.
I cannot bundle XVid since my software is not GPL. Is there any good direct-show-compatible video codec that can be redistributed with a commercial application? Requirement: The videos must look great on YouTube.
If not, I could switch from AViFile to another library (e.g. FFMpeg). But I'd like to avoid that if possible.
Thanks! :-)
Edit: The videos are computer animation with very sharp details (explosions and sparks). The video should be high-bitrate.
Theora is an excellent open source codec with very good DirectShow support. You also might consider google's newer WebM codecs. You dont say what kind of video you are distributing (from a camcorder, animation/computer rendered graphics, etc), so some of the choice of codec may depend on the exact nature of your video.

Resources