logo

Live Production Software Forums


Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
nikosman88  
#1 Posted : Thursday, April 13, 2023 9:00:32 AM(UTC)
nikosman88

Rank: Advanced Member

Groups: Registered
Joined: 12/24/2021(UTC)
Posts: 542
Greece
Location: athens

Thanks: 130 times
Was thanked: 74 time(s) in 70 post(s)
Dear friends, good evening. As I have written before, I use vscheduler to create a 24-hour stream. Since 237dominique has made the application's code available, I tried to find a way to improve/change some things I wanted. In this regard, since I have no idea about programming, I thought of trying ChatGPT. You can find program and code here https://www.dropbox.com/...cheduler%202023.zip?dl=0
With the help of ChatGPT, I made some changes to the program:
1. Now when adding an event, the fade is preset to 0. I did this because when it is at 500, sometimes it abruptly cuts off the previous video and looks bad.

2. I changed the code that shuffles the events we select from the list. With the previous code, if we have 5 events on the list and shuffle them, the 5th one always goes to the 4th place and not higher.

3. I tried very hard and experimented a lot to find a way to make the program recognize the videolists of vmix directly. No matter how I tried, I failed. So, as you will read below, I thought of a new (new to me at least) approach to make this possible.

4. I created an extra program, the xml editor, which makes bulk changes to the lists of xml files generated by the program. This is still in an early version, so I won't upload it for now. These are the basics I did. Now, regarding how the program can recognize and play videolists from vmix... Since I couldn't achieve it directly within the program, I got disappointed and gave up. Until one day I needed a simple program that would input the time, minutes, and seconds and calculate what the new time would be. I asked ChatGPT, and it suggested/made a python script. I was culturally shocked that it told me exactly how to install python, run the script, and generally how quickly it implemented it, without needing even half a line of code.
When I asked it to create some vb.net scripts for vmix, it struggled a lot because, as I understood, while it gave me correct commands that actually exist in vb.net, the implementation of them by vmix has some limitations that ChatGPT, of course, does not know. After it made the first python script for me, I thought to ask if python supports xml searching, timers, and http requests.
And that's how a new (for me, at least) wonderful world opened up in front of me. So, I started a few days ago and have been creating Python scripts for vmix, which I will share, in case they prove useful to some other forum member or to get ideas and improvements, etc. What I see is that when the python script runs, it has zero impact on the CPU/GPU (at least for the simple ones I tested), so we are doing well in that regard too. I will start with the scripts.
1. Vmixvideolists
This specific script works with the vmanager program to play videolists from vmix. The usage is as follows:

We have our list in vmix that we want to play. We change the List name to anything we want, for example, Hellolist. Now we need to set the time it will play. We go to vmanager and create a new list and save it. The script searches in c:\vmixlists\, and this is something that can be changed within the script. So, we give our list a name in vmanager and save it. Thus, an XML file with the name we provided will be created inside the c:\vmixlists\ folder.

Now we need to add the time and date our list will play from vmix. We go to Events -> Add Event -> Operator mode, and we change the operator mode name to the name we gave our list in vmix, set the duration, and the time/date we want it to play. Then we press push to send the event to vcontroller. Then we save the list in vmanager again so the XML file gets updated with the new time.

Next, we run our .py script, and it asks us to enter the name of our XML file. For example, Hello.xml. After that, it asks us to enter the name we want to search for. Here we write Hellolist and press enter. That's it. We let the script run, and when the specified time comes (which we set in vmanager when creating the list there), it will play the vmix list. Note that each time we change the times in vmanager, we save to update the time in the script. If we change the list name in vmanager (change the XML file, that is), we run the script from the beginning with the new name of the XML file. I should mention here that since I am in Greece, ChatGPT added the following line to my code for the XML file to work: start_time_str = start_time_str.replace("πμ", "AM").replace("μμ", "PM"), which is for Greek regional settings. For you, it might be necessary to remove it or add the appropriate line for your own country's regional settings.

Code:

import os
import xml.etree.ElementTree as ET
from datetime import datetime, timedelta
import time
import requests

xml_folder = "c:/vmixlists/"
xml_filename = input("Enter the XML filename: ")

# Read multiple event titles separated by commas
event_titles_input = input("Enter the Event Titles to search for (separated by commas): ")
event_titles = [title.strip() for title in event_titles_input.split(",")]

xml_file_path = os.path.join(xml_folder, xml_filename)

while True:
    tree = ET.parse(xml_file_path)
    root = tree.getroot()

    for event_title in event_titles:
        found_event = None

        for event in root.iter("Event"):
            if event.get("Title") == event_title:
                start_time_str = event.get("Start")
                start_time_str = start_time_str.replace("πμ", "AM").replace("μμ", "PM")
                start_time = datetime.strptime(start_time_str, "%d/%m/%Y %I:%M:%S %p")
                now = datetime.now()

                # Execute the event only if the current time is within a 10-second range of the start time
                if start_time <= now < start_time + timedelta(seconds=10):
                    found_event = event
                    break

        if found_event is not None:
            input_name = found_event.get("Title").replace(" ", "%20")
            url = f"http://127.0.0.1:8088/api/?Function=CutDirect&Input={input_name}"
            response = requests.get(url)

            print(f"Event executed, response: {response.text}")
        else:
            print(f'No event with title "{event_title}" found in the XML file or not time yet.')

    time.sleep(1)  # Wait for 1 second before checking for events again.


2. Random video
The scripts from here onwards are based on posts I've seen in forums, combined with things I personally would like to be able to do. This script searches a folder for an mp4 file, and once found, it selects a file randomly and adds it to vMix. The default folder is C:\spots, but of course, this can be changed. It's worth mentioning that it can be enriched with additional commands as needed. I won't lie... I don't know how to make the changes myself, but I will ask AI to do it for me.
Code:

import os
import random
import requests
import xml.etree.ElementTree as ET

def get_random_mp4_file(folder_path):
    mp4_files = [f for f in os.listdir(folder_path) if f.endswith('.mp4')]

    for _ in range(len(mp4_files)):
        random_file = random.choice(mp4_files)
        if not is_title_in_api_response(random_file):
            return random_file

    return None

def is_title_in_api_response(title):
    api_url = 'http://127.0.0.1:8088/API'
    response = requests.get(api_url)
    if response.status_code == 200:
        root = ET.fromstring(response.content)
        for elem in root.findall('.//*[@title]'):
            if elem.get('title') == title:
                return True
    return False

def send_request(video_path):
    url = f'http://127.0.0.1:8088/api/?Function=AddInput&Value=Video|{video_path}'
    response = requests.get(url)
    if response.status_code == 200:
        print('Success!')
        print(response.text)
    else:
        print('An error occurred. Status code:', response.status_code)

folder_path = 'c:\\spots'
random_video = get_random_mp4_file(folder_path)

if random_video:
    video_path = os.path.join(folder_path, random_video)
    print(f'Selected random video: {video_path}')
    send_request(video_path)
else:
    print('No suitable MP4 file found in the folder.')

3. Streaming
This script, when executed, checks the vMix API XML for the streaming status every 1 minute. If it sees that stream 1 or 2 is not running, it tries to restart it.
Code:

import requests
import time
import xml.etree.ElementTree as ET

API_URL = "http://127.0.0.1:8088/api/"
CHECK_INTERVAL = 60  # Check for status in intervals

def get_streaming_status():
    response = requests.get(API_URL)
    xml_data = response.content
    root = ET.fromstring(xml_data)
    streaming = root.find('streaming')
    channel1 = streaming.get('channel1') == 'True'
    channel2 = streaming.get('channel2') == 'True'
    return channel1, channel2

def stop_streaming(value):
    requests.get(API_URL, params={"Function": "StopStreaming", "Value": value})

def start_streaming(value):
    requests.get(API_URL, params={"Function": "StartStreaming", "Value": value})

while True:
    channel1_status, channel2_status = get_streaming_status()

    if not channel1_status:
        print("Stream1 stopped. Stream1 Restarted...")
        stop_streaming(0)
        time.sleep(2)
        start_streaming(0)

    if not channel2_status:
        print("Stream2 stopped. Stream2 Restarted...")
        stop_streaming(1)
        time.sleep(2)
        start_streaming(1)

    time.sleep(CHECK_INTERVAL)

4. Overlay script on time
I asked AI to create this script for me with the purpose of being able to play a GT title at a specific time during the day, with a duration that I define and on the overlay channel I want it to play. When executed, it requests the relevant information to run. It can also work with regular inputs.

Code:

import time
import requests
from datetime import datetime, timedelta

def send_http_request(overlay, input_name, action):
    url = f"http://127.0.0.1:8088/api/?Function=OverlayInput{overlay}{action}&Input={input_name}"
    response = requests.get(url)
    print(f"Event executed, response: {response.text}")

# Asks from user to enter details
gt_name = input("Enter name: ")
overlay_channel = input("Enter overlay channel number (1-4): ")

while int(overlay_channel) not in [1, 2, 3, 4]:
    print("No valid overlay number. It has to be 1, 2, 3, ή 4.")
    overlay_channel = input("Enter overlay channel (1-4): ")

event_time_str = input("Enter time for the event (HH:MM:SS): ")
event_time = datetime.strptime(event_time_str, "%H:%M:%S")

event_duration_str = input("Enter duration for event minutes:seconds (MM:SS): ")
event_duration = datetime.strptime(event_duration_str, "%M:%S")
event_duration_seconds = event_duration.minute * 60 + event_duration.second

while event_duration_seconds < 1 or event_duration_seconds > 18000:
    print("No valid Duration.")
    event_duration_str = input("Enter duration for the event minutes:seconds (MM:SS): ")
    event_duration = datetime.strptime(event_duration_str, "%M:%S")
    event_duration_seconds = event_duration.minute * 60 + event_duration.second

input_name = gt_name.replace(" ", "%20")

def send_http_request(overlay, input_name, action):
    url = f"http://127.0.0.1:8088/api/?Function=OverlayInput{overlay}{action}&Input={input_name}"
    response = requests.get(url)
    print(f"Event executed ({action}), response: {response.text}")

# Executes the event when time comes
while True:
    now = datetime.now().time()
    if now >= event_time.time():
        send_http_request(overlay_channel, input_name, "In")
        time.sleep(event_duration_seconds)
        next_event_time = datetime.now() + timedelta(seconds=event_duration_seconds)
        print(f"Overlay channel is off {next_event_time.time()}")
        send_http_request(overlay_channel, input_name, "Out")
        break
    else:
        time.sleep(1)  # wait for 1 second before check again 
        

Guide to install python in your pc to be able to run python scripts
Please follow this guide to download and install Python on Windows so that you can execute .py scripts:

1. Go to the official Python website: https://www.python.org/

2. Hover over the "Downloads" tab at the top of the page and click on "Windows" in the dropdown menu.

3. On the Windows download page, click on the latest Python release (e.g., Python 3.10.x). This will take you to the release page.

4. Scroll down to the "Files" section and download the appropriate installer for your system. For most users, the "Windows Installer (64-bit)" will be suitable. If you are using a 32-bit version of Windows, choose the "Windows Installer (32-bit)".

