Search code examples
node.jsffmpegelectronscreen-recording

record screen with high quality and minimum size in ElectronJS (Windows)


as I said in the title, I need to record my screen from an electron app.

my needs are:

  • high quality (720p or 1080p)
  • minimum size
  • record audio + screen + mic
  • low impact on PC hardware while recording
  • no need for any wait after the recorder stopped

by minimum size I mean about 400MB on 720p and 700MB on 1080p for a 3 to 4 hours recording. we already could achieve this by bandicam and obs and it's possible

I already tried:

  • the simple MediaStreamRecorder API using RecordRTC.Js; produces huge file sizes, like 1GB per hour for 720p video.
  • compressing the output video using FFmpeg; it can take up to 1 hour for 3 hours recording
  • save every chunk with 'ondataavailable' event and right after, run FFmpeg and convert and reduce the size and append all the compressed files (also by FFmpeg); there are two problems. 1, because of different PTS but it can be fixed by tunning compress command args. 2, the main problem is the audio data headers are only available in the first chunk and this approach causes a video that only has audio for the first few seconds
  • recording the video with FFmpeg itself; the end-users need to change some things manually (Stereo Mix), the configs are too complex, it causes the whole PC to work slower while recording (like fps drop; even if I set -threads to 1), in some cases after recording is finished it needs many times to wrap it all up
  • searched through the internet to find applications that can be used from the command line; I couldn't find much, the famous applications like bandicam and obs have command line args but there are not many args to play with and I can't set many options which leads to other problems

I don't know what else I can do, please tell me if u know a way or simple tool that can be used through CLI to achieve this and guide me through this


Solution

  • I end up using the portable mode of high-level 3d-party applications like obs-studio and adding them to our final package. I also created a js file to control the application using CLI

    this way I could pre-set my options (such as crf value, etc) and now our average output size for a 3:30 hour value with 1080p resolution is about 700MB which is impressive