IMFSourceReader giving error 0x80070491 for some resolutions - frameworks

I'm trying to catpure video from a 5MP UVC camera using an IMFSourceReader from Microsoft Media Foundation (on Windows 7 x64). Everything works just like the documentation with no errors on any API calls until the first callback into OnReadSample() which has "0x80070491 There was no match for the specified key in the index" as it's hrStatus parameter.
When I set the resolution down to 1080p it works fine even though 5MP is the camera's native resolution and 5MP (2592x1944) enumerates as an available format.
I can't find anything in the the Microsoft documentation to say that this behaviour is by design but it seems consistent so far. Has anyone else got IMFSourceReader to work at more that 1080p?
I see the same effects on the Microsoft MFCaptureToFile example when it's forced to select the native resolution:
HRESULT nativeTypeErrorCode = S_OK;
DWORD count = 0;
UINT32 streamIndex = 0;
UINT32 requiredWidth = 2592;
UINT32 requiredheight = 1944;
while ( nativeTypeErrorCode == S_OK )
{
IMFMediaType * nativeType = NULL;
nativeTypeErrorCode = m_pReader->GetNativeMediaType( streamIndex, count, &nativeType );
if ( nativeTypeErrorCode != S_OK ) continue;
// get the media type
GUID nativeGuid = { 0 };
hr = nativeType->GetGUID( MF_MT_SUBTYPE, &nativeGuid );
if ( FAILED( hr ) ) return hr;
UINT32 width, height;
hr = ::MFGetAttributeSize( nativeType, MF_MT_FRAME_SIZE, &width, &height );
if ( FAILED( hr ) ) return hr;
if ( nativeGuid == MFVideoFormat_YUY2 && width == requiredWidth && height == requiredheight )
{
// found native config, set it
hr = m_pReader->SetCurrentMediaType( streamIndex, NULL, nativeType );
if ( FAILED( hr ) ) return hr;
break;
}
SafeRelease( &nativeType );
count++;
}
Is there some undocumented maximum resolution with Media Framework?

It turns out that the problem was with the camera I was using, NOT the media streaming framework or UVC cameras generally.
I have switched back to using DirectShow sample grabbing which seems to work ok so far.

I ran into this same problem on windows 7 with a usb camera module I got from Amazon.com (ELP-USBFHD01M-L21). The default resolution of 1920x1080x30fps (MJPEG) works fine, but when I try to select 1280x720x60fps (also MJPEG, NOT h.264) I get the 0x80070491 error in the ReadSample callback. Various other resolutions work OK, such as 640x480x120fps. 1280x720x9fps (YUY2) also works.
The camera works fine at 1280x720x60fps in Direct Show.
Unfortunately, 1280x720x60fps is the resolution I want to use to do some fairly low latency augmented reality stuff with the Oculus Rift.
Interestingly, 1280x720x60fps works fine with the MFCaptureD3D sample in Windows 10 technical preview. I tried copying the ksthunk.sys and usbvideo.sys drivers from my windows 10 installation to my windows 7 machine, but they failed to load even when I booted in "Disable Driver Signing" mode.
After looking around on the web, it seems like various people with various webcams have run into this problem. I'm going to have to use DirectShow to do my video capture, which is annoying since it is a very old API which can't be used with app store applications.
I know this is a fairly obscure problem, but since Microsoft seems to have fixed it in Windows 10 it would be great if they backported the fix it to Windows 7. As it is, I can't use their recommended media foundation API because it won't work on most of the machines I have to run it on.
In any case, if you are having this problem, and Windows 10 is an option, try that as a fix.
Max Behensky

Related

Flir Lepton 3.5 Banana pi zero Armbian I2C issue

I have (I believed succesfully) enabled the spi and i2c on armbian to communicate with the lepton. Using the LEPTON FLIR libraries (e.g. https://github.com/Myzhar/Lepton3_Jetson/tree/master/grabber_lib/Lepton_SDK) I can communicate with the camera (set output etc. returns LEP_OK). However when I try to reboot the camera (using the LEP_RunOemReboot( &port )) I get I2C error. I tried to check in the file linux_I2C.c and I know that in function DEV_I2C_MasterReadData(...) the check if(bbb_result != 0 || bytesActuallyRead != bytesToRead) fails with values bbb_result = -1; bytesActuallyRead = 0 and bytesToRead = 2. As the settings otherwise returns OK (I have no way to check it, as the camera seems to get stuck after one frame. I want to reboot it and I get to this loop).
Any idea what is going on?
[EDIT] does not seem to be this issue as sleeps around the write function did nothing.
(the issue seems to be the write int DEV_I2C_MasterReadData(...) returning -1)

SUPSTRONICS X400 Raspberry pi 3 with Android things

I've been trying to create a car head using the raspberry pi and android things. In order to power the car audio I bought this amp Suptronics X400 but I haven't been able to use it as the default output for audio and I'm trying to integrate the Spotify SDK. I tried to create the drive but most of the Documentation here has been removed from the libraries. I'm a bit lost
The audio driver user driver is no longer available in Android Things. The right way is to use the AudioTrack class and set the preferred device type, as is done in this sample project.
You may need to specify the audio bus you want to send sounds to:
private AudioDeviceInfo findAudioDevice(int deviceFlag, int deviceType) {
AudioManager manager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
AudioDeviceInfo[] adis = manager.getDevices(deviceFlag);
for (AudioDeviceInfo adi : adis) {
if (adi.getType() == deviceType) {
return adi;
}
}
return null;
}
Then find the I2S bus:
mAudioInputDevice = findAudioDevice(AudioManager.GET_DEVICES_INPUTS, AudioDeviceInfo.TYPE_BUS);
mAudioOutputDevice = findAudioDevice(AudioManager.GET_DEVICES_OUTPUTS, AudioDeviceInfo.TYPE_BUS);
Then you can run audioTrack.setPreferredDevice(mAudioOutputDevice);

TinyMCE can't resize Youtube videos embeded on Plone 4.3.10rc1

I've upgraded to Products.TinyMCE 1.3.25 on my Plone 4.3.10rc1 installation. When I add an embeded video in edition mode, I can't resize the frame. It occurs only with Youtube videos, but it works fine with Vimeo, por instance.
I have tried an answer in https://github.com/tinymce/tinymce/issues/3614?_pjax=%23js-repo-pjax-container, but without answer yet.
Any issues about that? Thanks in advance...
You cannot resize the video because it's dimensions are being explicitly set by the media plugin.
I am on TinyMCE version 3.5.12 (2016-10-31). I tried to debug the JavaScript. And in the media plugin, there is part of code, which compares URL with some pattern, and if the URL is YouTube, than it sets the size to exactly 425x350.
The part of code is this:
// YouTube Embed
if (src.match(/youtube\.com\/embed\/\w+/)) {
data.width = 425;
data.height = 350;
data.params.frameborder = '0';
data.type = 'iframe';
setVal('src', src);
setVal('media_type', data.type);
}
...
setVal('width', data.width || (data.type == 'audio' ? 300 : 320));
setVal('height', data.height || (data.type == 'audio' ? 32 : 240));
I don't understand the purpose of the code yet, but clearly, it is there for purpose, not just some broken code.
Maybe it is meant as setting the dimensions for the first time, as initial size, but it sets them always.

Multidisplay Rendering

I'm trying to build a project on 4 screens (2x projectors and 2x monitors all running at 1024x768). I'm using 2xGTX 295s.
Every time I run the file (using -multidisplay) the main screen hangs black and if I look at the processes I see 3 other screens being created, but nothing ever appears. The log files say "D3D11:failed to create RenderTexture(1024 x 768 fmt 44 aa 8), error 0x8007000e" where each Display.Activate() code should execute.
Relevant code:
if (Display.displays.Length > 1) {
Display.displays [1].SetRenderingResolution (1024, 768);
Display.displays [1].Activate ();
}
if (Display.displays.Length > 2){
Display.displays [2].SetRenderingResolution (1024, 768);
Display.displays [2].Activate ();
}
if (Display.displays.Length > 3) {
Display.displays [3].SetRenderingResolution (1024, 768);
Display.displays [3].Activate ();
}
I've tried searching for a solution, but because multi-display is relatively new I can't seem to find anything on it.
Does anyone have a solution or idea? it would be greatly appreciated. Thanks for your time.
This sounds like a driver issue. Windows update probably updated your video driver. Update your driver from device manager. If that didn't work, use a video driver from the manufacturer of your PC.You can easily download this from their website. Will provide link if you update your question with name of your PC make, the model number and the Operating System.

How to use EM_INSERTIMAGE?

Using Visual Studio 2013 Community.
Added #include to source code.
Added Shlwapi.lib to linker.
Compile and link OK.
This is the code that uses EM_INSERTIMAGE:
static void insertimage( )
{
RICHEDIT_IMAGE_PARAMETERS rip;
IStream *pStream = NULL;
DWORD grfMode = STGM_READ | STGM_SHARE_DENY_NONE;
HRESULT hr = SHCreateStreamOnFileA( "add.png", grfMode, &pStream );
if (hr == S_OK)
{
ZeroMemory( &rip, sizeof( rip ) );
rip.xWidth = 2000; // unit 0.01mm
rip.yHeight = 2000;
rip.Type = TA_BASELINE;
rip.pwszAlternateText = L"adding xyz";
rip.pIStream = pStream;
hr = SendMessage( hwndrichedit, EM_INSERTIMAGE, (WPARAM)0, (LPARAM)&rip );
if (hr == S_OK)
{
// getting here, but not getting any image or alternate text
// output on screen
}
}
}
but it does not output any image or alternative text on screen and does not put the image control words into the rtf file.
I also tried SHCreateStreamOnFileEx with same negative result.
How can I make this work?
I forgot to mention I am using Windows 7.
I have been searching Google on EM_INSERTIMAGE and other keys and found
a match that said EM_INSERTIMAGE requires Windows 8. I checked EM_INSERTIMAGE
MSDN and found this in the Requirements section 'Minimum supported client
Windows 8 [desktop apps only]'.
I did not expect this because Wordpad and Windows Office 10 on my Windows 7 PC
can insert images. Also, the Linux TED richedit text editor can insert images
in Ubuntu 12.04 released three years ago.
Maybe these programs just insert the image spec into rtf
as required by the rtf format specification.
I assume EM_INSERTIMAGE issued by a user program would generate the image
rtf part and insert it into the rtf format text.
I am happy with Windows 7 and will not change to Windows 8, so it seems I
will not be able have images.
If EM_INSERTIMAGE only works on Windows 8, I think there should be an error
returned when EM_INSERTIMAGE is issued from Windows 7, Windows XP etc.
EM_INSERTIMAGE is only available from Windows 8 onwards. In Windows 7, you will need to use the RichEdit's OLE interface to insert images. That's how Wordpad does it. You can look up this example on MSDN:
RichEdit OLE sample