5. Once the installer has been downloaded, locate the file in your Downloads folder and double-click on it to run the installer.

6. In the installer window, make sure to check the box next to "Add Python to PATH" at the bottom of the window. This will make it easier to run Python scripts from the command prompt.

7. Click on "Install Now" to start the installation process. The installer will copy the necessary files to your computer and set up Python.

8. Once the installation is complete, you can close the installer window.

9. To verify that Python was installed correctly, open the Command Prompt by pressing the Windows key, typing "cmd" and hitting Enter.

10. In the Command Prompt, type "python --version" and press Enter. You should see the Python version you just installed displayed in the output (e.g., Python 3.10.x).

Now you have successfully installed Python on your Windows computer and can execute .py scripts. To run a script, navigate to the folder containing the script using the Command Prompt (use the "cd" command followed by the folder path), then type "python script_name.py" and press Enter. Replace "script_name.py" with the name of the script you want to execute.
Or you can make directly double click on your *.py file and it will run.

For some of the scripts, you may need to install additional libraries, such as the Python requests library, using the command "pip install requests".



To install the requests library, follow these steps:

1. First, make sure you have Python and pip (the package installer for Python) installed on your computer. If you haven't installed Python yet, please refer to the previous guide on downloading and installing Python on Windows.

2. Open the Command Prompt by pressing the Windows key, typing "cmd" and hitting Enter.

3. In the Command Prompt, type the following command and press Enter:

```
pip install requests
```

This command will download and install the requests library.

4. Once the installation is complete, you should see a message indicating that the library was successfully installed.

Now you have the requests library installed, and you can use it in your Python scripts that require it. To import the library in your script, add the following line at the beginning of your script:

```python
import requests
```

This will make the requests library available for use in your script.
That's it for now.
I would like to thank all the people who selflessly help in the forum. I'd like to emphasize that I am not a programmer and everything I do is based on many trials and experimentation. Before using anything in a real video production, make sure everything works as you desire.Let me know your thoughts or anything else you want to share. Take care. Happy Easter and Good Resurrection to all of you, with health and love.
thanks 1 user thanked nikosman88 for this useful post.
Rayza on 5/10/2023(UTC)
Rayza  
#2 Posted : Thursday, May 11, 2023 4:40:32 AM(UTC)
Rayza

Rank: Newbie

Groups: Registered
Joined: 3/6/2023(UTC)
Posts: 4
Nigeria

Thanks: 1 times
Originally Posted by: nikosman88 Go to Quoted Post
Dear friends, good evening. As I have written before, I use vscheduler to create a 24-hour stream. Since 237dominique has made the application's code available, I tried to find a way to improve/change some things I wanted. In this regard, since I have no idea about programming, I thought of trying ChatGPT. You can find program and code here https://www.dropbox.com/...cheduler%202023.zip?dl=0
With the help of ChatGPT, I made some changes to the program:
1. Now when adding an event, the fade is preset to 0. I did this because when it is at 500, sometimes it abruptly cuts off the previous video and looks bad.

2. I changed the code that shuffles the events we select from the list. With the previous code, if we have 5 events on the list and shuffle them, the 5th one always goes to the 4th place and not higher.

3. I tried very hard and experimented a lot to find a way to make the program recognize the videolists of vmix directly. No matter how I tried, I failed. So, as you will read below, I thought of a new (new to me at least) approach to make this possible.

4. I created an extra program, the xml editor, which makes bulk changes to the lists of xml files generated by the program. This is still in an early version, so I won't upload it for now. These are the basics I did. Now, regarding how the program can recognize and play videolists from vmix... Since I couldn't achieve it directly within the program, I got disappointed and gave up. Until one day I needed a simple program that would input the time, minutes, and seconds and calculate what the new time would be. I asked ChatGPT, and it suggested/made a python script. I was culturally shocked that it told me exactly how to install python, run the script, and generally how quickly it implemented it, without needing even half a line of code.
When I asked it to create some vb.net scripts for vmix, it struggled a lot because, as I understood, while it gave me correct commands that actually exist in vb.net, the implementation of them by vmix has some limitations that ChatGPT, of course, does not know. After it made the first python script for me, I thought to ask if python supports xml searching, timers, and http requests.
And that's how a new (for me, at least) wonderful world opened up in front of me. So, I started a few days ago and have been creating Python scripts for vmix, which I will share, in case they prove useful to some other forum member or to get ideas and improvements, etc. What I see is that when the python script runs, it has zero impact on the CPU/GPU (at least for the simple ones I tested), so we are doing well in that regard too. I will start with the scripts.
1. Vmixvideolists
This specific script works with the vmanager program to play videolists from vmix. The usage is as follows:

We have our list in vmix that we want to play. We change the List name to anything we want, for example, Hellolist. Now we need to set the time it will play. We go to vmanager and create a new list and save it. The script searches in c:\vmixlists\, and this is something that can be changed within the script. So, we give our list a name in vmanager and save it. Thus, an XML file with the name we provided will be created inside the c:\vmixlists\ folder.

Now we need to add the time and date our list will play from vmix. We go to Events -> Add Event -> Operator mode, and we change the operator mode name to the name we gave our list in vmix, set the duration, and the time/date we want it to play. Then we press push to send the event to vcontroller. Then we save the list in vmanager again so the XML file gets updated with the new time.

