GoSecure / pyrdp

RDP monster-in-the-middle (mitm) and library for Python with the ability to watch connections live or after the fact
https://www.gosecure.net/blog/2020/10/20/announcing-pyrdp-1/
GNU General Public License v3.0
1.49k stars 242 forks source link

Increase/validate precision of converted videos #359

Open obilodeau opened 3 years ago

obilodeau commented 3 years ago

I believe that the way we encode frames we create the possibility of a drift between the real time and the resulting video times. This is exacerbated on large captures.

In Mp4EventHandler's init:

        self.delta = 1000 // fps  # ms per frame

then:

        nframes = (dt // self.delta)
        if nframes > 0:
            for _ in range(nframes):
                self.writeFrame()

However:

In [18]: 1000//30
Out[18]: 33

In [19]: 1000/30
Out[19]: 33.333333333333336

There's a 0.3ms per 1000ms drift opportunity. On a long capture this amount to a very large maximum theoretical drift:

In [26]: ((1000/30-1000//30) * 12*60*60) / 60
Out[26]: 240.0000000000017

Further investigation: I will record an RDP session playing a high precision clock and timer on a screen for a long time and compare after video encoding.

obilodeau commented 3 years ago

@h3xstream suggested to use a fps of 25 (which can divide 1000 cleanly) and see. What I like about this solution is that it would also make the conversion faster and video files smaller. Remembering some captures I looked at, we clearly don't do 30 fps over RDP anyway.