Resource icon

Streamlink source 0.1


New Member
HeyyItsBran submitted a new resource:

Streamlink source - Connects Streamlink to a media source

Quickly and easily display a Twitch or Youtube stream on your own stream, such as for background music or reaction videos

Requires Streamlink to be installed and set up on your system - Please note however this script is an independent project with no affiliation to the Streamlink dev team

Released under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International...

Read more about this resource...


New Member
Well, this script didn't work for a Mac. So I modified it to be cross-platform and separate the quality from the URL.. The default URL was taken down by the copyright hunters. So I changed it to another music twitch.

No instructions were given on how to use the script... So here is some:

You need to first have OBS setup with Python support. should help with that.

If you want to do multiple streams, you need to have the script saved multiple times.

To use, create a new "Media Source" in a scene. Name it something, and save it. Then, under the Tools menu bar, select scripts. Then select, or whatever you save the script as. It will close the window, and then you will just need to open the scripts again. Fill out the fields, and select the media source that you created. Then hit the "Save and reload" button. It may take a few seconds before the source shows, depending on where you are streaming from.

# Original Script by HeyyItsBran - Refactored and modified by jaminmc.
import signal
import subprocess
import os
import obspython as obs
import platform
import shutil

def get_streamlink_path():
    streamlink_executable = "streamlink" + platform.system().lower()
    path_from_shutil = shutil.which(streamlink_executable)

    if path_from_shutil is not None:
        return path_from_shutil

    # Fallback to common installation paths
    common_paths = [
        "/usr/local/bin/streamlink",  # Common path on macOS and Linux
        "/usr/bin/streamlink",  # Another common path on Linux
        "C:\\Program Files (x86)\\Streamlink\\bin\\streamlink.exe",  # Common path on Windows
        "/opt/homebrew/bin/streamlink",  # Homebrew path on macOS

    for path in common_paths:
        if os.path.exists(path):
            return path

    return None

def script_description():
    return '<h1>Streamlink source</h1><b>Connects Streamlink to a media source.</b><br /><br /><a href="">Get Streamlink</a>'

def script_properties():
    props = obs.obs_properties_create()
    obs.obs_properties_add_text(props, "url", "Stream URL", obs.OBS_TEXT_DEFAULT)

    # Dropdown menu for quality settings
    quality_prop = obs.obs_properties_add_list(
        "Quality Settings",
    quality_values = ["best", "worst", "720p", "480p", "360p"]
    for value in quality_values:
        obs.obs_property_list_add_string(quality_prop, value, value)

        props, "port", "Output Port (1024-65535)", 1024, 65535, 1
        props, "args", "Custom arguments (optional)", obs.OBS_TEXT_DEFAULT

    sourcesList = obs.obs_properties_add_list(
        "Media Source",
    sources = obs.obs_enum_sources()

    if sources is not None:
        for source in sources:
            source_id = obs.obs_source_get_unversioned_id(source)
            if source_id == "ffmpeg_source":
                name = obs.obs_source_get_name(source)
                obs.obs_property_list_add_string(sourcesList, name, name)


    obs.obs_properties_add_button(props, "save", "Save and reload", save)
    return props

def script_update(settings):
    global source_name
    source_name = obs.obs_data_get_string(settings, "source")

def script_defaults(settings):
    obs.obs_data_set_default_string(settings, "url", "")
    obs.obs_data_set_default_string(settings, "quality", "best")
    obs.obs_data_set_default_int(settings, "port", 50495)
    obs.obs_data_set_default_string(settings, "args", "--twitch-disable-ads")

def script_load(settings):
    global daemon
    global gblSettings
    gblSettings = settings

    streamlink_path = get_streamlink_path()

    if streamlink_path is None:
        print("[] Streamlink executable not found.")

    url = obs.obs_data_get_string(settings, "url")
    quality = obs.obs_data_get_string(settings, "quality")
    port = str(obs.obs_data_get_int(settings, "port"))
    args = obs.obs_data_get_string(settings, "args")

    # Construct the streamlink command
    streamlink_cmd = [

    # Add custom arguments if provided
    if args.strip():

    print("Executing Streamlink command:", streamlink_cmd)

        daemon = subprocess.Popen(
            streamlink_cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
            "[] Streamlink process started in the background."
    except Exception as e:
        print("[] Error starting Streamlink process:", str(e))

    srcSettings = obs.obs_data_create()
    obs.obs_data_set_bool(srcSettings, "is_local_file", False)
    obs.obs_data_set_bool(srcSettings, "restart_on_activate", True)
    obs.obs_data_set_int(srcSettings, "buffering_mb", 4)
    obs.obs_data_set_string(srcSettings, "input", "" + port)
    obs.obs_data_set_string(srcSettings, "input_format", "")
    obs.obs_data_set_int(srcSettings, "reconnect_delay_sec", 10)
    obs.obs_data_set_bool(srcSettings, "hw_decode", True)
    obs.obs_data_set_bool(srcSettings, "clear_on_media_end", True)
    obs.obs_data_set_bool(srcSettings, "close_when_inactive", False)
    obs.obs_data_set_int(srcSettings, "color_range", 0)
    obs.obs_data_set_bool(srcSettings, "linear_alpha", False)
    obs.obs_data_set_bool(srcSettings, "seekable", False)
        obs.obs_get_source_by_name(obs.obs_data_get_string(settings, "source")),

def script_unload():
    os.kill(, signal.SIGKILL)
    subprocess.Popen(["pkill", "streamlink" + platform.system().lower()])

def save(prop, btn):


New Member
After trying it on Windows, I needed to add another common path for 64bit streamlink

    common_paths = [
        "/usr/local/bin/streamlink",  # Common path on macOS and Linux
        "/usr/bin/streamlink",  # Another common path on Linux
        "C:\\Program Files\\Streamlink\\bin\\streamlink.exe",  # Common path on Windows
        "C:\\Program Files (x86)\\Streamlink\\bin\\streamlink.exe",  # Common path on Windows
        "/opt/homebrew/bin/streamlink",  # Homebrew path on macOS


    2.2 KB · Views: 10