Mosaik Outputs flackern

  • Hello Thweiss,


    Apparently, info@vlc-forum.de don't like my bad english!

    I try with Dateianhänge, Hochladen.


    On the path F:\Vlc-de, I have put for you:

    - MosaicIcon.ico, an icon for Mosaic VLC;

    - Mosaic Video.lnk, a shortcut for start Mosaic VLC;

    - Mosaic.bat, the cmd script.


    I have seen Erlaubte Dateiendungen; all the above files are renamed with .txt; for MosaicIcon.ico (.txt) and Mosaic.bat (.txt) -> refused!

    I put Mosaic.bat in Quellcode; I don't see how return to message!


    I wish a good send; do not hesitate to ask me for explanations.


    Kind regards.

    Edmund


    @echo off
    rem ##################################################################################
    rem # Mosaic VLC -> from Video-1 to Video-4 #
    rem # ------------------------------------- #
    rem # All the windows are started with the audio. #
    rem # #
    rem # All the hotkeys of VLC are usable for each subpicture, after select with a #
    rem # mouse click. #
    rem # #
    rem # After launching of each subpicture, True is displayed in Mosaic VLC to #
    rem # indicate a good start, in mute; else, False is displayed. #
    rem # #
    rem # To quit the mosaic, select Mosaic VLC and strike any key. #
    rem # #
    rem # WARNING: #
    rem # Here, it is assumed that the creation time of the task corresponding to a #
    rem # sub-window is less than one second; if he can be superior: #
    rem # - increase the time in AudioToggle, $_.CPU -le 1; #
    rem # - if he is random, add a loop to make sure the task is fully started #
    rem # before searching for his Process id. #
    rem # #
    rem # Technical informations: #
    rem # - a VLC subpicture is composed of two windows Windows 10: #
    rem # - one main, hidden, identified by his Process id and his hWnd; #
    rem # - one child, used for display, identified by his hWnd; #
    rem # - the hotkeys of VLC must be adressed to the child window; #
    rem # - after sending to a child window, the only direct method to retrieve the #
    rem # focus here, is the use of Task view by the send of Alt+Tab; #
    rem # - NULL is a file created in the current path to log debug informations. #
    rem # #
    rem # Malfunctions: #
    rem # - thin black border around the videos; unknown cause; #
    rem # - --width and --height don't function; BUG VLC; here, --zoom is used; #
    rem # the inconvenients are : #
    rem # - necessity to adjust --zoom to obtain the wished size of the subpicture; #
    rem # - loss of video quality in fullscreen (strike of F), because upscaling on a #
    rem # reduced video resolution cannot be well displayed in the subpicture. #
    rem # #
    rem ##################################################################################

    rem ##################################################################################
    rem # Global variables initialization. #
    rem # #
    rem ##################################################################################
    setlocal enabledelayedexpansion &rem necessary for array and for /f loop
    set "title=Mosaic VLC"
    set "Stars=********************" &rem for well identify results of debug
    set "DllFwe='[DllImport("""user32.dll""")] public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, IntPtr lclassName, string windowTitle);'"
    set "DllSfw='[DllImport("""user32.dll""")] public static extern bool SetForegroundWindow(IntPtr hWnd);'"
    set ProcessId=0 & set hWmain=0 & set hWchild=0 &rem Initialization of the variables for returned values
    set SubpictureOldInd=0

    title %title%
    echo %title% started >NULL &rem debug
    rem New session (required for good use of SetForegroundWindow);
    powershell -Command " & {(New-Object -ComObject Shell.Application).MinimizeAll()}" &rem Minimize all opened windows (likewise with WinKey+M)

    rem ##################################################################################
    rem # Launching of the four subpictures. #
    rem # #
    rem ##################################################################################
    set "PathVlc=C:\Program Files (x86)\VideoLAN\VLC\"
    set "PathVideo=F:\Vlc-de\"
    set "Opt-0=--no-one-instance --no-one-instance-when-started-from-file --loop --no-repeat --no-embedded-video"
    set "Opt-1=--swscale-mode=10 --qt-start-minimized --no-qt-video-autoresize --no-video-deco --no-video-title-show"

    start "" "%PathVlc%vlc.exe" %Opt-0% %Opt-1% --video-x=1 --video-y=1 --zoom=0.75 "%PathVideo%Video-1.mp4"
    call :AudioToggle
    start "" "%PathVlc%vlc.exe" %Opt-0% %Opt-1% --video-x=961 --video-y=1 --zoom=0.75 "%PathVideo%Video-2.mp4"
    call :AudioToggle
    start "" "%PathVlc%vlc.exe" %Opt-0% %Opt-1% --video-x=1 --video-y=541 --zoom=0.75 "%PathVideo%Video-3.mp4"
    call :AudioToggle
    start "" "%PathVlc%vlc.exe" %Opt-0% %Opt-1% --video-x=961 --video-y=541 --zoom=0.75 "%PathVideo%Video-4.mp4"
    call :AudioToggle

    rem Informations given in the cmd window (Mosaic VLC).
    echo ^ Select a subpicture, strike:
    echo ^ ^ m to toggle audio mode
    echo ^ ^ f to toggle fullscreen mode
    echo ^ ^ n -^> next video
    echo ^ ^ p -^> previous video
    echo ^ ^ ~
    echo ^ To quit, select Mosaic VLC
    echo ^ and strike any key.

    pause >>NULL

    rem Select cmd and strike any key to quit all instances of VLC.
    powershell $WS=New-Object -ComObject wscript.shell; While($WS.AppActivate('VLC (Direct3D output)')){Sleep 1; $WS.SendKeys([char]94+'q')}
    exit

    rem ##################################################################################
    rem # FUNCTION AudioToggle -> to toggle the sound, using the hotkey M of VLC, for #
    rem # ----------- one subpicture. #
    rem # #
    rem # Warnings: #
    rem # - %, ", are significant characters for the command interpreter; for direct use,#
    rem # they must be trebled; #
    rem # - caret ^ is used at the end of a multiple lines command; its function is to #
    rem # take the next character for his ASCII value, here New line; so, the caret #
    rem # must be the last character of the line, and it's necessary to use Notepad or #
    rem # equivalent to edit; #
    rem # - to transmit online several return values from a PowerShell script to the #
    rem # calling cmd, the only possible method is the using of Environment Variable; #
    rem # the method used here ensures the good affectation in a cmd set statement. #
    rem # #
    rem ##################################################################################
    :AudioToggle

    set /a SubpictureOldInd+=1 &rem Increment the value of the variable by 1
    set ProcessId=0 & set hWmain=0 & set hWchild=0 &rem Initialization of the variables for returned values

    rem Line by line:
    rem - get the Process id of the last subpicture started;
    rem - waiting for the subpicture construction, and get the handle number of the MAIN window ($hWm);
    rem - get the handle number of the CHILD window ($hWc);
    rem - update the return value in the Environment Variable Vlc;
    rem - set the focus to the CHILD window;
    rem - the Sleep below is, only, to obtain a delay for listening the audio;
    rem send the hotkey m to toggle audio, and retrieve immediately the focus for cmd.

    powerShell $Pi=Get-Process 'vlc' ^| Where-Object{$_.CPU -le 1} ^| Select -expand ID; ^
    Sleep 1; $hWm=(Get-Process -Id $Pi.ToString()).MainWindowHandle; ^
    $FW=Add-Type -MemberDefinition %DllFwe% -Name Wfw -PassThru; $hWc=$FW::FindWindowEx($hWm,[IntPtr]::Zero,[IntPtr]::Zero,[String]::Empty); ^
    [System.Environment]::SetEnvironmentVariable('Vlc', $Pi.ToString()+' '+$hWm.ToString()+' '+$hWc.ToString(), 'user'); ^
    $SF=Add-Type -MemberDefinition %DllSfw% -Name Wsf -PassThru; $SF::SetForegroundWindow($hWc); ^
    $WS=New-Object -ComObject wscript.shell; Sleep 4; $WS.SendKeys('m'); $WS.SendKeys('%%%{TAB}')

    rem Get return value in Vlc; this syntax reg query is for a one line result of a command.
    for /f "tokens=3-5" %%V in ('"reg query "HKCU\Environment" /v Vlc"') do (set ProcessId=%%V &set hWmain=%%W &set hWchild=%%X)

    rem These variables are for future developments.
    echo %Stars% Subpicture %SubpictureOldInd% ProcessId= %ProcessId% hWmain= %hWmain% hWchild= %hWchild% %Stars% >>NULL &rem debug

    goto:eof
    rem # End of the FUNCTION AudioToggle ################################################

  • Hello Edmund,


    try to add for every File (Icon, *.bat, ...) the file-extension .txt.

    For example: rename "mosaic.bat" in "mosaic.bat.txt" and attach them in your next answer.


    Images, like Icon's should add as *.jpg or *.png files.


    Hope this way will work fine.


    Kind Regards

    Thomas

  • Hello Edmund,

    sorry for my late Answer.


    Today I could successful try your Commandline Script with completion by the stackoverflow experts.
    Have a look at the screendump "Mosaic-Edmund-VLC.jpg".


    I add in the Script small changes for my Computer with the VLC-Version 3.0.2 (64-Bit):
    - deleted four Script lines with # comment
    - set "PathVlc=C:\Program Files\VideoLAN\VLC\" (for the 64-Bit Version)
    - set "PathVideo=D:\Video\" (local Path for the Videos in my Computer)

    According to start the Mosaic-Script, the four Videos playing step by step with sound.
    All the Videos or subpictures I can select with the mouse and mute or unmute the sound with the key [m].
    Similarly I can close every VLC-Instance with the Key-Combination [Ctrl]+[Q] or the context-menu with the mouse.

    Your aim is successfull catched with the Script.

    There are only some small mistakes with the red-color Text in the Commandline-Windows ("Mosaic-Edmund-VLC.jpg") and the Keys [N] and [P], which will not work fine with the german keyboard. Some alphabetic Characters are changed between German and English Keybord.
    Perhaps anybody will find the Solution to avoid the small mistakes.


    I attach the adapted Script "Mosaic-Edmund-VLC.bat.txt" also for Downloading.
    Please delete the File-Extension .txt when the File ist saved on your Computer.

    A secound Script "Mosaic-Edmund-VLC-Streams.bat.txt" is working well with four Web-Livestreams.

    Please delete the File-Extension .txt when the File ist saved on your Computer.


    Kind Regards and many Thanks for your great Help.
    Thomas

  • An dieser Stelle möchte ich einen großen Dank an das Forum-Mitglied Edmund ausrichten, welcher das Mosaic-Script mit Hilfe von externen Script-Experten (https://stackoverflow.com/) weiterentwickelt hat.


    Sein Ziel war es die vier Videos im Mosaic-Script einzeln anzusteuern und den Ton individuell stumm zu schalten oder zu aktivieren.

    Weiterhin sollte jedes Video bzw. jede VLC-Instanz mit der Tastenkombination [Strg]+[Q] beendet werden.

    Das Script ist für einen Monitor mit einer Bildschirmauflösung von 1920×1080 Bildpunkten vorgesehen.

    Nach dem Start des Scriptes werden alle offenen Fenster in der Bildschirmansicht automatisch minimiert.


    Die Tonstummschaltung oder Aktivierung gelingt mit der Maus durch klicken in das jeweilige Video und anschließendem Drücken der Taste [m].

    Die Vollbildansicht lässt sich mit der Taste [f] oder einem Doppelklick mit der linken Maustaste erreichen.

    Die Tasten [N] und [P] sind für das Wechseln der Videofenster gedacht und funktionieren mit der deutschen Tastatur leider nicht so wie gewollt.

    Im Kommandozeilenfenster wird fehlerhafte Code in roter Textfarbe angezeigt. Durch drücken einer beliebigen Taste wird das Kommandozeilenfenster beendet bzw. geschlossen.


    Vielleicht findet sich jemand, der das Script für die deutsche Tastatur erfolgreich anpasst.


    MfG

    Thomas