Jump to content

Winmm.dll play video fill the entire screen


Belini
 Share

Recommended Posts

Does anyone know what I should use in mciSendString for video to occupy every area of the screen without having black stripes on top, bottom or sides?

Link to comment
Share on other sites

I'm not sure how your question is relevant to AutoIt, but have you tried the "stretch" flag of the Window command?

Edited by TheXman
Link to comment
Share on other sites

@TheXman I tried in some ways but none worked.

_mciSendString("play " & $sAlias & "window stretch")

_mciSendString("play " & $sAlias & " stretch")

_mciSendString("window " & $sAlias & " stretch")

_mciSendString($sAlias & "window stretch")

_mciSendString($sAlias & " stretch")

 

Link to comment
Share on other sites

I found the code made in VB but it didn't work with Autoit.

' Videobild stretchen
Public Sub mciSetVideoStretch()
  On Error Resume Next
  mciSendString "window TempMCI stretch", 0, 0, 0
End Sub
_mciSendString("window " & $sAlias & " stretch"); Autoit

 

Link to comment
Share on other sites

  • 3 years later...

@Belini, Have you come up with a solution? In my experience, most of the files would stretch to whatever size I give with WinMove() function after I obtain a popup style video window. But there are some files, especially of movies, that persistently keep the original aspect ratios and fill up the blank spaces with black strips. It may have something to do with codecs. For your information, I use K-Lite codecs. If you have found a solution, would you mind sharing your solution? Thanks in advance.

Link to comment
Share on other sites

unfortunately not and I'm trying to use a player that already has this option and that also doesn't need to install codecs to work, what seemed like it would work better was libvlc but I had problems incorporating its window into an Autoit gui, if I can get one that works well I'll give you the tip.

Link to comment
Share on other sites

  • 5 months later...

I implemented fullscreen function with winmm.dll in my zPlayer and the following is a replication of that function.

#include <GUIConstants.au3>

HotKeySet("{F11}", "_FullScreen")

Global $videoWidth = @DesktopWidth/3*2, $videoHeight = $videoWidth*9/16, $iGui, $iFullScreen
$hVideoGUI = GUICreate("WINMM.DLL", $videoWidth, $videoHeight)
$iGui = Dec(StringMid($hVideoGUI, 3))
GUISetState(@SW_HIDE, $hVideoGUI)
$aPos = WinGetPos($hVideoGUI)
$borderWidth = ($aPos[2]-$videoWidth)/2
$titleHeight = $aPos[3]-$videoHeight-$borderWidth
GUISetState()

$sFile = "D:\Video\Voorbeeld.mp4"

GUIRegisterMsg($WM_MOVE, "WM_MOVE")

$hDLL = DllOpen("winmm.dll")
mciSendString("open """ & $sFile & """ alias myMedia type MPEGVideo style popup parent " & $iGui)
$hVideo = WinGetHandle($sFile)
WinMove($hVideo, "", $aPos[0]+$borderWidth, $aPos[1]+$titleHeight, $videoWidth, $videoHeight)
mciSendString("play myMedia")

While 1
    Switch GUIGetMsg(0)
        Case $GUI_EVENT_CLOSE
            mciSendString("close myMedia")
            DllClose($hDLL)
            Exit
    EndSwitch
    If mciSendString("status myMedia mode") = "stopped" Then
        mciSendString("play myMedia from 0")
    EndIf
WEnd


Func mciSendString($string)
    Local $aRet = DllCall($hDLL, "int", "mciSendStringW", "wstr", $string, "wstr", "", "int", 65534, "hwnd", 0)
    If Not @error Then Return $aRet[2]
EndFunc     ;==>mciSendString


Func _FullScreen()
    If WinGetState($hVideo) < 7 Then Return
    WinActivate($hVideoGUI)
    If $iFullScreen = 0 Then
        $aPos = WinGetPos($hVideoGUI)
        $iFullScreen = 1
        WinMove($hVideo, "", 0, 0, @DesktopWidth, @DesktopHeight)
    Else
        $iFullScreen = 0
        WinMove($hVideo, "", $aPos[0]+$borderWidth, $aPos[1]+$titleHeight, $videoWidth, $videoHeight)
    EndIf
EndFunc


Func WM_MOVE($hWnd, $MsgID, $wParam, $lParam)
    #forceref $hWnd, $MsgID, $wParam, $lParam
    If $hWnd <> $hVideoGUI Then Return $GUI_RUNDEFMSG
    If $iFullScreen = 1 Then Return $GUI_RUNDEFMSG
    $aPos = WinGetPos($hVideoGUI)
    Local $x1, $y1, $w1, $h1
    $x1 = $aPos[0]+$borderWidth
    $y1 = $aPos[1]+$titleHeight
    $w1 = $aPos[2]-$borderWidth*2
    $h1 = $aPos[3]-$titleHeight-$borderWidth
    WinMove($hVideo, "", $x1, $y1, $w1, $h1)
    Return $GUI_RUNDEFMSG
EndFunc

 

Edited by CYCho
Link to comment
Share on other sites

Thanks @CYCho I'll test it here to see if it works on mine too

EDITED: I tested it here and it doesn't work, your script only maximizes the window but doesn't make the video fill the entire screen and it still has black stripes when the video isn't the same resolution as the desktop

Edited by Belini
Link to comment
Share on other sites

2 hours ago, Belini said:

I tested it here and it doesn't work

I tested the above code in Windows 10 and 11 and it works as intended in both of the systems. What system are you on? in my zPlayer, I intentionally forced the screen to maintain the original source aspect ratio, but the above code is supposed to fill the entire screen regardless of the aspect ratio if F11 hotkey is pressed while a video is playing.

Edited by CYCho
Link to comment
Share on other sites

I tested it on Windows 7 and it gets black stripes on the sides if the video resolution is not equal or proportional to the desktop resolution.

KweDNifg_t.jpg

Link to comment
Share on other sites

On 12/5/2023 at 8:09 AM, Nine said:

How do you take a picture with 2 black stripes on the side ? 

I have a movie file which has black stripes on the top and bottom. I don't think the movie itself was shot with black stripes. The file I have might be a screen capture. Below is the image showing how it looks when played in Windows Media Player.

Edit: https://www.anymp4.com/video-editing/remove-black-bars-from-video.html

 

Imgae with black stripes.png

Edited by CYCho
Link to comment
Share on other sites

@CYCho this is how the 1024 x 786 video is shown in a resolution of 1600 x 900 using wimm.dll but there are players that have the option to stretch to fill the entire screen without getting those black stripes on the sides or top and lower, for example winamp and vlc.

Edited by Belini
Link to comment
Share on other sites

@Belini, the file I mentioned above is a 1920 x 1080 video and my desktop resolution is also 1920 x 1080. When I stretch this video to fullscreen in winmm.dll or vlc, I see the black stripes on top and bottom. I know that winmm.dll has no function to truncate the black stripes. I would like to see how vlc does it, but I am not so familiar with vlc. Could you let me know what options I should change in vlc to truncate the black stripes?

Ben Hur file Propties.png

Edited by CYCho
Link to comment
Share on other sites

To get a full screen in VLC you will first need to find out the aspect ratio of your desktop and send it to VLC via the command line when you open it, and I created a function to find out the aspect ratio of the desktop.

Global $oHttpObj = ObjCreate("winhttp.winhttprequest.5.1"); cria a janela do navegador para receber os comandos

$ratio_maq = Preenche_Tela(@DesktopWidth, @DesktopHeight); pega o aspect ratio da tela

$pid_vlc = Run('"' & @ScriptDir & '\vlc.exe"' & " --aspect-ratio=" & $ratio_maq & " --video-title=Video:9999 --fullscreen --video-x=1 --video-y=1 -Idummy --extraint=http --http-host=127.0.0.1 --http-port=9999 --http-password=0000", @ScriptDir, @SW_HIDE); executa o vlc

_Video_play(@ScriptDir & '\Produce.mp4'); toca o vídeo escolhido em tela cheia

Func Preenche_Tela($resol_w, $resol_h)
    Local $GCD, $ASP_RAT, $GUARD, $INT[3]
    $INT[1] = $resol_w
    $INT[2] = $resol_h
    For $i = $INT[1] To 1 Step -1
        If Mod($INT[1], $i) = 0 Then $GUARD &= "|" & $i & "|"
    Next
    For $i = $INT[2] To 1 Step -1
        If Mod($INT[2], $i) = 0 Then
            If StringInStr($GUARD, "|" & $i & "|") Then
                $GCD = $i
                ExitLoop
            EndIf
        EndIf
    Next
    $ASP_RAT = ($INT[1] / $GCD) & ":" & ($INT[2] / $GCD)
    Return $ASP_RAT
EndFunc   ;==>Preenche_Tela

Func _Video_play($video = "")
    Local $comando = "http://127.0.0.1:9999/requests/status.xml?command=in_enqueue&input=" & $video; coloca o arquivo na lista
    $oHttpObj.open("GET", $comando, False)
    $oHttpObj.SetRequestHeader("Authorization", "Basic OjAwMDA=0000")
    $oHttpObj.Send(); executa o vlc identificando a janela

    $comando = "http://127.0.0.1:9999/requests/status.xml?command=pl_play"
    $oHttpObj.open("GET", $comando, False)
    $oHttpObj.SetRequestHeader("Authorization", "Basic OjAwMDA=0000")
    $oHttpObj.Send()

    WinWait("Video:9999", "", 5)
    WinSetOnTop("Video:9999", "", 1)
EndFunc   ;==>_Video_play

 

Edited by Belini
Link to comment
Share on other sites

So your video was already made with black stripes, send me the video so I can check it out here.

Edited by Belini
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...