Skip to content

Instantly share code, notes, and snippets.

@me7
Created July 21, 2017 10:01
Show Gist options
  • Save me7/f6e85c245b8cc4672eb549a9f05f4a76 to your computer and use it in GitHub Desktop.
Save me7/f6e85c245b8cc4672eb549a9f05f4a76 to your computer and use it in GitHub Desktop.
use lua to execute ffmpeg
function convert2wmv(filename)
return os.execute('ffmpeg -i \"'..filename..'\" -q:v -vf scale=w=854:h=854:force_original_aspect_ratio=decrease \"'..filename..'.wmv\"')
end
function convert2wma(filename)
return os.execute('ffmpeg -i \"'..filename..'\" -vn \"'..filename..'.wma\"')
end
function cutvideo(filename)
io.write("cut from (sec): ")
from = io.read()
io.write("to (sec): ")
to = io.read()
return os.execute('ffmpeg -i \"'..filename..'\" -q:v 10 -vf scale=w=854:h=854:force_original_aspect_ratio=decrease -ss '..from..' -to '..to..' \"'..filename..'_'..from..'-'..to..'.wmv\"')
end
function cutaudio(filename)
io.write("cut from (sec): ")
from = io.read()
io.write("to (sec): ")
to = io.read()
return os.execute('ffmpeg -i \"'..filename..'\" -q:a 10 -vn -ss '..from..' -to '..to..' \"'..filename..'_'..from..'-'..to..'.wma\"')
end
funcname = arg[1]
filename = arg[2]
if not _G[funcname](filename) then io.read() end
-- usage: lua d:\cmd cut2wmv "%1"
@me7
Copy link
Author

me7 commented Jul 21, 2017

function convert2wmv(filename)
return os.execute('ffmpeg -i "'..filename..'" -q:v -vf scale=w=854:h=854:force_original_aspect_ratio=decrease "'..filename..'.wmv"')
end

function convert2wma(filename)
return os.execute('ffmpeg -i "'..filename..'" -vn "'..filename..'.wma"')
end

function cut2wmv(filename)
io.write("cut from (sec): ")
from = io.read()
io.write("to (sec): ")
to = io.read()
return os.execute('ffmpeg -i "'..filename..'" -q:v 10 -vf scale=w=854:h=854:force_original_aspect_ratio=decrease -ss '..from..' -to '..to..' "'..filename..'_'..from..'-'..to..'.wmv"')
end

function cut2wma(filename)
io.write("cut from (sec): ")
from = io.read()
io.write("to (sec): ")
to = io.read()
return os.execute('ffmpeg -i "'..filename..'" -q:a 10 -vn -ss '..from..' -to '..to..' "'..filename..'_'..from..'-'..to..'.wma"')
end

funcname = arg[1]
filename = arg[2]

if not _Gfuncname then io.read() end

-- usage: lua d:\cmd cut2wmv "%1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment