Page 4 of 7

Posted: Thu Mar 22, 2007 4:43 am
by hmoraldo
Loockas wrote:Hey,
I've got the runtime error while trying to run my app. I've used the simplest code from wiki and it compiles fine though there was a problem with missing ddraw.h file but after installing directx sdk all went well. Anyone has encountered that issue with runtime error?
Please post details on the error (error message, stack trace), and the log file, otherwise we can't tell much about the problem.

Posted: Thu Mar 22, 2007 8:01 am
by futnuh
Hopefully it isn't considered poor taste to offer a small bounty for what should be a very small amount of work? If it is, I apologize and promise not to do it again. If you aren't offended however, feel free to read http://www.ogre3d.org/phpBB2addons/view ... hp?p=22182

The task will take me 2-3 hours tomorrow so the price seems reasonable given that the result benefits the (python) Ogre community. If you're interested, please read the thread carefully - I'll pay only if it passes muster by the python-ogre guys. If I (or they) have to start mucking around with your submission, it defeats the purpose of offering a bounty. If you're going to do it, post a message in the thread - no use a slew of people recreating the proverbial wheel.

Posted: Thu Mar 22, 2007 2:17 pm
by hmoraldo
Hmmm, I can't do that, I'm busy these days.

Posted: Thu Mar 22, 2007 3:43 pm
by Loockas
hmoraldo wrote:
Loockas wrote:Hey,
I've got the runtime error while trying to run my app. I've used the simplest code from wiki and it compiles fine though there was a problem with missing ddraw.h file but after installing directx sdk all went well. Anyone has encountered that issue with runtime error?
Please post details on the error (error message, stack trace), and the log file, otherwise we can't tell much about the problem.
I've noticed that my app crashes just after the loadmovie function.

I've got this error:
Image

And my log file ends with this:

Code: Select all

15:32:44: [DSHOW] Creating texture with dimensions 640x480.
15:32:44: [DSHOW] Loading movie named 'C:/test_movie.avi'.
EDIT: OK it was something wrong with my video file... with other ones it's working fine! :D Thanks a lot for this great plugin hmoraldo! :D
Umm just one question. How can I load my video not from specified path but from my media folder just like a resource?
Oh, and one more thing. :oops: How to set fullscreen? I can't use the setUV function because there is no PanelOverlayElement class...

Posted: Tue Mar 27, 2007 3:19 am
by independentCreations
@Loockas i have the same crashing problem as yours, i have used directshow before and come across this but i forget how i resolved the issue. My audio works, but i get a crash and i dont see any visual. is there any codec that i should be using????

:Edit: fixed first, material error

Also has any one come across and got around the debugger detected message with visual studio??

:Edit: To find a movie and its relative path using ogre

Code: Select all

Ogre::String path;
Ogre::FileInfoListPtr results =  Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo("General", "*.avi");
Ogre::FileInfoList::iterator itr = results->begin();
while(itr != results->end())
{
	if((*itr).filename == "Cova_Marketing.avi")
	{
		path = (*itr).archive->getName() + "/" + (*itr).filename;
		m_clip->loadMovie(path);
		m_clip->playMovie();
		//and so on
		break;
	}
	itr ++;
}

Posted: Sun Apr 01, 2007 5:25 pm
by MickeMicke
Hi! I've got this error when I'm running Visual Studio and using DirectShow, otherwise not:
Image

Any suggestions?

Posted: Thu Apr 05, 2007 1:38 pm
by mako
I'm getting this error too MickeMicke. just after loading a movie, I've tryed with an avi and a mpg video that I downloaded from gamespot.
I'll try with other movies, cause I guess this is a video codec problem.

Posted: Thu Apr 05, 2007 6:34 pm
by mako
the problem is in this line

hr=dsdata->pGraph->RenderFile(filepath, NULL);

filepath seems alright to me.

using ogre 1.4 and directx February 2007 SDK.

Posted: Wed May 30, 2007 11:45 am
by syedhs
ahmedali wrote:I solved the xvid problem by turning the compatibility option on in its decoder properties. But the mpeg2 problem remains.
Sorry to revive this thread - but I faced the same problem as Ahmedali's. Not sure you are still having this problem, but I get this solved by manually setting the subtype & formattype. Originally it was this:-

Code: Select all

mt.subtype = MEDIASUBTYPE_RGB24;
mt.formattype = FORMAT_VideoInfo;
I have it changed to this:-

Code: Select all

mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
mt.formattype = FORMAT_MPEG2Video;
I think there could be better solution (eg smart detection) but this is suffice for my problem.

Thanks hmoraldo! :)

Edit: Opss premature solution.. there video doesn't get displayed :?

Posted: Thu May 31, 2007 11:26 am
by syedhs
Yay.. 80% done! MPEG2 get displayed although DIVX still dont get displayed. I think it should get displayed because the modification to make it work is based on this: http://www.codeproject.com/audio/VideoA ... ct=1797483
and the binary downloaded from there is able to display all files. The remaining 20% job is
1) to get the frames synched with audio (now the frames are displayed as fast as possible).
2) COMs object cleanup.
3) getting the video synched with audio,

To those interested, below is my modification:-
loadMovie

Code: Select all

hr=dsdata->pGrabber->SetMediaType(&mt);
if (FAILED(hr)) throw("[DSHOW] Error in setting sample grabber media type");

//---------------Starts here
IBaseFilter* srcFilter;
WCHAR* filepath = util_convertCStringToWString(moviePath.c_str());	
hr = dsdata->pGraph->AddSourceFilter(filepath, L"Source", &srcFilter);
if(FAILED(hr)) throw ("[DSHOW] Unsupported media type!");

// Connect the src and grabber
hr = ConnectFilters(dsdata->pGraph, srcFilter, dsdata->pGrabberF);
if(FAILED(hr)) throw ("[DSHOW] Unsupported media type!");
//---------------End here

// open the file!
hr=dsdata->pGraph->RenderFile(filepath, NULL);
if (FAILED(hr)) throw("[DSHOW] Error opening video file!");
and the supporting functions...

Code: Select all

HRESULT DirectShowMovieTexture::ConnectFilters(IGraphBuilder *pGraph, IBaseFilter *pFirst, IBaseFilter *pSecond)
{
	IPin *pOut = NULL, *pIn = NULL;
	HRESULT hr = GetPin(pSecond, PINDIR_INPUT, &pIn);
	if (FAILED(hr)) return hr;
	// The previous filter may have multiple outputs, so try each one!
	IEnumPins  *pEnum;
	pFirst->EnumPins(&pEnum);
	while(pEnum->Next(1, &pOut, 0) == S_OK)
	{
		PIN_DIRECTION PinDirThis;
		pOut->QueryDirection(&PinDirThis);
		if (PINDIR_OUTPUT == PinDirThis)
		{
			hr = pGraph->Connect(pOut, pIn);
			if(!FAILED(hr))
			{
				break;
			}
		}
	}
	pEnum->Release();
	pIn->Release();
	pOut->Release();
	return hr;
}

// Helper functions:
HRESULT DirectShowMovieTexture::GetPin(IBaseFilter *pFilter, _PinDirection PinDir, IPin **ppPin)
{
	IEnumPins  *pEnum;
	IPin       *pPin;
	pFilter->EnumPins(&pEnum);
	while(pEnum->Next(1, &pPin, 0) == S_OK)
	{
		PIN_DIRECTION PinDirThis;
		pPin->QueryDirection(&PinDirThis);
		if (PinDir == PinDirThis)
		{
			pEnum->Release();
			*ppPin = pPin;
			return S_OK;
		}
		pPin->Release();
	}
	pEnum->Release();
	return E_FAIL;  
}

Posted: Thu Jun 07, 2007 3:05 pm
by manowar
This is a great piece of code ! How difficult would it be to retrieve and use the actual dimensions of the movie (read from the file) to create the texture ? I find it about annoying to have to specify the dimensions for each movie.

Thanks

Posted: Fri Jun 08, 2007 11:30 am
by manowar
I had a look on the code, and the Ogre::Texture is created before the movie is loaded. Why not loading the movie and then create the Ogre::Texture using the actual movie dimensions (dsdata->videoWidth, dsdata->videoHeight) ? I quickly hacked the code and moved the texture creation after the movie is loaded and it seems to work fine.
Is there anything wrong with doing that ? I do not have to modify the uvs which is not always simple when videos are applied on parts of models exported from modeling tools.

