OBS 日期时间.毫秒时间脚本 date-and-time.lua

文章目录

    • OBS 日期时间.毫秒时间脚本:
    • 效果

OBS 日期时间.毫秒时间脚本:

obs           = obslua
source_name   = ""last_text     = ""
format_string = ""
activated     = false-- 此函数用于获取精确的毫秒级时间戳,适用于 Linux 系统
local function getMillisTimestamp()local sec, usec = os.time(), os.clock()local millis = math.floor((sec + usec) * 1000)return millis
end-- Function to set the time text
function set_time_text()-- local text = os.date(format_string)-- local date_table = os.date("*t")-- local ms = string.format("%.3f", os.clock()) -- local hour, minute, second = date_table.hour, date_table.min, date_table.sec-- local year, month, day = date_table.year, date_table.month, date_table.day   -- local text = string.format("%s", ms)local date_table = os.date("*t")local hour, minute, second = date_table.hour, date_table.min, date_table.seclocal year, month, day = date_table.year, date_table.month, date_table.day-- 获取毫秒级时间戳local millisTimestamp = getMillisTimestamp()-- 提取毫秒部分local ms = millisTimestamp % 1000-- 格式化时间字符串local text = string.format("%04d-%02d-%02d %02d:%02d:%02d.%03d", year, month, day, hour, minute, second, ms)if text ~= last_text thenlocal source = obs.obs_get_source_by_name(source_name)if source ~= nil thenlocal settings = obs.obs_data_create()obs.obs_data_set_string(settings, "text", text)obs.obs_source_update(source, settings)obs.obs_data_release(settings)obs.obs_source_release(source)endendlast_text = text
endfunction timer_callback()set_time_text()
endfunction activate(activating)if activated == activating thenreturnendactivated = activatingif activating thenset_time_text()obs.timer_add(timer_callback, 1)elseobs.timer_remove(timer_callback)end
end-- Called when a source is activated/deactivated
function activate_signal(cd, activating)local source = obs.calldata_source(cd, "source")if source ~= nil thenlocal name = obs.obs_source_get_name(source)if (name == source_name) thenactivate(activating)endend
endfunction source_activated(cd)activate_signal(cd, true)
endfunction source_deactivated(cd)activate_signal(cd, false)
endfunction reset(pressed)if not pressed thenreturnendactivate(false)local source = obs.obs_get_source_by_name(source_name)if source ~= nil thenlocal active = obs.obs_source_active(source)obs.obs_source_release(source)activate(active)end
end------------------------------------------------------------ A function named script_properties defines the properties that the user
-- can change for the entire script module itself
function script_properties()local props = obs.obs_properties_create()local p = obs.obs_properties_add_list(props, "source", "Text Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING)local sources = obs.obs_enum_sources()if sources ~= nil thenfor _, source in ipairs(sources) dosource_id = obs.obs_source_get_id(source)if source_id == "text_gdiplus" or source_id == "text_ft2_source" thenlocal name = obs.obs_source_get_name(source)obs.obs_property_list_add_string(p, name, name)endendendobs.source_list_release(sources)obs.obs_properties_add_text(props, "format_string", "Format String", obs.OBS_TEXT_DEFAULT)return props
end-- A function named script_description returns the description shown to
-- the user
function script_description()return "Sets a text source to act as a date/time text when the source is active.\n\nMade by Ragowit"
end-- A function named script_update will be called when settings are changed
function script_update(settings)activate(false)source_name = obs.obs_data_get_string(settings, "source")format_string = obs.obs_data_get_string(settings, "format_string")reset(true)
end-- A function named script_defaults will be called to set the default settings
function script_defaults(settings)obs.obs_data_set_default_string(settings, "format_string", "%Y-%m-%d %X")
end-- a function named script_load will be called on startup
function script_load(settings)-- Connect activation/deactivation signal callbacks---- NOTE: These particular script callbacks do not necessarily have to-- be disconnected, as callbacks will automatically destroy themselves-- if the script is unloaded.  So there's no real need to manually-- disconnect callbacks that are intended to last until the script is-- unloaded.local sh = obs.obs_get_signal_handler()obs.signal_handler_connect(sh, "source_activate", source_activated)obs.signal_handler_connect(sh, "source_deactivate", source_deactivated)
end

效果

在这里插入图片描述

********************************* 只要思想不滑坡,办法总比困难多*********************************

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/79905.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

进程和线程(1)

前言: 在计算机中cpu就像一座工厂,这个工厂里面有许多的车间,但是假如工厂的电力有限,一次只能供给一个车间使用,也就是说当一个车间在进行工作的时候,其他车间是不能工作的(单个cpu只能运行一…

入门-C编程基础部分:16、 预处理器

飞书文档https://x509p6c8to.feishu.cn/wiki/DzSJwsGiTiXkeCkyEYUcuXbKnbf C 预处理是编译过程中一个单独的步骤,是一个文本替换工具而已。所有的预处理命令都是以井号(#)开头。 指令描述#define定义宏#ifdef如果宏已经定义,则返…

Ubuntu下安装和卸载MySQL

Ubuntu下安装和卸载MySQL 下面的演示系统版本:Ubuntu 24.04 更新系统软件包 在开始安装之前,建议先更新系统的软件包列表,以确保所有依赖项是最新的。 sudo apt update && sudo apt upgrade -y安装MySQL服务器 Ubuntu的官方软件…

【Python爬虫实战篇】--爬取豆瓣电影信息(静态网页)

网站,:豆瓣电影 Top 250 爬取豆瓣前250电影的信息, F12打开网页控制台,查看网页元素, 发现网页数据直接可以查看到,为静态网页数据,较为简单 目录 1.第一步使用urllib库获取网页 2.第二步使…

【Unity知识点详解】Unity中泛型单例的使用,兼容WebGL

今天来讲下Unity中泛型单例的使用,包含普通单例和继承MonoBehaviour的单例。重点是需要两种泛型单例兼容WebGL平台,话不多说直接开始。 泛型单例的设计目标 作为泛型单例,需要实现以下几个目标: 全局唯一,在程序的整个…

Python进程与线程的深度对比

一、核心概念对比 1. 进程(Process) 操作系统级独立单元:每个进程拥有独立的内存空间(堆、栈、代码段) 资源隔离性:崩溃不影响其他进程 多核并行:可充分利用多核CPU资源 2. 线程&#xff0…

Django 入门指南:构建强大的 Web 应用程序

什么是 Django? Django 是一个开源的高层次 Python Web 框架,旨在快速开发安全且可维护的网站。它通过简化常见的 Web 开发任务,帮助开发者专注于开发应用的核心功能。Django 实现了“快速开发”和“尽量少的重复”的理念,提供了…

ESP-ADF外设子系统深度解析:esp_peripherals组件架构与核心设计(显示输出类外设之IS31FL3216)

目录 ESP-ADF外设子系统深度解析:esp_peripherals组件架构与核心设计(显示输出类外设之IS31FL3216)简介模块概述功能定义架构位置核心特性 IS31FL3216外设分析IS31FL3216外设概述IS31FL3216外设层次架构图 IS31FL3216外设API和数据结构外设层…

【计算机网络 | 第三篇】常见的网络协议(二)

没有看过我写的关于网络协议的第一篇博客可以看【计算机网络 | 第二篇】常见的通信协议(一)-CSDN博客 TCP的三次握手和四次挥手 TCP三次握手 三次握手是TCP协议建立可靠连接的过程,目的是确保客户端和服务端双方的双向通信能力正常&#x…

HAL库(STM32CubeMX)——高级ADC学习、HRTIM(STM32G474RBT6)

系列文章目录 文章目录 系列文章目录前言存在的问题HRTIMcubemx配置前言 对cubemx的ADC的设置进行补充 ADCs_Common_Settings Mode:ADC 模式 Independent mod 独立 ADC 模式,当使用一个 ADC 时是独立模式,使用两个 ADC 时是双模式,在双模式下还有很多细分模式可选 ADC_Se…

Unity接入安卓SDK(3)厘清Gradle的版本

接入过程中,很多人遇到gradle的各种错误,由于对各种gradle版本的概念不甚了了,模模糊糊一顿操作猛如虎,糊弄的能编译通过就万事大吉,下次再遇到又是一脸懵逼。所以我们还是一起先厘清gradle的版本概念。 1 明晰概念 …

python-67-基于plotly的绘图可视化和智能推荐图表

文章目录 1 各种图表的适用场景1.1 面积图1.2 饼图1.3 散点图1.3.1 散点1.3.2 散点加线1.4 折线图1.5 箱线图1.5.1 不同类别的箱线图1.5.2 一个变量的箱线图1.5.3 多个变量的箱线图1.6 小提琴图1.6.1 不同类别的小提琴图1.6.2 一个变量的小提琴图1.7 直方图1.7.1 直方图1.7.2 分…

Spring AI MCP

MCP是什么 MCP是模型上下文协议(Model Context Protocol)的简称,是一个开源协议,由Anthropic(Claude开发公司)开发,旨在让大型语言模型(LLM)能够以标准化的方式连接到外…

c++_csp-j算法 (3)

弗洛伊德算法(Floyd) Floyd算法又称为插点法,是一种利用动态规划的思想寻找给定的加权图中多源点之间最短路径的算法,与Dijkstra算法类似。该算法名称以创始人之一、1978年图灵奖获得者、斯坦福大学计算机科学系教授罗伯特弗洛伊…

QT常见输入类控件及其属性

Line Edit QLineEdit用来表示单行输入框,可以输入一段文本,但是不能换行 核心属性: 核心信号 信号 说明 void cursorPositionChanged(int old,int new) 当鼠标移动时发出此型号,old为先前位置,new为新位置 void …

【k8s系列1】一主两从结构的环境准备

环境准备 虚拟机软件准备及安装,这里就不详细展开了,可以看文章:【一、虚拟机vmware安装】 linux环境准备及下载,下载镜像centOS7.9,以前也有写过这个步骤的文章,可以看:【二、安装centOS】 开始进入正题…

【C++类和数据抽象】类的作用域

目录 一、类的作用域基本概念 1.1 什么是类的作用域 1.2 作用域层次体系 1.3 类作用域的特点 1.4 基本访问规则 二、访问控制三剑客 2.1 public:开放接口 2.2 private:数据封装 2.3 protected:继承通道 2.4 跨作用域访问示例 三…

opencv图片颜色识别,颜色的替换

图片颜色识别 1. RGB颜色空间2. 颜色加法2.1使用numpy对图像进行加法2.2使用opencv加法(cv2.add) 3 颜色加权加法(cv2.addWeighted())4. HSV颜色空间5. 制作掩膜4. 与运算(cv2.bitwise_and)5.颜色的替换7 R…

ADC数据不稳定的解决方案

问题如图: 解决方案:上图第一个通道后来接入GND,就稳定了 上图第一个通道后来接入VCC,就稳定了

Spark(18)Yarn-概述

Hadoop三大核心组件:HDFS、MapReduce和YARN 一)Yarn的概念 YARN(Yet Another Resource Negotiator,另一种资源协调者)是一个通用资源管理系统和调度平台,可为上层应用提供统一的资源管理和调度。它的引入为集群在利用率,资源统一管…