I'm capturing HTML animation with use of Puppeteer and MediaRecorder API.
Before starting the capturing I'm waiting for networkidle
event (I tried networkidle0-2 but result is identical)
await page.goto(url, { waitUntil: 'networkidle0' })
For some reason, the animation starts to play 2-3 seconds after the capturing starts, and thus, white frames are captures. Similar, at the end of the video there are identical frames because capturing duration is a bit longer than animation plays.
Thus I want to detect and cut off those repeating white frames at the beginning and repeating non-white frames at the end of the video (mp4/webm).
I tried some solutions, like described here, for instance
ffmpeg -i input.mp4 -vf mpdecimate,setpts=N/FRAME_RATE/TB out.mp4
It does remove duplicates, but the problem is that it cuts off dups in the middle as well.
Thus, if I have a 15 sec animation,it removes all dups at the beginning, all dups at the end and all dups in the middle, and what is left after it is just a several identical frames which are pack into less than 1 sec video.