2024-01-13 22:55:15 +00:00
|
|
|
#!/usr/bin/env luajit
|
2024-01-14 00:31:54 +00:00
|
|
|
|
2024-01-14 01:13:57 +00:00
|
|
|
local help = [[Usage:
|
2024-01-14 00:31:54 +00:00
|
|
|
|
2024-01-14 00:36:05 +00:00
|
|
|
2webm.lua [threads=1]
|
2024-01-14 00:31:54 +00:00
|
|
|
|
|
|
|
Converts everything in the local directory to webm, placed in "./2webm-output".
|
2024-01-14 00:36:05 +00:00
|
|
|
(Defaults to using only a single thread to reduce impact on the system.)
|
2024-01-14 00:31:54 +00:00
|
|
|
|
|
|
|
[threads]: Number of threads ffmpeg will be assigned.
|
2024-01-14 00:36:05 +00:00
|
|
|
If a non-number value, ffmpeg's -threads flag will not be used.
|
2024-01-14 00:31:54 +00:00
|
|
|
]]
|
|
|
|
|
|
|
|
if arg[1] and arg[1]:find("help") then
|
|
|
|
print(help)
|
|
|
|
return false
|
2024-01-13 22:55:15 +00:00
|
|
|
end
|
|
|
|
|
2024-01-14 00:54:25 +00:00
|
|
|
local error_occurred, utility = pcall(function() return dofile(arg[0]:match("@?(.*/)") or arg[0]:match("@?(.*\\)") .. "utility-functions.lua") end) if not error_occurred then error("\n\nThis script is installed improperly. Follow instructions at:\n\thttps://github.com/TangentFoxy/.lua-files#installation\n") end
|
2024-01-14 01:04:55 +00:00
|
|
|
utility.required_program("ffmpeg")
|
2024-01-14 00:31:54 +00:00
|
|
|
|
2024-01-14 00:36:05 +00:00
|
|
|
local threads = tonumber(arg[1]) or arg[1] or 1
|
2024-01-13 22:55:15 +00:00
|
|
|
|
2024-01-14 00:31:54 +00:00
|
|
|
local for_files = utility.ls()
|
|
|
|
os.execute("mkdir 2webm-output")
|
2024-01-13 22:55:15 +00:00
|
|
|
|
2024-01-14 00:31:54 +00:00
|
|
|
for_files(function(file_name)
|
|
|
|
local command
|
2024-01-14 00:36:05 +00:00
|
|
|
if type(threads) == "number" then
|
2024-01-14 00:31:54 +00:00
|
|
|
command = "ffmpeg -threads " .. threads .. " -i \"" .. file_name .. "\" -threads " .. threads .. " \"2webm-output/" .. file_name .. ".webm\""
|
|
|
|
else
|
|
|
|
command = "ffmpeg -i \"" .. file_name .. "\" \"2webm-output/" .. file_name .. ".webm\""
|
2024-01-13 22:55:15 +00:00
|
|
|
end
|
|
|
|
|
2024-01-14 00:31:54 +00:00
|
|
|
os.execute(command)
|
|
|
|
end)
|