user4310: For a small project of mine I want to record short screen-casts which show features of my program. Currently, I'm using a small app on my Ubuntu box which creates directly animated gif output. The drawback is, that gif has some limitations in the number of colors. If you inspect some of the gifs you may note that although it looks great, it's not perfect, especially when you look at the aliased fonts

There are some handmade solutions, for instance the demonstration on the sublime-text site. To have something that nice, you first need to record your screen completely lossless. Most screen-casting programs I know unfortunately do compress the video.
Question: I have Ubuntu and OSX at my disposal, what (if possible free) screen-casting solutions exists which let me create lossless videos?
Extra credit for programs where I can select the region or window to record and turn off audio.
Update
To make it clear what I mean with lossless: Usually, videos are compressed with a method which is perfect for natural images/videos but horrible for images/videos having sharp edges and one-colored structures. I made two screen-casts and zoomed a small part so that those effects are visible. The first one is done with gtk-recordmydesktop with highest quality and the artifacts in the gray area are clearly visible

The second one is done with the small Record your Desktop tool which saves gif files directly and takes the exact pixels of the screen without compression.

What I want is a screen-caster which saves its videos in this raw format without the limitations of gif.
Possibly related questions:

How does Salman Khan make his screencasts?
creating a lossless mp4 screencast


user4339: Here's a non-command-line option.
Try Collaaj (http://collaaj.com). Works on PC & Mac. It doesn't work on Ubuntu, but since you mentioned you have OSX, this should work just fine. I think it should do what you asked for and more. Such as region selection, selecting inputs etc.., and it also lets you upload and maintain your recordings on collaaj.com for anytime access. They have a nice set of videos here - http://collaaj.com/videos

user26843: 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.
Caveats

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 \
-framerate 30 
-i "1:" -c:v libx264 -crf 0 -preset ultrafast \
lossless-screen-rec.mkv 2>/dev/null" \
"ffmpeg -f avfoundation -i ":3" \
-acodec alac \
lossless-mic-.m4a 2>/dev/null"

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.
⚠️ ":3" and 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 

user4710: On OS X, seems like ScreenFlow can record in lossless (not by default, but this can be enabled in settings). Unfortunately, this application is not free. Still looking for free alternatives…
Important update!
This applies only to Screenflow 4.5.3 (and maybe some earlier versions). In Screenflow 5 this feature is gone. They advertise like they can do lossless recording, but this is a blatant lie: the "lossless" mode is using Apple ProRes, which is not lossless (and I tested the output, it indeed has artifacts), and there's no way to select some other codec (in Screenflow 4.5.3 the lossless mode is achieved by using "Animation" codec, which is qtrle, in Screenflow 5 there's no way to do this)
So… good bye, sweet prince.
Update 2
ffmpeg also can record the screen, if you learn how to use it properly.

user6082: I had very similar requirements and eventually found on Claquette.
It's an OS X app that uses a lossless codec. While it doesn't allow you to define a screen area before recording, it has a crop feature that allows you to select a region after the recording is finished. Audio can also be turned off. Movies can be exported in various formats (including h.264, ProRes and Animated GIF).

user1725: Alternatively, pipe your screen output to a second computer to record, using a device like a Blackmagic Intensity. It supports capturing to a totally uncompressed format (make sure you have an SSD or a RAID setup to record as the bitrate is very high). 
So the computer you're doing the work on should have dual monitor output - mirror the display so one output goes to your monitor, the other to a PC with a BlackMagic PCIe (or USB 3.0) card in it, that records the output. Use DVI/HDMI, not VGA.
Note, the Intensity only supports video-type resolutions, so a res like 1024x768 or 1024x1024, etc. is no good - 480p, 720p, 1080p, etc. are what you'll need to mirror your display at (21" 1080p LCDs are $99 now anyways). 
Then you can edit & compress the raw video any way you like.

user3476: FFmpeg with a lossless codec is one solution. I recall a comparison of different codecs which concluded that Apple Animation (known to ffmpeg as qtrle) gave the best quality for screen-recording.
ffmpeg -f x11grab -r 25 -s 1024x768 -i :0.0 -c:v qtrle output.mov

Stop it by opening its terminal while it is running and pressing q. Obviously change the resolution (1024x768 here) to match your own. For selecting a section of your screen, see how to grab the screen on the ffmpeg wiki.
It is possible that the ffmpeg which comes with your Linux distribution does not have the qtrle codec included. In this case you have to download and compile your own version. 

4310: <p>For a small project of mine I want to record short screen-casts which show features of my program. Currently, I'm using a small app on my Ubuntu box which creates directly animated gif output. The drawback is, that gif has some limitations in the number of colors. If <a href="http://halirutan.de/start" rel="nofollow noreferrer">you inspect some of the gifs</a> you may note that although it looks great, it's not perfect, especially when you look at the aliased fonts</p>

<p><img src="https://i.stack.imgur.com/y391d.gif" alt="animated gif"></p>

<p>There are some handmade solutions, for instance the demonstration on the <a href="http://www.sublimetext.com/" rel="nofollow noreferrer">sublime-text site</a>. To have something that nice, you first need to record your screen completely lossless. Most screen-casting programs I know unfortunately do compress the video.</p>

<p><strong>Question:</strong> I have Ubuntu and OSX at my disposal, what (if possible free) screen-casting solutions exists which let me create lossless videos?</p>

<p>Extra credit for programs where I can select the region or window to record and turn off audio.</p>

<h2>Update</h2>

<p>To make it clear what I mean with lossless: Usually, videos are compressed with a method which is perfect for <a href="http://www.hdwallpaperstop.com/wp-content/uploads/2013/06/forest-landscape_pictures_hd_wallpapers_nature_backgrounds_autumn_forest_and_landscape_color.jpg" rel="nofollow noreferrer">natural images/videos</a> but horrible for images/videos having <a href="http://upload.wikimedia.org/wikipedia/commons/3/3b/Ringing_artifact_example.png" rel="nofollow noreferrer">sharp edges and one-colored structures</a>. I made two screen-casts and zoomed a small part so that those effects are visible. The first one is done with <a href="http://wiki.ubuntuusers.de/recordMyDesktop" rel="nofollow noreferrer">gtk-recordmydesktop</a> with highest quality and the artifacts in the gray area are clearly visible</p>

<p><img src="https://i.stack.imgur.com/Q5oNm.png" alt="enter image description here"></p>

<p>The second one is done with the small <em>Record your Desktop</em> tool which saves gif files directly and takes the exact pixels of the screen without compression.</p>

<p><img src="https://i.stack.imgur.com/vK5GH.png" alt="enter image description here"></p>

<p>What I want is a screen-caster which saves its videos in this raw format without the limitations of gif.</p>

<p>Possibly related questions:</p>

<ul>
<li><a href="https://video.stackexchange.com/q/4477/4310">How does Salman Khan make his screencasts?</a></li>
<li><a href="https://video.stackexchange.com/q/3324/4310">creating a lossless mp4 screencast</a></li>
</ul>
 4339: <p>Here's a non-command-line option.</p>

<p>Try Collaaj (<a href="http://collaaj.com" rel="nofollow">http://collaaj.com</a>). Works on PC &amp; Mac. It doesn't work on Ubuntu, but since you mentioned you have OSX, this should work just fine. I think it should do what you asked for and more. Such as region selection, selecting inputs etc.., and it also lets you upload and maintain your recordings on collaaj.com for anytime access. They have a nice set of videos here - <a href="http://collaaj.com/videos" rel="nofollow">http://collaaj.com/videos</a></p>
 26843: <p>Please excuse my tardiness to the party, this is something that I've been working with as of late <em>lossless screen recording</em></p>

<p>Originally I was using OBS to record my screen throughout the year <em>2019</em> primarily for uploading screen recordings / cast to youtube, however I've recently began experimenting using ffmpeg to record my screen and mic <em>have not tested recording desktop audio</em> yet.</p>

<p>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 <a href="https://github.com/mltframework/shotcut" rel="nofollow noreferrer">shotcut</a> so I went back and reread the screen <a href="https://trac.ffmpeg.org/wiki/Capture/Desktop#lossless-recording" rel="nofollow noreferrer">capture doc</a> on the ffmpeg wiki, and noticed that screen recordings can be captured lossless using the x264 codec as long as <code>-crf 0</code> the <strong>crf</strong> is set to <strong>0</strong> which I believe means ffmpeg will use the x264 codec will not apply any lossy compression to the recording.  Also the wiki suggests using <code>-preset ultrafast</code> in conjunction with the <code>-crf 0</code> setting of the ffmpeg command.  I experimented with these settings last night and the picture quality / file size is great.</p>

<p>I recorded my screen <em>4K</em> 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.</p>

<h3>Caveats</h3>

<ul>
<li>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.</li>
<li>also, presently I have issues with recording audio <em>mic</em> 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. 

<ul>
<li><em>I run macOS 10.13.6</em> and I'm using the <em>Nvidia web driver</em> 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. ‍♂️</li>
</ul></li>
<li>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</li>
<li>also, I'd like to <em>convert</em> all prior recordings <em>ffmpeg</em> &amp; <em>OBS</em> using this new technique to preserve them for archival purposes.</li>
</ul>

<p>You mention your converting your recordings to animated GIFs, I've used the <a href="https://github.com/asciinema/asciicast2gif" rel="nofollow noreferrer">following project</a> to convert little screen recordings to GIFs <em>will only work with terminal based recordings</em>, and have had pleasant results using it.  It even has a docker container that makes using it rather simple for various OSes.</p>

<p>I did <a href="https://github.com/ipatch/dotfiles/wiki/video-production-Notes#ffmpeg-going-from-idiot-iphone-recording-to-animated-gif" rel="nofollow noreferrer">experiment</a> 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 <strong>mov</strong> <strong>mkv</strong> or <strong>mp4</strong>.</p>

<p>Also, I did a <a href="https://stackoverflow.com/a/36838100/708807">quick search</a> on the <strong>QTRLE</strong> codec and it seems it is not compatible with the <strong>MP4</strong> container format, so if using something other than <strong>MOV</strong> is required you might look at using a different codec.</p>

<p>⚠️ the below command will require <a href="https://github.com/kimmobrunfeldt/concurrently" rel="nofollow noreferrer">concurrently</a> be installed.</p>

<pre><code>concurrently --kill-others \ 
"ffmpeg -f avfoundation -capture_cursor 1 \
-capture_mouse_clicks 1 \
-framerate 30 
-i "1:" -c:v libx264 -crf 0 -preset ultrafast \
lossless-screen-rec.mkv 2&gt;/dev/null" \
"ffmpeg -f avfoundation -i ":3" \
-acodec alac \
lossless-mic-.m4a 2&gt;/dev/null"
</code></pre>

<p>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.</p>

<p>⚠️ <code>":3"</code> and <code>1:</code> will vary per system running macOS</p>

<p>To get a list of capture devices on macOS</p>

<pre><code>ffmpeg -f avfoundation -list_devices true -i ""
</code></pre>

<p>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 <em>for future me</em> </p>
 4710: <p>On OS X, seems like <a href="http://www.telestream.net/screenflow/overview.htm" rel="nofollow noreferrer">ScreenFlow</a> can record in lossless (not by default, but this can be enabled in settings). Unfortunately, this application is not free. Still looking for free alternatives…</p>
<h2>Important update!</h2>
<p>This applies only to Screenflow 4.5.3 (and maybe some earlier versions). <strong>In Screenflow 5 this feature is gone.</strong> They advertise like they can do lossless recording, but this is a blatant lie: the &quot;lossless&quot; mode is using Apple ProRes, which is not lossless (and I tested the output, it indeed has artifacts), and there's no way to select some other codec (in Screenflow 4.5.3 the lossless mode is achieved by using &quot;Animation&quot; codec, which is <code>qtrle</code>, in Screenflow 5 there's no way to do this)</p>
<p>So… good bye, sweet prince.</p>
<h2>Update 2</h2>
<p><a href="https://trac.ffmpeg.org/wiki/Capture/Desktop" rel="nofollow noreferrer">ffmpeg</a> also can record the screen, if you learn how to use it properly.</p>
 6082: <p>I had very similar requirements and eventually found on <a href="https://www.peakstep.com/claquette/" rel="nofollow noreferrer">Claquette</a>.<br>
It's an OS X app that uses a lossless codec. While it doesn't allow you to define a screen area <em>before</em> recording, it has a crop feature that allows you to select a region after the recording is finished. Audio can also be turned off. Movies can be exported in various formats (including h.264, ProRes and Animated GIF).</p>
 1725: <p>Alternatively, pipe your screen output to a second computer to record, using a device like a Blackmagic Intensity. It supports capturing to a totally uncompressed format (make sure you have an SSD or a RAID setup to record as the bitrate is very high). </p>

<p>So the computer you're doing the work on should have dual monitor output - mirror the display so one output goes to your monitor, the other to a PC with a BlackMagic PCIe (or USB 3.0) card in it, that records the output. Use DVI/HDMI, not VGA.</p>

<p>Note, the Intensity only supports video-type resolutions, so a res like 1024x768 or 1024x1024, etc. is no good - 480p, 720p, 1080p, etc. are what you'll need to mirror your display at (21" 1080p LCDs are $99 now anyways). </p>

<p>Then you can edit &amp; compress the raw video any way you like.</p>
 3476: <p>FFmpeg with a lossless codec is one solution. I recall <a href="http://boredzo.org/codec-comparison/">a comparison of different codecs</a> which concluded that Apple Animation (known to ffmpeg as <code>qtrle</code>) gave the best quality for screen-recording.</p>

<pre><code>ffmpeg -f x11grab -r 25 -s 1024x768 -i :0.0 -c:v qtrle output.mov
</code></pre>

<p>Stop it by opening its terminal while it is running and pressing <code>q</code>. Obviously change the resolution (1024x768 here) to match your own. For selecting a section of your screen, see <a href="https://ffmpeg.org/trac/ffmpeg/wiki/How%20to%20grab%20the%20desktop%20%28screen%29%20with%20FFmpeg">how to grab the screen</a> on the ffmpeg wiki.</p>

<p>It is possible that the <code>ffmpeg</code> which comes with your Linux distribution does not have the <code>qtrle</code> codec included. In this case you have to <a href="http://www.ffmpeg.org/index.html">download and compile</a> your own version. </p>
