MTS files stuttering with PC sticks

2 posters

Go down

MTS files stuttering with PC sticks Empty MTS files stuttering with PC sticks

Post by mOOmOOn Fri Feb 05, 2016 6:56 pm

Hi all,

I developed a video application base on VMR9.
It works fine on all PCs, using K-Lite pack, with mp4 and mts files as well.
Except with some new small PCs (tested Archos PC stick, Intel PC stick).
With those PCs, video is OK with 720p file, but with 1080p mts files issued from various camcorder (AVCHD), video is stuttering : plays 300ms, freezes half a second, ...

I have to mention that MediaPlayer Classic plays the same file perfectly.
With my application, CPU is not overloaded, although I can see CPU consumption is much higher than with MediaPlayer Classic.

I tried codec tweeking, changing splitter, codec, but did not find any good solution.
It seems I get better results by changing decoder Deinterlacing option from Auto to Disable (progressive), but with poorer video quality.

I also noticed that with the PC sticks, I get a EC_LENGTH_CHANGED message at start, that I do not get with PCs where it works fine (following, in all cases, I get EC_VMR_RENDERDEVICE_SET, EC_CLOCK_CHANGED, EC_CLOCK_CHANGED, EC_PAUSED).

Below is a basic source code of a test sample.
I can provide the complete .cpp file, VS Express 2012 project, video mts file, .exe file, if needed.

At the end, is there somewhere I can tweek any parameter so that my application works the same way as MediaPlayer Classic does ?

Thanks a lot for your help.


Code:
VMR9NormalizedRect *r;
IVMRWindowlessControl9 *pWC;
IVMRMixerControl9 *pMix;
IGraphBuilder *pGB;
IBaseFilter *pVmr;
IVMRFilterConfig9 *pConfig;
IMediaControl *pMC;
IMediaSeeking *pMS;
IMediaEventEx *pEvent;


TCHAR g_szFileName[MAX_PATH]="00000.mts";



void OpenClip()
{
  // initialize video coordinates with normal values
  r = new VMR9NormalizedRect;
  r->left = 0;
  r->top = 0;
  r->right = 1;
  r->bottom = 1;

  pWC = NULL;
  pMix = NULL;
  pGB = NULL;
  pVmr = NULL;
  pConfig = NULL;
  pMC = NULL;
  pMS = NULL;
  pEvent = NULL;

  // create an instance of the Filter Graph Manager
  CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
    IID_IGraphBuilder, (void **)&pGB);

  // create an instance of the VMR9 filter
  CoCreateInstance(CLSID_VideoMixingRenderer9, NULL, CLSCTX_INPROC,
    IID_IBaseFilter, (void**)&pVmr);

  // add the VMR9 filter to the Graph Manager
  pGB->AddFilter(pVmr, L"Video");

  // get a pointer toe the IVMRFilterConfig9 interface
  pVmr->QueryInterface(IID_IVMRFilterConfig9, (void**)&pConfig);
  // make sure VMR9 is in windowless mode
  pConfig->SetRenderingMode(VMR9Mode_Windowless);

  // get a pointer to the IVMRWindowlessControl9 interface
  pVmr->QueryInterface(IID_IVMRWindowlessControl9, (void**)&pWC);

  // set destination rectangle for the video
  pWC->SetVideoPosition(NULL, &rcDest);
  // specify the container window that the video should be clipped to
  pWC->SetVideoClippingWindow(ghApp);

  // IVMRMixerControl manipulates video streams
  pVmr->QueryInterface(IID_IVMRMixerControl9, (void**)&pMix);
  // IMediaSeeking seeks to a position in the video stream
  pGB->QueryInterface(IID_IMediaSeeking, (void **)&pMS);
  // IMediaControl controls flow of data through the graph
  pGB->QueryInterface(IID_IMediaControl, (void **)&pMC);

  pGB->QueryInterface(IID_IMediaEventEx, (void **)&pEvent);

  
  wchar_t wszString[_MAX_PATH];
  MultiByteToWideChar(CP_ACP, 0, g_szFileName, -1, wszString, sizeof(wszString) / sizeof(wchar_t));
  pGB->RenderFile((LPCWSTR)wszString, NULL);

  pMC->StopWhenReady();

  pMC->Run();
}


mOOmOOn

Posts : 9
Join date : 2016-02-05

Back to top Go down

MTS files stuttering with PC sticks Empty Re: MTS files stuttering with PC sticks

Post by Admin Sat Feb 06, 2016 11:57 am

Those PC sticks use an Intel Atom processor. Those have relatively low performance.

The codec pack enables DXVA2 (native) hardware acceleration on such systems when using MPC-HC. It also uses a different video renderer (EVR-CP).

So first thing you should try is using DXVA2. Assuming you need subtitles, you need to use the copy-back variant of DXVA2.

Admin
Admin

Posts : 7632
Join date : 2011-06-17

https://codecs.forumotion.net

Back to top Go down

MTS files stuttering with PC sticks Empty Re: MTS files stuttering with PC sticks

Post by mOOmOOn Sun Feb 07, 2016 2:47 pm

I did try DXVA2 acceleration but it was not better (66% CPU usage, and stuttering still there).
The answer is actually EVR : Without DXVA (no acceleration) : 70% CPU usage, and smooth video !
And with DXVA2, it drops to 10% CPU usage !
Thanks a lot.

mOOmOOn

Posts : 9
Join date : 2016-02-05

Back to top Go down

MTS files stuttering with PC sticks Empty Re: MTS files stuttering with PC sticks

Post by Admin Sun Feb 07, 2016 3:24 pm

DXVA2 only works with EVR (on Vista and newer). When using VMR9 it falls back to using normal software decoding.

Admin
Admin

Posts : 7632
Join date : 2011-06-17

https://codecs.forumotion.net

Back to top Go down

MTS files stuttering with PC sticks Empty Re: MTS files stuttering with PC sticks

Post by mOOmOOn Fri Feb 12, 2016 5:41 pm

Well, now I am facing another issue.
My application is also supposed to draw some GDIPlus stuff (basically scrolling text) in the window where the video is also displayed.
This used to work nice with VMR9, but now text is stuttering with EVR, and only during the RenderFile execution.
So it looks like RenderFile is locking GDIPlus access when in EVR mode.
Any idea of what can happen, and how to fix it ?

Thanks.

mOOmOOn

Posts : 9
Join date : 2016-02-05

Back to top Go down

MTS files stuttering with PC sticks Empty Re: MTS files stuttering with PC sticks

Post by Admin Fri Feb 12, 2016 10:26 pm

Is everything single-threaded? Try pre-rendering the text in a different thread.

Have a look at the source code of MPC-HC to see how they merge rendered subtitles in their custom EVR renderer.

Admin
Admin

Posts : 7632
Join date : 2011-06-17

https://codecs.forumotion.net

Back to top Go down

MTS files stuttering with PC sticks Empty Re: MTS files stuttering with PC sticks

Post by mOOmOOn Sat Feb 13, 2016 10:36 am

No, the application is already fully multithreaded.
I'll have a look at MPC-HC source code.
Thanks.

mOOmOOn

Posts : 9
Join date : 2016-02-05

Back to top Go down

MTS files stuttering with PC sticks Empty Re: MTS files stuttering with PC sticks

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum