Facepunch / garrysmod-issues

Garry's Mod issue tracker
144 stars 56 forks source link

video.Record Codec #5624

Open ItsDonnyDev opened 11 months ago

ItsDonnyDev commented 11 months ago

Tested this with several render and drawing hooks, and to my understanding the issue of my httpPost returning a distorted videoframe is a result of the codec not supporting this (or other, higher than 1920x1080 which i cannot test) resolution '1366x768'

765611984129011351701554912[1].webm

    local id64 = LocalPlayer():SteamID64()
    local CallHook = netReadBool()
    local id = _tostring(netReadUInt(32))

    local CaptureFunction = function()
        local writer = videoRecord({
            container = "webm",
            video = "vp8",
            quality = 100,
            audio = "vorbis",
            bitrate = 2000,
            fps = 1,
            lockfps = 1,
            name = id,
            width = mathClamp(_ScrW(), 0, 1920),
            height = mathClamp(_ScrH(), 0, 1080),
        })
        if writer == false then return end
        writer:SetRecordSound( false )
        writer:AddFrame(1, true)
        writer:Finish()
    end

    if CallHook then
        hookAdd("DrawOverlay", "CaptureFrame", function()
            CaptureFunction()
            hookRemove("DrawOverlay", "CaptureFrame")
        end)
    else
        CaptureFunction()
    end
robotboy655 commented 11 months ago

Cannot confirm. I have tried running your code (after fixing it) with CallHook set to true and it worked properly for 3 different resolutions in windowed mode.

test3.webm

test4.webm

test5.webm

robotboy655 commented 11 months ago

The code I ran is:

local CallHook = true//netReadBool()

    local CaptureFunction = function()
        local writer = video.Record({
            container = "webm",
            video = "vp8",
            quality = 100,
            audio = "vorbis",
            bitrate = 2000,
            fps = 1,
            lockfps = 1,
            name = "test5",
            width = ScrW(),
            height = ScrH(),
        })
        if writer == false then return end
        writer:SetRecordSound( false )
        writer:AddFrame(1, true)
        writer:Finish()
    end 

    if CallHook then
        hook.Add("DrawOverlay", "CaptureFrame", function()
            CaptureFunction()
            hook.Remove("DrawOverlay", "CaptureFrame")
        end)
    else
        CaptureFunction()
    end
ItsDonnyDev commented 6 months ago

Requesting a re-open after revisiting this project a million years later..

Did several tests and none gave a different result until i opted out of the beta chromium gmod version. The issue apparently lies with WreHKqb 1

edit: I added a temp fix as that specific width seems to be causing this local scrW = ScrW() == 1366 and 1360 or math.Clamp(ScrW(), 0, 1920)