rename the file lol
This commit is contained in:
parent
420b59f982
commit
0416801260
1 changed files with 0 additions and 0 deletions
97
OBSReplay.lua
Executable file
97
OBSReplay.lua
Executable file
|
@ -0,0 +1,97 @@
|
|||
local output_path = obslua.obs_frontend_get_current_record_output_path()
|
||||
local output_path_prop_key = "output_path"
|
||||
local remux_to_mp4_prop_key = "remux_to_mp4"
|
||||
local ffmpeg_path_prop_key = "ffmpeg_path"
|
||||
|
||||
local REPLAY_EVENT = 0
|
||||
local RECORDING_EVENT = 1
|
||||
local SCREENSHOT_EVENT = 2
|
||||
local remux_to_mp4 = false
|
||||
local ffmpeg_path = "ffmpeg"
|
||||
|
||||
function script_description()
|
||||
return [[
|
||||
<h2>OBSReplay</h2>
|
||||
<p>Moves recordings, replays, and screenshots to a folder named after the current scene.</p>
|
||||
]]
|
||||
end
|
||||
|
||||
function script_load()
|
||||
obslua.obs_frontend_add_event_callback(obs_frontend_callback)
|
||||
end
|
||||
|
||||
function obs_frontend_callback(callback, _private_data)
|
||||
if callback == obslua.OBS_FRONTEND_EVENT_REPLAY_BUFFER_SAVED then
|
||||
save(REPLAY_EVENT)
|
||||
elseif callback == obslua.OBS_FRONTEND_EVENT_RECORDING_STOPPED then
|
||||
save(RECORDING_EVENT)
|
||||
elseif callback == obslua.OBS_FRONTEND_EVENT_SCREENSHOT_TAKEN then
|
||||
save(SCREENSHOT_EVENT)
|
||||
end
|
||||
end
|
||||
|
||||
function script_properties()
|
||||
local prop = obslua.obs_properties_create()
|
||||
obslua.obs_properties_add_path(prop, output_path_prop_key, "Output path:", obslua.OBS_PATH_DIRECTORY, nil, nil)
|
||||
obslua.obs_properties_add_path(prop, ffmpeg_path_prop_key, "FFmpeg Path:", obslua.OBS_PATH_FILE, nil, nil)
|
||||
obslua.obs_properties_add_bool(prop, remux_to_mp4_prop_key, "Remux to MP4")
|
||||
return prop
|
||||
end
|
||||
|
||||
function script_update(settings)
|
||||
output_path = obslua.obs_data_get_string(settings, output_path_prop_key)
|
||||
remux_to_mp4 = obslua.obs_data_get_bool(settings, remux_to_mp4_prop_key)
|
||||
ffmpeg_path = obslua.obs_data_get_string(settings, ffmpeg_path_prop_key)
|
||||
if ffmpeg_path == "" then ffmpeg_path = "ffmpeg" end
|
||||
print("Updated output path:", output_path)
|
||||
print("Remux to MP4:", remux_to_mp4)
|
||||
print("FFmpeg Path:", ffmpeg_path)
|
||||
end
|
||||
|
||||
function script_defaults(settings)
|
||||
obslua.obs_data_set_default_string(settings, output_path_prop_key, output_path)
|
||||
obslua.obs_data_set_default_bool(settings, remux_to_mp4_prop_key, false)
|
||||
obslua.obs_data_set_default_string(settings, ffmpeg_path_prop_key, "ffmpeg")
|
||||
end
|
||||
|
||||
function save(event)
|
||||
local latest_file_path = (event == REPLAY_EVENT and obslua.obs_frontend_get_last_replay())
|
||||
or (event == RECORDING_EVENT and obslua.obs_frontend_get_last_recording())
|
||||
or (event == SCREENSHOT_EVENT and obslua.obs_frontend_get_last_screenshot())
|
||||
|
||||
if latest_file_path and latest_file_path ~= "" then
|
||||
local current_scene_name = get_current_scene_name()
|
||||
local scene_folder_path = output_path .. "/" .. current_scene_name
|
||||
|
||||
if package.config:sub(1, 1) == "\\" then
|
||||
os.execute(('if not exist "%s" mkdir "%s"'):format(scene_folder_path, scene_folder_path))
|
||||
else
|
||||
os.execute(('mkdir -p "%s"'):format(scene_folder_path))
|
||||
end
|
||||
|
||||
local move_command
|
||||
if package.config:sub(1, 1) == "\\" then
|
||||
move_command = ('move /Y "%s" "%s"'):format(latest_file_path, scene_folder_path)
|
||||
else
|
||||
move_command = ('mv "%s" "%s"'):format(latest_file_path, scene_folder_path)
|
||||
end
|
||||
os.execute(move_command)
|
||||
|
||||
if remux_to_mp4 and latest_file_path:match("%.mkv$") then
|
||||
local new_file_path = scene_folder_path .. "/" .. latest_file_path:match("([^/]+)%.mkv$") .. ".mp4"
|
||||
local remux_command = ffmpeg_path .. ' -i "' .. scene_folder_path .. "/" .. latest_file_path:match("([^/]+)$") .. '" -c:v copy -c:a copy "' .. new_file_path .. '"'
|
||||
print("Remuxing to MP4:", remux_command)
|
||||
os.execute(remux_command)
|
||||
end
|
||||
else
|
||||
print("No file found to move.")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function get_current_scene_name()
|
||||
local current_scene = obslua.obs_frontend_get_current_scene()
|
||||
local name = obslua.obs_source_get_name(current_scene)
|
||||
obslua.obs_source_release(current_scene)
|
||||
return name
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue