Open 0RadicalLarry0 opened 1 month ago
You achieve this by not calling https://wiki.facepunch.com/gmod/IVideoWriter:AddFrame every frame?
EDIT: I may have misunderstood your reply, updated code to work as an example of the problem.
Not while sound is recorded. Without sound, it does cut the video. With sound, it freezes on the last frame until you start adding frames. I reckon this is intended behavior so if you're doing what I'm doing and adding frames to match 30 fps without locking the clients fps to 30 it doesn't cut the audio.
Code to reproduce:
local config = {
container = "webm",
video = "vp8",
audio = "vorbis",
quality = 50,
bitrate = 500,
fps = 30,
lockfps = false,
name = "Test",
width = 480,
height = 480
}
local vid
local toggle = false
local pause_recording = false
local function StopRecording()
print("STOP RECORDING")
toggle = false
hook.Remove("PostRender", "Record")
vid:Finish()
end
local last_time = 0
local start_time = 0
local function Record()
local time = SysTime()
if time >= start_time then
StopRecording()
return end
if pause_recording then return end
if time >= last_time then
last_time = time + 0.0333333333333333 -- records at 30fps
vid:AddFrame(FrameTime(), false)
end
end
local function StartRecording()
print("START RECORDING")
toggle = true
pause_recording = false
vid = video.Record(config)
vid:SetRecordSound(true)
timer.Simple(0.1, function()
start_time = SysTime() + 60
hook.Add("PostRender", "Record", Record)
end)
end
concommand.Add("record_toggle", function()
if !toggle then
StartRecording()
else
StopRecording()
end
end)
concommand.Add("record_toggle_pause", function() -- Bind a key to this and press it in-game
if !pause_recording then
print("PAUSED")
pause_recording = true
else
print("UNPAUSED")
pause_recording = false
end
end)
Here is an example, the cut happens between 5 seconds and 10 seconds Test.webm
Details
Currently you cannot pause the video recording for jump cuts. If you stop adding frames to the video, it will freeze and record audio only. A function to manage the video play state should be added.
Something like:
IVideoWriter:SetRecordPause( bool )