2webm should be done, untested though

This commit is contained in:
Tangent / Rose / Nebula Rosa 2024-01-13 17:36:05 -07:00
parent b2127451fc
commit ef896d140d
2 changed files with 7 additions and 6 deletions

View File

@ -2,12 +2,13 @@
local helptext = [[Usage: local helptext = [[Usage:
2webm.lua [threads] 2webm.lua [threads=1]
Converts everything in the local directory to webm, placed in "./2webm-output". Converts everything in the local directory to webm, placed in "./2webm-output".
(Defaults to using only a single thread to reduce impact on the system.)
[threads]: Number of threads ffmpeg will be assigned. [threads]: Number of threads ffmpeg will be assigned.
If a non-number value, 1 thread will be used. If a non-number value, ffmpeg's -threads flag will not be used.
]] ]]
if arg[1] and arg[1]:find("help") then if arg[1] and arg[1]:find("help") then
@ -18,14 +19,14 @@ end
local error_occurred, utility = pcall(function() return require("utility-functions") end) if not error_occurred then error("This script is installed improperly. Follow instructions at https://github.com/TangentFoxy/.lua-files#installation") end local error_occurred, utility = pcall(function() return require("utility-functions") end) if not error_occurred then error("This script is installed improperly. Follow instructions at https://github.com/TangentFoxy/.lua-files#installation") end
utility.required_program("ffpmeg") utility.required_program("ffpmeg")
local threads = tonumber(arg[1]) or (arg[1] and 1) local threads = tonumber(arg[1]) or arg[1] or 1
local for_files = utility.ls() local for_files = utility.ls()
os.execute("mkdir 2webm-output") os.execute("mkdir 2webm-output")
for_files(function(file_name) for_files(function(file_name)
local command local command
if threads then if type(threads) == "number" then
command = "ffmpeg -threads " .. threads .. " -i \"" .. file_name .. "\" -threads " .. threads .. " \"2webm-output/" .. file_name .. ".webm\"" command = "ffmpeg -threads " .. threads .. " -i \"" .. file_name .. "\" -threads " .. threads .. " \"2webm-output/" .. file_name .. ".webm\""
else else
command = "ffmpeg -i \"" .. file_name .. "\" \"2webm-output/" .. file_name .. ".webm\"" command = "ffmpeg -i \"" .. file_name .. "\" \"2webm-output/" .. file_name .. ".webm\""

View File

@ -6,7 +6,7 @@ utility = require("utility-functions")
print("---") print("---")
local threads = tonumber(arg[1]) or (arg[1] and 1) local threads = tonumber(arg[1]) or arg[1] or 1
print(threads) print(threads, type(threads))
print("---") print("---")