Posted: Mon Jun 18, 2007 10:34 pm
by hmoraldo
Hi. First of all, this code snippet is meant to be a simple class that deals with videos, so I'm not giving it full features but rather keeping simple enough so that any interested user can just modify the code to make it fits his/her needs. (Different and more complex versions of the code, to be published in neighbour pages on the wiki are welcome too)

The reason why I'm not using the video size to create the texture is that I'm rather trying to use a single texture to fit all videos that are going to be played in an application. And as only the user (and not the app) can know what the maximum size of a video to be played by the application is going to be, I'm keeping the selection of the texture size in hands of the programmer.

It's a personal choice, and of course there are plenty of alternatives. I could have coded it to create a new texture only when the newest video is bigger than the previous ones, or I could have coded it so that each video opened uses a different texture. In this case I chose the option explained above, as it was best fit for the use I was giving this resource and also as it was also appealingly simple. But by no means I say this is the best of all options, or that it should be best for all users or uses.

Thanks for your comments :)

Posted: Wed Jun 20, 2007 7:18 pm
by rluck
so I'm having the same issue KungFooMasta did, the video playing in the upper left hand corner. I used his setUV call, and it made the movie smaller, and it gets reproduced multiple times over the panel. Any ideas?

Image
The video size is 640x480, screen resolution is 1152x864.

edit: Fixed, always the stupid errors.

Posted: Fri Jun 22, 2007 8:11 pm
by jona vark
I have been able to compile this under VS2005 but I am having a problem with Coinitialize()

Code: Select all

	hr=CoInitialize(NULL);
		if (FAILED(hr))
		{
			throw("[DSHOW] Error in co initialize");

		}
hr is returnd as RPC_E_CHANGED_MODE

Which I guess means that some form of Coinititalize() was already called?

So should I check for this value and bypass Coinitialize() in that case?



thanks Jona

Edit:
I see you've all been dealing with the same sort of issues in this thread. When I posted this I had not seen the entire thread. I will review it. Meanwhile any insight is indeed helpful.

Posted: Fri Jun 22, 2007 9:43 pm
by ricardo_arango
Are there any license issues when using this?

Let's say for example to play an avi with a cinepak radius codec4?

Posted: Fri Jun 22, 2007 10:01 pm
by jona vark
As far as I can tell after only a couple of hours into it. You have to setup the MEDIASUBTYPE and other parms for the SampleGrabber code. So your video file and those parms have to match. See earlier parts of this thread.

Seems to be an issue with DV though that I am working out. I am trying to determine how you find the MEDIASUBTYPE of a file.

edit:

I was not able to get this puppy to work for me. Seems like any file type I tried failed. I was able to play the AUDIO of a DV_25 file with the MEDIASUBTYPE_DV25 and MEDIASUBTYPE_Avi but never got imagery with a wmv file or a MS Video1 avi file.

Purging on.

Posted: Sat Jun 23, 2007 1:28 am
by hmoraldo
ricardo_arango wrote:Are there any license issues when using this?

Let's say for example to play an avi with a cinepak radius codec4?
The code is under the zLib license. Apart from a few details, you can do with this what you could do anyway without this: so I guess what you can or you cannot do with such code rather depends on the license of that codec. But, as far as I know, as you are not using the codec directly, but through DirectShow, your program doesn't depend that much on the codec's license as in DirectShow's.

But I'm not an attorney so I can't really say for sure. Does anyone know better?

Jona Vark: sorry, I don't know why you are having these problems (I guess they require some additional directshow programming to get them working, but I have no time to check that). I can recommend you to try with other video formats? Mpeg has always worked fine for me, and anyway you could try converting some video to a few popular video formats to find those that work.

I'm sorry I couldn't give you more useful answers...

Best regards,

Posted: Sat Jun 23, 2007 1:43 am
by jona vark
>>I'm sorry I couldn't give you more useful answers...

Giving us the code was enough. I'll eventually figure it out.

Thanks

Posted: Sat Jun 23, 2007 2:58 pm
by hmoraldo
Thank you!

By the way, it's strange you aren't getting any visuals. Maybe the texture is being updated but you aren't seeing it? That you are getting the sound is generally the sign that you are very nearly making it work.

Regards!

Posted: Sat Jun 23, 2007 3:08 pm
by jona vark
Yes. I am working on it this morning and the first thing I am trying to get past is the fact that CoInitialize() failes. Even if I try to do it prior to any Ogre Init. I keep getting the RPC_E_CHANGED_MODE response.

I was able to play audio though, depending on the file type. I have created avi, dv, mpeg2 and wmv files to try and I have changed the MEDIASUBTYPE from _DV25 to _Avi and back to the RGB24 it was originally.

I am starting to wade through DirectShow doc but there isn't much there on what to do with the RPC_E_CHANGED_MODE result. From what I can tell it indicates that :
A previous call to CoInitializeEx specified a different concurrency model for the calling thread, or the thread that called CoInitializeEx currently belongs to the neutral threaded apartment.
Doh! I have little idea where that previous call could have come from.

This did not fail though:
.

Code: Select all

  HRESULT hr;
   hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
   if(FAILED(hr))
    {
        throw("[DSHOW] Error in co initialize");
        
     } 
hr is always returned as S_FALSE. Oddly all of the other calls to CoCreateInstance and AddFilter, etc return hr=0; So they seem fine. Like somthing else has called CoInitialize.

However. With most file types I get :
First-chance exception at 0x0862a8ed in daac.exe: 0xC0000005: Access violation writing location 0x00000000.
When calling

Code: Select all

hr=dsdata->pGraph->RenderFile(filepath, NULL);
On we go. My target is to have live video on Ogre Textures at some point

EDIT

Whew.. ok.. CoInitialize is the thread starter for COM? This is apparently another Rabbit Hole that would suck up my entire weekend. Even when CoInitialize is the first thing my app does it returns other than S_OK.

But this is a DShow problem. Not an Ogre problem.

Posted: Sat Jun 23, 2007 8:52 pm
by jona vark
MickeMicke wrote:Hi! I've got this error when I'm running Visual Studio and using DirectShow, otherwise not:
Image

Any suggestions?
If you get back to this thread .. I wanted to ask you. DO YOU Have NERO6 installed on your machine?

see this:http://www.hitlabnz.org/forum/showthread.php?t=70

UPDATE!

THIS WAS THE PROBLEM WITH MY MACHINE RUNNING THIS DEMO!

Yesterday , just to make sure I wasn't crazy I installed the latest Platform SDK, OgreSDK on another machine and rebuilt my entire project.

At the end of the day I had a wmv file playing in one of my textures on a plane.

So I took that project back to the main workstation and built it. Again I got the warning MessageBox shown above. The next thing I did was to uninstall Nero6 and ran again. Without rebuilding. I didn't bother to find out why but it's clearly a part of a protection scheme.

It worked.

That program is gone forever from my machine. Anyone trying to use the DShow features which use video codecs should not have Nero6 on their machine.

Posted: Tue Jun 26, 2007 1:33 am
by hmoraldo
I'm glad to know you could solve it, thanks for telling us how you did it!

Posted: Tue Jun 26, 2007 2:05 am
by jona vark
you're welcome.. meanwhile. If you see any good examples like this which use live video.. I am trying to comprehend the CaptureTex9 sample from the old DX SDK and see if I can held the two together.

Posted: Tue Jun 26, 2007 8:04 am
by ricardo_arango
I am trying to watch a video encoded with XVid. I checked the video in media player and it played fine.

When I tried to load it with the code it crashed in

Code: Select all

if (FAILED(hr)) throw("[DSHOW] Error getting connected media type info");
returning hr=0x80040209, which means:
An interface has too many methods to fire events from

If i try setting "compatibility renderer" in the Decoder Options dialog for Xvid, as someone recommended in a previous post, I get the "Protection Error, Debugger Detected error dialog", which is supposed to have something to do with Nero, but there is no way to deny a user from having Nero installed..

So, anyone got XVid working?