function ShowVideoWithCorrectAspectRatio (string video ,float fps , int x2, int y2, int BackgroundColor, bool DvdMode, bool AspectRatio43) {

    VideoF=DirectShowSource(video,audio=false,video=true)

    x1=Width(VideoF)
    y1=Height(VideoF)
    
    #ymax = (fps==25) ? 576 : 480
    ymax = y2
        
    DvdMode==true && AspectRatio43==true && fps==25 ? Eval("""
    par1=1.025641
    par2=1.0940171
    """):Eval(""" """)
   
    DvdMode==true && AspectRatio43==true && fps!=25 ? Eval("""
    par1=1.0255328
    par2=0.9115847
    """):Eval(""" """)
    
    DvdMode==true && AspectRatio43==false && fps==25 ? Eval("""
    par1=1.025641
    par2=1.4586895
    """):Eval(""" """)
    
    DvdMode==true && AspectRatio43==false && fps!=25 ? Eval("""
    par1=1.0255328
    par2=1.2154463
    """):Eval(""" """)
    
    DvdMode==false && fps==25 ? Eval("""
    par1=1.025641
    par2=1
    """):Eval(""" """)
    
    DvdMode==false && fps!=25 ? Eval("""
    par1=1.0255328
    par2=1
    """):Eval(""" """)
    
    yt=Round((x2*y1*par2)/(4*x1*par1))*4
    
    yt <= ymax  ? Eval("""
      VideoF=BilinearResize(VideoF , Round(x2/4)*4 , yt)
      VideoF=AddBorders(VideoF , 0 , Round(Abs(y2-yt)/2) , 0 , Abs(y2-yt)-Round(Abs(y2-yt)/2) , BackgroundColor)     
    """) : Eval("""
      xt=Round((x1*par1*y2)/(4*y1*par2))*4
      VideoF=BilinearResize(VideoF , xt , Round(y2/4)*4) 
      VideoF=AddBorders(VideoF , Round(Abs(x2-xt)/2) , 0 , Abs(x2-xt)-Round(Abs(x2-xt)/2) , 0 , BackgroundColor)
    """)

   VideoF=ConvertToRGB32(VideoF).ConvertFPS(fps).killaudio

   return VideoF

 }