refactor: extract virtcam cache_dir as constant
This commit is contained in:
parent
93dad5a043
commit
2bbc7df77e
|
@ -10,7 +10,7 @@ local http_server = require "http.server"
|
||||||
local http_headers = require "http.headers"
|
local http_headers = require "http.headers"
|
||||||
local json = require "JSON"
|
local json = require "JSON"
|
||||||
|
|
||||||
function NewHttpServer(host, port, handlers)
|
local function NewHttpServer(host, port, handlers)
|
||||||
local function reply(myserver, stream) -- luacheck: ignore 212
|
local function reply(myserver, stream) -- luacheck: ignore 212
|
||||||
-- Read in headers
|
-- Read in headers
|
||||||
local req_headers = assert(stream:get_headers())
|
local req_headers = assert(stream:get_headers())
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
local httpserver = require "httpserver"
|
local httpserver = require "httpserver"
|
||||||
|
local CACHE_DIR = "~/Videos/virtcam"
|
||||||
|
|
||||||
local function run(cmd)
|
local function run(cmd)
|
||||||
print(cmd)
|
print(cmd)
|
||||||
|
@ -9,6 +10,7 @@ end
|
||||||
|
|
||||||
run("sudo modprobe v4l2loopback -r -f")
|
run("sudo modprobe v4l2loopback -r -f")
|
||||||
run("sudo modprobe v4l2loopback video_nr=21 card_label=virtcam exclusive_caps=1")
|
run("sudo modprobe v4l2loopback video_nr=21 card_label=virtcam exclusive_caps=1")
|
||||||
|
run("mkdir -p " .. CACHE_DIR)
|
||||||
|
|
||||||
Ffmpeg = { cmd = "", proc = nil, name = "", started = false }
|
Ffmpeg = { cmd = "", proc = nil, name = "", started = false }
|
||||||
|
|
||||||
|
@ -45,12 +47,13 @@ Actualcam = Ffmpeg:new {
|
||||||
|
|
||||||
Recorder = Ffmpeg:new {
|
Recorder = Ffmpeg:new {
|
||||||
name = "recorder",
|
name = "recorder",
|
||||||
cmd = "ffmpeg -y -i /dev/video21 ~/Video/seq.mp4",
|
cmd = "ffmpeg -y -i /dev/video21 " .. CACHE_DIR .. "/seq.mp4",
|
||||||
}
|
}
|
||||||
|
|
||||||
Looper = Ffmpeg:new {
|
Looper = Ffmpeg:new {
|
||||||
name = "looper",
|
name = "looper",
|
||||||
cmd = "ffmpeg -re -stream_loop -1 -i ~/Video/loop.mp4 -f v4l2 -vcodec rawvideo -pix_fmt yuyv422 -framerate 30 /dev/video21 ",
|
cmd = "ffmpeg -re -stream_loop -1 -i " ..
|
||||||
|
CACHE_DIR .. "/loop.mp4 -f v4l2 -vcodec rawvideo -pix_fmt yuyv422 -framerate 30 /dev/video21 ",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,7 +73,7 @@ end
|
||||||
|
|
||||||
local stage = "stopped"
|
local stage = "stopped"
|
||||||
|
|
||||||
NewHttpServer("127.0.0.1", 10200, {
|
httpserver.NewHttpServer("127.0.0.1", 10200, {
|
||||||
["POST /prepare"] = function(_, _)
|
["POST /prepare"] = function(_, _)
|
||||||
if stage == "stopped" then
|
if stage == "stopped" then
|
||||||
-- run("pactl set-source-mute @DEFAULT_SOURCE@ 1")
|
-- run("pactl set-source-mute @DEFAULT_SOURCE@ 1")
|
||||||
|
@ -92,8 +95,12 @@ NewHttpServer("127.0.0.1", 10200, {
|
||||||
Recorder:start()
|
Recorder:start()
|
||||||
run("sleep 3")
|
run("sleep 3")
|
||||||
Recorder:stop()
|
Recorder:stop()
|
||||||
run("ffmpeg -y -i ~/Video/seq.mp4 -vf reverse ~/Video/reversed.mp4")
|
run("ffmpeg -y -i " .. CACHE_DIR .. "/seq.mp4 -vf reverse " .. CACHE_DIR .. "/reversed.mp4")
|
||||||
run("ffmpeg -y -i ~/Video/seq.mp4 -i ~/Video/reversed.mp4 -filter_complex '[0:v] [1:v] concat=n=2:v=1 [v]' -map '[v]' ~/Video/loop.mp4")
|
run("ffmpeg -y -i " ..
|
||||||
|
CACHE_DIR ..
|
||||||
|
"/seq.mp4 -i " ..
|
||||||
|
CACHE_DIR ..
|
||||||
|
"/reversed.mp4 -filter_complex '[0:v] [1:v] concat=n=2:v=1 [v]' -map '[v]' " .. CACHE_DIR .. "/loop.mp4")
|
||||||
run_only(Looper)
|
run_only(Looper)
|
||||||
stage = "fake"
|
stage = "fake"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user