Next, we run our .py script, and it asks us to enter the name of our XML file. For example, Hello.xml. After that, it asks us to enter the name we want to search for. Here we write Hellolist and press enter. That's it. We let the script run, and when the specified time comes (which we set in vmanager when creating the list there), it will play the vmix list. Note that each time we change the times in vmanager, we save to update the time in the script. If we change the list name in vmanager (change the XML file, that is), we run the script from the beginning with the new name of the XML file. I should mention here that since I am in Greece, ChatGPT added the following line to my code for the XML file to work: start_time_str = start_time_str.replace("πμ", "AM").replace("μμ", "PM"), which is for Greek regional settings. For you, it might be necessary to remove it or add the appropriate line for your own country's regional settings.

Code:

import os
import xml.etree.ElementTree as ET
from datetime import datetime, timedelta
import time
import requests

xml_folder = "c:/vmixlists/"
xml_filename = input("Enter the XML filename: ")

# Read multiple event titles separated by commas
event_titles_input = input("Enter the Event Titles to search for (separated by commas): ")
event_titles = [title.strip() for title in event_titles_input.split(",")]

xml_file_path = os.path.join(xml_folder, xml_filename)

while True:
    tree = ET.parse(xml_file_path)
    root = tree.getroot()

    for event_title in event_titles:
        found_event = None

        for event in root.iter("Event"):
            if event.get("Title") == event_title:
                start_time_str = event.get("Start")
                start_time_str = start_time_str.replace("πμ", "AM").replace("μμ", "PM")
                start_time = datetime.strptime(start_time_str, "%d/%m/%Y %I:%M:%S %p")
                now = datetime.now()

                # Execute the event only if the current time is within a 10-second range of the start time
                if start_time <= now < start_time + timedelta(seconds=10):
                    found_event = event
                    break

        if found_event is not None:
            input_name = found_event.get("Title").replace(" ", "%20")
            url = f"http://127.0.0.1:8088/api/?Function=CutDirect&Input={input_name}"
            response = requests.get(url)

            print(f"Event executed, response: {response.text}")
        else:
            print(f'No event with title "{event_title}" found in the XML file or not time yet.')

    time.sleep(1)  # Wait for 1 second before checking for events again.


2. Random video
The scripts from here onwards are based on posts I've seen in forums, combined with things I personally would like to be able to do. This script searches a folder for an mp4 file, and once found, it selects a file randomly and adds it to vMix. The default folder is C:\spots, but of course, this can be changed. It's worth mentioning that it can be enriched with additional commands as needed. I won't lie... I don't know how to make the changes myself, but I will ask AI to do it for me.
Code:

import os
import random
import requests
import xml.etree.ElementTree as ET

def get_random_mp4_file(folder_path):
    mp4_files = [f for f in os.listdir(folder_path) if f.endswith('.mp4')]

    for _ in range(len(mp4_files)):
        random_file = random.choice(mp4_files)
        if not is_title_in_api_response(random_file):
            return random_file

    return None

def is_title_in_api_response(title):
    api_url = 'http://127.0.0.1:8088/API'
    response = requests.get(api_url)
    if response.status_code == 200:
        root = ET.fromstring(response.content)
        for elem in root.findall('.//*[@title]'):
            if elem.get('title') == title:
                return True
    return False

def send_request(video_path):
    url = f'http://127.0.0.1:8088/api/?Function=AddInput&Value=Video|{video_path}'
    response = requests.get(url)
    if response.status_code == 200:
        print('Success!')
        print(response.text)
    else:
        print('An error occurred. Status code:', response.status_code)

folder_path = 'c:\\spots'
random_video = get_random_mp4_file(folder_path)

if random_video:
    video_path = os.path.join(folder_path, random_video)
    print(f'Selected random video: {video_path}')
    send_request(video_path)
else:
    print('No suitable MP4 file found in the folder.')

3. Streaming
This script, when executed, checks the vMix API XML for the streaming status every 1 minute. If it sees that stream 1 or 2 is not running, it tries to restart it.
Code:

import requests
import time
import xml.etree.ElementTree as ET

API_URL = "http://127.0.0.1:8088/api/"
CHECK_INTERVAL = 60  # Check for status in intervals

def get_streaming_status():
    response = requests.get(API_URL)
    xml_data = response.content
    root = ET.fromstring(xml_data)
    streaming = root.find('streaming')
    channel1 = streaming.get('channel1') == 'True'
    channel2 = streaming.get('channel2') == 'True'
    return channel1, channel2

def stop_streaming(value):
    requests.get(API_URL, params={"Function": "StopStreaming", "Value": value})

def start_streaming(value):
    requests.get(API_URL, params={"Function": "StartStreaming", "Value": value})

while True:
    channel1_status, channel2_status = get_streaming_status()

    if not channel1_status:
        print("Stream1 stopped. Stream1 Restarted...")
        stop_streaming(0)
        time.sleep(2)
        start_streaming(0)

    if not channel2_status:
        print("Stream2 stopped. Stream2 Restarted...")
        stop_streaming(1)
        time.sleep(2)
        start_streaming(1)

    time.sleep(CHECK_INTERVAL)

4. Overlay script on time
I asked AI to create this script for me with the purpose of being able to play a GT title at a specific time during the day, with a duration that I define and on the overlay channel I want it to play. When executed, it requests the relevant information to run. It can also work with regular inputs.

Code:

import time
import requests
from datetime import datetime, timedelta

def send_http_request(overlay, input_name, action):
    url = f"http://127.0.0.1:8088/api/?Function=OverlayInput{overlay}{action}&Input={input_name}"
    response = requests.get(url)
    print(f"Event executed, response: {response.text}")

# Asks from user to enter details
gt_name = input("Enter name: ")
overlay_channel = input("Enter overlay channel number (1-4): ")

while int(overlay_channel) not in [1, 2, 3, 4]:
    print("No valid overlay number. It has to be 1, 2, 3, ή 4.")
    overlay_channel = input("Enter overlay channel (1-4): ")

event_time_str = input("Enter time for the event (HH:MM:SS): ")
event_time = datetime.strptime(event_time_str, "%H:%M:%S")

event_duration_str = input("Enter duration for event minutes:seconds (MM:SS): ")
event_duration = datetime.strptime(event_duration_str, "%M:%S")
event_duration_seconds = event_duration.minute * 60 + event_duration.second

while event_duration_seconds < 1 or event_duration_seconds > 18000:
    print("No valid Duration.")
    event_duration_str = input("Enter duration for the event minutes:seconds (MM:SS): ")
    event_duration = datetime.strptime(event_duration_str, "%M:%S")
    event_duration_seconds = event_duration.minute * 60 + event_duration.second

input_name = gt_name.replace(" ", "%20")

def send_http_request(overlay, input_name, action):
    url = f"http://127.0.0.1:8088/api/?Function=OverlayInput{overlay}{action}&Input={input_name}"
    response = requests.get(url)
    print(f"Event executed ({action}), response: {response.text}")

# Executes the event when time comes
while True:
    now = datetime.now().time()
    if now >= event_time.time():
        send_http_request(overlay_channel, input_name, "In")
        time.sleep(event_duration_seconds)
        next_event_time = datetime.now() + timedelta(seconds=event_duration_seconds)
        print(f"Overlay channel is off {next_event_time.time()}")
        send_http_request(overlay_channel, input_name, "Out")
        break
    else:
        time.sleep(1)  # wait for 1 second before check again 
        

Guide to install python in your pc to be able to run python scripts
Please follow this guide to download and install Python on Windows so that you can execute .py scripts:

1. Go to the official Python website: https://www.python.org/

2. Hover over the "Downloads" tab at the top of the page and click on "Windows" in the dropdown menu.

3. On the Windows download page, click on the latest Python release (e.g., Python 3.10.x). This will take you to the release page.

4. Scroll down to the "Files" section and download the appropriate installer for your system. For most users, the "Windows Installer (64-bit)" will be suitable. If you are using a 32-bit version of Windows, choose the "Windows Installer (32-bit)".

5. Once the installer has been downloaded, locate the file in your Downloads folder and double-click on it to run the installer.

6. In the installer window, make sure to check the box next to "Add Python to PATH" at the bottom of the window. This will make it easier to run Python scripts from the command prompt.

7. Click on "Install Now" to start the installation process. The installer will copy the necessary files to your computer and set up Python.

8. Once the installation is complete, you can close the installer window.

9. To verify that Python was installed correctly, open the Command Prompt by pressing the Windows key, typing "cmd" and hitting Enter.

10. In the Command Prompt, type "python --version" and press Enter. You should see the Python version you just installed displayed in the output (e.g., Python 3.10.x).

Now you have successfully installed Python on your Windows computer and can execute .py scripts. To run a script, navigate to the folder containing the script using the Command Prompt (use the "cd" command followed by the folder path), then type "python script_name.py" and press Enter. Replace "script_name.py" with the name of the script you want to execute.
Or you can make directly double click on your *.py file and it will run.

For some of the scripts, you may need to install additional libraries, such as the Python requests library, using the command "pip install requests".



To install the requests library, follow these steps:

1. First, make sure you have Python and pip (the package installer for Python) installed on your computer. If you haven't installed Python yet, please refer to the previous guide on downloading and installing Python on Windows.

2. Open the Command Prompt by pressing the Windows key, typing "cmd" and hitting Enter.

3. In the Command Prompt, type the following command and press Enter:

```
pip install requests
```

This command will download and install the requests library.

4. Once the installation is complete, you should see a message indicating that the library was successfully installed.

Now you have the requests library installed, and you can use it in your Python scripts that require it. To import the library in your script, add the following line at the beginning of your script:

```python
import requests
```

This will make the requests library available for use in your script.
That's it for now.
I would like to thank all the people who selflessly help in the forum. I'd like to emphasize that I am not a programmer and everything I do is based on many trials and experimentation. Before using anything in a real video production, make sure everything works as you desire.Let me know your thoughts or anything else you want to share. Take care. Happy Easter and Good Resurrection to all of you, with health and love.


Hi, thanks for the work you do. I work for a Satellite TV station in Nigeria and I use Vmix as my playout and Vscheduler for automation.
I have a few questions:

Is there a way to make Vscheduler to have a type of now playing feature where if I schedule a music video to play, I select the lower third to overlay and also in a text box, I type in the information of the music video. e.g Artist: Celine Dion, Song: My heart will go on?

On an alternative, can vscheduler push the now playing information through .csv file into vmix for the lower third to read each time it is triggered? Or can vscheduler run a script that gets the now playing information from vmix api and input it into a selected lower third?
When scheduling an overlay, can there be a multi-time option as in the case of a music lower third that comes at the beginning and the end of a song?
Also, can an overlay be tied to an input? So that if one schedules a video, it automatically triggers the overlay?

On the creation of schedules, is there a possibility of adding a dummy block as an input type especially when one wants to create a placeholder for an event or a video.
When creating and saving a schedule, can there be an option of not to save the schedule with the date.

nikosman88  
#3 Posted : Friday, May 12, 2023 4:27:31 AM(UTC)
nikosman88

Rank: Advanced Member

Groups: Registered
Joined: 12/24/2021(UTC)
Posts: 542
Greece
Location: athens

Thanks: 130 times
Was thanked: 74 time(s) in 70 post(s)
Hi.
Quote:
Also, can an overlay be tied to an input? So that if one schedules a video, it automatically triggers the overlay?

Yes it is possible if the input is inside vmix. You can use a trigger like transition in-->overlay1in so when vscheduler runs this input will do the overlay and a trigger in transitionout-->overlayinput1out so when this input will be off air, to overlay out or do something else. This is the way im doing it for some tv shows i need to take off the channel logo and when this show transition out to bring back channel logo . Other way to do this is to multiview layer in this input what you want
But.. The problem is when the video/input is not allready exist in vmix. Vscheduler will insert the video 5secs before the time it will play. So in this case we cannot tie an overlay in an input if this input doesnt exist in vmix. So in this case maybe something can be done with a script like this https://forums.vmix.com/...or-commercials#post99914 this script writes the title of the active input in a txt file and im also using it to log what it playout from vmix. Maybe with some modifications of course you can do whenever a new video loads in vmix that you need the now playing to combine the command API.Function("SetText", Input:="My input", Value:="My new text line 1%0AMy new text line 2", SelectedName:="myTitle.Text") and then overlay out or change when the video changes. I dont need something like this, so i didnt try it if possible but should be possible
Another way you say from csv file. See this video

The way that this video explain, works very good. I tried it now
Quote:
When scheduling an overlay, can there be a multi-time option as in the case of a music lower third that comes at the beginning and the end of a song?

im not sure i understand what you say here.
Quote:
On the creation of schedules, is there a possibility of adding a dummy block as an input type especially when one wants to create a placeholder for an event or a video.
When creating and saving a schedule, can there be an option of not to save the schedule with the date.

same here. Can you explain better please?
Rayza  
#4 Posted : Friday, May 12, 2023 4:55:28 AM(UTC)
Rayza

Rank: Newbie

Groups: Registered
Joined: 3/6/2023(UTC)
Posts: 4
Nigeria

Thanks: 1 times
Originally Posted by: nikosman88 Go to Quoted Post
Hi.
Quote:
Also, can an overlay be tied to an input? So that if one schedules a video, it automatically triggers the overlay?

Yes it is possible if the input is inside vmix. You can use a trigger like transition in-->overlay1in so when vscheduler runs this input will do the overlay and a trigger in transitionout-->overlayinput1out so when this input will be off air, to overlay out or do something else. This is the way im doing it for some tv shows i need to take off the channel logo and when this show transition out to bring back channel logo . Other way to do this is to multiview layer in this input what you want
But.. The problem is when the video/input is not allready exist in vmix. Vscheduler will insert the video 5secs before the time it will play. So in this case we cannot tie an overlay in an input if this input doesnt exist in vmix. So in this case maybe something can be done with a script like this https://forums.vmix.com/...or-commercials#post99914 this script writes the title of the active input in a txt file and im also using it to log what it playout from vmix. Maybe with some modifications of course you can do whenever a new video loads in vmix that you need the now playing to combine the command API.Function("SetText", Input:="My input", Value:="My new text line 1%0AMy new text line 2", SelectedName:="myTitle.Text") and then overlay out or change when the video changes. I dont need something like this, so i didnt try it if possible but should be possible
Another way you say from csv file. See this video

Quote:
When scheduling an overlay, can there be a multi-time option as in the case of a music lower third that comes at the beginning and the end of a song?

im not sure i understand what you say here.
Quote:
On the creation of schedules, is there a possibility of adding a dummy block as an input type especially when one wants to create a placeholder for an event or a video.
When creating and saving a schedule, can there be an option of not to save the schedule with the date.

same here. Can you explain better please?



Hi, thanks for your response.
So, for this:
Quote:
On the creation of schedules, is there a possibility of adding a dummy block as an input type especially when one wants to create a placeholder for an event or a video.
When creating and saving a schedule, can there be an option of not to save the schedule with the date.

I meant, when building a schedule for a particular day, e.g lets say today is Friday and I'm building a schedule that will play on sunday and some media files that are ready to be played aren't available yet or are still being edited, can we have an input called dummy block(currently we have video, audio, image, slideshow etc.). So, basically, a dummy block acts as a place holder until the said media files are ready. We can set the time length.

Quote:
When scheduling an overlay, can there be a multi-time option as in the case of a music lower third that comes at the beginning and the end of a song?

What I meant here is in the case of playing a music and we wanted the overlay to come on at the beginning and the end of the song, is there possibility of having a multiple time option or a repeat function?
Example: if the lower third/overlay comes in at 4:00pm, we set the repeat overlay to be at 4:30pm.

In the case where we can't tie an overlay to a video from vscheduler, can this be an option:
1) make vscheduler have metadata option where we enter the metadata of a video or an audio.
2) vscheduler picks the metadata e.g artist name and song name then writes it to an xml or csv file.
3) inside vmix, we have a lower third that picks the information from the xml or csv file. Whenever vscheduler overlays the lower third, the lower third displays the information from the xml or csv.
4) so, each time vscheduler pushes a video or audio, it removes the old information and replaces it with the new one.

Another question I wanted to ask is:
Is there a way to override the chronological sequence in vscheduler?
If I add two videos at 9:00am. Lets say one is 4 minutes, the next video would come in at 9:04am. Is there a way to alter the times of the videos so that I can set the exact time I want the video to play. E.g instead of the second video coming in at 9:04am, I can set it to come in at 9:15am?

Thanks for your time. I do appreciate
nikosman88  
#5 Posted : Saturday, May 13, 2023 5:09:39 AM(UTC)
nikosman88

Rank: Advanced Member

Groups: Registered
Joined: 12/24/2021(UTC)
Posts: 542
Greece
Location: athens

Thanks: 130 times
Was thanked: 74 time(s) in 70 post(s)
Quote:
I meant, when building a schedule for a particular day, e.g lets say today is Friday and I'm building a schedule that will play on sunday and some media files that are ready to be played aren't available yet or are still being edited, can we have an input called dummy block(currently we have video, audio, image, slideshow etc.). So, basically, a dummy block acts as a place holder until the said media files are ready. We can set the time length.

Hi. So you need something that will exist as record in vmanager in order to be able to make your playlist and change it,when you have the real file. For this thing im using Events-->Add Event-->Operator mode. This mode is simply manual mode, means that when time comes vscheduler will set free vmix to do anything you want. So if i want to do the thing you say, i add an operator mode event, name it as i need in order to find it later, i give the duration i need. Then i change it with the real video when i have it. So i think no need of adding "dummy block" as we allready have this function
Quote:

What I meant here is in the case of playing a music and we wanted the overlay to come on at the beginning and the end of the song, is there possibility of having a multiple time option or a repeat function?
Example: if the lower third/overlay comes in at 4:00pm, we set the repeat overlay to be at 4:30pm.

You need to overlay in specific time or for example every 30 minutes? For every x time i have a show that i overlay some graphics every 7 minutes. So what i do for this
1.I add the video of the show as video in vmix and i rename it for example "Show1". Then i add also my graphics and i make a script that runs inside vmix
This script
Code:

Do While True
 sleep (60000)
 API.Function("OverlayInput2In", Input:="x1")
 sleep (9000)
 API.Function("OverlayInput2In", Input:="x2")
 sleep (9000)
 API.Function("OverlayInput2In", Input:="x3")
 sleep (9000)
 API.Function("OverlayInput2Out")
 sleep (360000)
loop

This script will overlay 3 graphics at 1st minute of the video, for 9 seconds every graphic and then after 7 minutes about, it will loop again

2.In my input "Show1" i put a trigger -->In transition in-->Script start-->name of the script so the script will start run when video comes in and a trigger in transition out-->Script Stop-->name of the script in order to stop running when the show is over
3.In Vmanager i go to Events-->Add Event-->Input and i set as name Show1 and i give the duration that has and it runs when the time comes
Quote:
Another question I wanted to ask is:
Is there a way to override the chronological sequence in vscheduler?
If I add two videos at 9:00am. Lets say one is 4 minutes, the next video would come in at 9:04am. Is there a way to alter the times of the videos so that I can set the exact time I want the video to play. E.g instead of the second video coming in at 9:04am, I can set it to come in at 9:15am?

Ok so you need somehow to break the continoous time for the events and put fixed time and then again continoous? Maybe this is possible at programmatically level to somehow add a stop function and then start count time function again but im sorry im not an expert to do this but i have to suggest 2 workarounds
1. Let`s say you put Video1 that it is 4 minutes to start 09:00am and you want the next video at 9:15am.
a. Add the first video and it will end at 09.04am. Then in the same list go to Events-->Add Event-->Operator mode. Change the duration of this record in 11 minutes. Now the time in vmanager ends 09:15am. Then go to Events-->Add Event-->video2 and push the list in the vcontroller
b. Now the first video1 will start at 09:00am and after it ends at 09:04am vmix will wait until 09:15am and it will run the video2 when 09:15am arrives
2. The second workaround
Simply open a new instance of vmanager programm. Go to Events-->Add Event-->Video and add your video. Then fix the date/time you want and push it to vcontroller and it will run the time you need
One of these 2 workarounds you can also use to do overlays repeat in specified time. Im using also this, some times.
Quote:

In the case where we can't tie an overlay to a video from vscheduler, can this be an option:
1) make vscheduler have metadata option where we enter the metadata of a video or an audio.
2) vscheduler picks the metadata e.g artist name and song name then writes it to an xml or csv file.
3) inside vmix, we have a lower third that picks the information from the xml or csv file. Whenever vscheduler overlays the lower third, the lower third displays the information from the xml or csv.
4) so, each time vscheduler pushes a video or audio, it removes the old information and replaces it with the new one.

The info we need is allready exist in the xml vmix api. Have you seen the video i quoted you in previous message? I think we dont need to make new files etc, when possible to use datasource. Exactly how, i dont know yet, but i will think of it and if i find something i will tell you.
data1.png (27kb) downloaded 4 time(s).
ok i did one step more. If we put this in datasources
im writing also the code for xml path
Code:
 /vmix/inputs/input[@state='Running'][@type='Video'] 
this code will read the active video that vscheduler sends and it will write it in the title we connect. If we dont want to have the extension we can make the thing that the video in my previous post says. So this succeed. Next step on how to decide when overlay will auto on and then auto off.
If i think something, i will post it
thanks 1 user thanked nikosman88 for this useful post.
jassantos on 10/16/2023(UTC)
Rayza  
#6 Posted : Saturday, May 13, 2023 5:45:15 AM(UTC)
Rayza

Rank: Newbie

Groups: Registered
Joined: 3/6/2023(UTC)
Posts: 4
Nigeria

Thanks: 1 times
Hey, thanks for taking your time to explain this all for me. I do appreciate.
nikosman88  
#7 Posted : Sunday, May 14, 2023 7:32:50 AM(UTC)
nikosman88

Rank: Advanced Member

Groups: Registered
Joined: 12/24/2021(UTC)
Posts: 542
Greece
Location: athens

Thanks: 130 times
Was thanked: 74 time(s) in 70 post(s)
Hi. I made a little more progress for this task. I used as base this script https://forums.vmix.com/...ng-for-Dummies#post71985 from doggy. So let`s say for example we want the title to be overlayed 5 seconds after the video begins to play, keep the overlay for 10 seconds and then overlay out we can use a script like this
Code:

' Checking time left of active input
' and do some stuff at certain time remaining

dim position as string = ""
dim duration as string = ""
dim activeinput as string = ""
dim triggerduration as integer = 2000   'fade duration, could be different than trigger

do while true

   dim xml as string = API.XML()
   dim x as new system.xml.xmldocument
   x.loadxml(xml)

activeinput = (x.SelectSingleNode("//active").InnerText)
duration = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@duration").Value)
position = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@position").Value)

if Double.Parse(position) >= 5000 and Double.Parse(position) <= 6000

  API.Function("OverlayInput1In", Input:="nowplaying-title")
 sleep (10000)
 API.Function("OverlayInput1Out")

end if

sleep(500)
Loop

This script when the position of the active video goes after 5s and before 6s it will do the overlay on/off. If you need to do the overlay repeat for example in 1st minute of the video again, you will add in the script an extra if condition for that point of time. For example for 1 minute later you can do the code
Code:

if Double.Parse(position) >= 5000 and Double.Parse(position) <= 6000

  API.Function("OverlayInput1In", Input:="nowplaying-title")
 sleep (10000)
 API.Function("OverlayInput1Out")

if Double.Parse(position) >= 60000 and Double.Parse(position) <= 61000

  API.Function("OverlayInput1In", Input:="nowplaying-title")
 sleep (10000)
 API.Function("OverlayInput1Out")
the rest code as it is. For 2minutes again or other time do the math on how much you need to set the if Double.Parse(position) >= ... condition
This is for the start of the video. Now let`s say we want to overlay again on/off the title when 15 seconds of the active video remain. We use this script
Code:

' Checking time left of active input
' and do some stuff at certain time remaining

dim position as string = ""
dim duration as string = ""
dim activeinput as string = ""
dim Timeleft as double = 0
dim triggertime as integer = 15000       'set seconds before end
dim triggerduration as integer = 2000   'fade duration, could be different than trigger

do while true

   dim xml as string = API.XML()
   dim x as new system.xml.xmldocument
   x.loadxml(xml)

activeinput = (x.SelectSingleNode("//active").InnerText)
duration = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@duration").Value)
position = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@position").Value)

Timeleft= Double.Parse(duration)-Double.Parse(position)

if Timeleft < triggertime  

 API.Function("OverlayInput1In", Input:="nowplaying-title")
 sleep (10000)
 API.Function("OverlayInput1Out")
 sleep (7000)
end if

sleep(500)
Loop

This script will overlay on when the active video has 15 seconds remaining, it will keep overlay on for 10 seconds and then it will overlay off for the last 5 seconds of active video
I hope i give you an idea on a possible way to achieve what you need
thanks 1 user thanked nikosman88 for this useful post.
jassantos on 10/16/2023(UTC)
Rayza  
#8 Posted : Monday, May 22, 2023 1:16:12 AM(UTC)
Rayza

Rank: Newbie

Groups: Registered
Joined: 3/6/2023(UTC)
Posts: 4
Nigeria

Thanks: 1 times
Thanks my bro. I do appreciate all you do
nikosman88  
#9 Posted : Friday, December 29, 2023 9:43:27 AM(UTC)
nikosman88

Rank: Advanced Member

Groups: Registered
Joined: 12/24/2021(UTC)
Posts: 542
Greece
Location: athens

Thanks: 130 times
Was thanked: 74 time(s) in 70 post(s)
Hello. Finally i have discovered the programm-addon that cancels the majority of my python (my ideas-chatgpt construction) scripts. Combine this programm for time placeholder with the companion vmix module https://forums.vmix.com/...anion-Module#post112069, use your imagination a little and we have the ultimate (at least for my needs) playout system. We can play vmix lists (that in vsheduler we cannot) either by time or triggers for example using the previous name of the video that plays normally in vscheduler. We can start-stop vmix scripts,we can do almost anything that misses from vscheduler.
Vmix companion module by-pass the 30sec limit for the triggers so if we combine it with vscheduler we can do many things. For example if we have a video 1 hour and we want to 25minutes of playing this video to overlay a title for x seconds we can set a trigger that will do this
Because module and vmix work in ms the time (we can do some triggers to transform so big time to ms as creator of the module post) i made a small python script in which we give hours,minutes,seconds it transform them to ms,copies the result to clipboard so we can paste it easily to the companion trigger. To make the code work you have first to install the pyperclip python library by giving the command "pip install pyperclip" as described in 1st post
Code:

import pyperclip

def convert_to_milliseconds(hours, minutes, seconds):
    total_seconds = hours * 3600 + minutes * 60 + seconds
    milliseconds = total_seconds * 1000
    return milliseconds

# Παράδειγμα χρήσης:
hours = int(input("Hours: "))
minutes = int(input("Minutes: "))
seconds = int(input("Seconds: "))

result = convert_to_milliseconds(hours, minutes, seconds)
print(f"This time is {result} milliseconds.")

# Αντιγραφή στο πρόχειρο
pyperclip.copy(str(result))
print("The result has been copied to clipboard.")

# Περιμένουμε το enter πριν κλείσουμε
input("\nPress enter to close the program.")

Also i want to thank the vmix team guys that continue to keep in vmix 27 the same "engine" so programms like vscheduler continue to work ok. Happy new year to everyone with health
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.