Please excuse my tardiness to the party, this is something that I've been working with as of late lossless screen recording
Originally I was using OBS to record my screen throughout the year 2019 primarily for uploading screen recordings / cast to youtube, however I've recently began experimenting using ffmpeg to record my screen and mic have not tested recording desktop audio yet.
I started with vanilla ffmpeg settings for recording my screen, but the stock GOP setting of the recording makes it utterly painful when editing the recording in a NLE / NLA editor such as shotcut so I went back and reread the screen capture doc on the ffmpeg wiki, and noticed that screen recordings can be captured lossless using the x264 codec as long as
-crf 0 the crf is set to 0 which I believe means ffmpeg will use the x264 codec will not apply any lossy compression to the recording. Also the wiki suggests using
-preset ultrafast in conjunction with the
-crf 0 setting of the ffmpeg command. I experimented with these settings last night and the picture quality / file size is great.
I recorded my screen 4K 3840 x 2160 monitor at 30 fps and the bitrate was totally manageable, ie. I don't think it ever went above 10MB/sec, and a one minute recording was ~ 48MB, which is totally acceptable file size for archiving recordings.
- obviously if you do not prefer using a command line then this will probably not be for you, as I've found relying a GUI to interface with ffmpeg is not a viable thing as most GUIs I experimented with are outdated.
- also, presently I have issues with recording audio mic and screen at the same time under a single ffmpeg process / command, so I have to split the command into two separate commands / processed and start them simultaneously to keep the audio / video in sync.
- I run macOS 10.13.6 and I'm using the Nvidia web driver so that may be the issue why I the single ffmpeg process / command of recording screen and mic at same time is failing. Not entirely sure what the issue is. 🤷♂️
- I have not come up with a solution for recording the audio in a lossless codec yet, but that will definitely be my next task to research
- also, I'd like to convert all prior recordings ffmpeg & OBS using this new technique to preserve them for archival purposes.
You mention your converting your recordings to animated GIFs, I've used the following project to convert little screen recordings to GIFs will only work with terminal based recordings, and have had pleasant results using it. It even has a docker container that makes using it rather simple for various OSes.
I did experiment with using ffmpeg to convert and iPhone recording to animated GIF a while back which was useful for uploading the GIF to github because I believe github does not support uploading video files such as mov mkv or mp4.
Also, I did a quick search on the QTRLE codec and it seems it is not compatible with the MP4 container format, so if using something other than MOV is required you might look at using a different codec.
⚠️ the below command will require concurrently be installed.
concurrently --kill-others \
"ffmpeg -f avfoundation -capture_cursor 1 \
-capture_mouse_clicks 1 \
-i "1:" -c:v libx264 -crf 0 -preset ultrafast \
lossless-screen-rec.mkv 2>/dev/null" \
"ffmpeg -f avfoundation -i ":3" \
-acodec alac \
the above command will capture the computer screen losslessly using x264 and using alac to capture microphone input losslessly as well. both formats work well for editing in a NLA/NLE editor such as shotcut.
1: will vary per system running macOS
To get a list of capture devices on macOS
ffmpeg -f avfoundation -list_devices true -i ""
Anyways I know this is a lot of information, but I thought I'd share this info for the fact that I have been using ffmpeg almost daily for the past couple of weeks now so I thought I'd share what I've learned, and leave this info for future me 👴🏻