Change Video resolution

Fotis
2013-06-12
2013-07-01
  • Fotis

    Fotis - 2013-06-12

    Hi everybody.I want to render a video file with VMR9(windowless mode) with a different video resolution that the one the video file was encoded.Which is the best way to achieve that?
    I tried to do that with Grabber filter and getconnectedmedia I took the formatptr and change
    videoinfoheader.bmiheader width and height after through marshal.structuretoPtr i copied the structure videoinfoheader with new resolution to formatptr and through Grabber.setmedia i set the same media with different format,But it didnt worked.Any hint or direction?
    Thanks

     
  • Eric

    Eric - 2013-06-13

    I don't understand your problem... The VMR9 filter can stretch the video frames to cover the filter area!

    See IVMRWindowlessControl9.SetVideoPosition (http://msdn.microsoft.com/en-us/library/windows/desktop/dd390550%28v=vs.85%29.aspx)
    You should also read that: http://msdn.microsoft.com/en-us/library/windows/desktop/dd407296%28v=vs.85%29.aspx

     
  • Fotis

    Fotis - 2013-06-13

    Thanks Eric,I will tell what i mean..
    my code is

    retrive video size
    dim lwidth as integer
    dim lheight as integer
    hr=fc.GetNativeVideoSize(lwidth,lheight,0,0)

    now i create the source and destination rectangle
    dim rcSrc as new rectangle(0,0,lwitdth,lheight)
    dim rcDest as new Rectangle(me.panel1.top,me.panel1.left...........)

    hr=fc.SetVideoPosition(rcSrc,rcDset)
    So I understand that i retrieve the source rectangle(full resolution) and i set it to display according the size(coordinates) of the panel.So the video stretches according to the panel just to fit in(correct???)
    Now because i own a very old disk(IDE) and when i render together 3 or 4 videos sometimes the video freeze and i try to get resolution lower than normal to save some resources...and all i want to change is the native video size....and generally a want to have access to format of video and i want to be able to change things if nessesary..
    Allthough i dont use mixing mode but different instances of VMR9....
    I ve seen this procedure in your samples but this was achieved with CapureGraphBuilder2 and capture filter.the output file was encoded with different video size with use IStreamConfigInterface.....
    Thanks anyway

     
  • Eric

    Eric - 2013-06-20

    Displaying a frame in any size, using the VMR9, is normally very fast (just render two textured triangles using D3D9).

    Are you sure that your "video freezes" are related to the video ?
    How much CPU are you using while playing 3 or 4 videos ?

     
  • Fotis

    Fotis - 2013-06-29

    Sorry for the delay and thanks for the answer.
    Using four instances of vmr9 my cpu is working about 12%-18%....I dont believe is matter of cpu mostly because of low usage and secondly because its hyperthread i3 3.1ghz
    I believe its because of IDE it is very slow for my opinion...especially when displaying the same video all four of them.

     
    • Eric

      Eric - 2013-07-01

      It looks like you're right. You can validate the huge disk activity with the Task Manager's resource monitor on Window 7 / Vista or with the perfmon on Windows XP.

      If it's really a disk problem, you can do nothing from DirectShow. Try to do some defrag or buy an SSD !

       
  • David

    David - 2013-06-30

    You can use GetNumberOfCapabilities
    to get a list of resolutions and then set the resolution with SetFormat

    Dim iCount,iSize as Integer
    pCaptureConfig.GetNumberOfCapabilities(iCount, iSize)
    For i = 0 To iCount
    Dim sCapType As New AMMediaType
    Dim sCapCaps As New VideoStreamConfigCaps
    Dim IPT As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(sCapCaps))
    Marshal.StructureToPtr(sCapCaps, IPT, True)
    pCaptureConfig.GetStreamCaps(i, sCapType, IPT)
    If sCapType IsNot Nothing Then
    If sCapType.subType = MediaSubType.RGB24 Then
    Dim Info As New VideoInfoHeader
    Marshal.PtrToStructure(sCapType.formatPtr, sCapType)
    ReDim Preserve Resolutions(Index)
    Resolutions(Index) = New CaptureResolution(Info.BmiHeader.Width, Info.BmiHeader.Height)
    Index += 1
    End If
    End If
    DsUtils.FreeAMMediaType(sCapType)
    Next

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks