Monday, January 18, 2016

Recording a screencast in Linux


A picture is worth a thousand words.
And what if you want to make it even better? What about using an animated image to show some action or progress? Like this one:

Personally I like the animated images on the main project pages at GitHub. See for example git-plus or color-picker Atom plugins. (Or my build-rake plugin displayed above.)

The question is how to record such screencasts?

Screen Recording in Linux

There are several tools for Linux which can be used for screen recording. It also depends it you want to create a standard video file (e.g. for uploading to youtube) or an animated image which can be embedded into web pages.

Standard Video

For recording the desktop to a standard video file (like in AVI or WEBM format) you can use the ffmpeg tool.

To record the screen with audio capture (via PulseAudio) to a WebM file (using open codecs VP9 for video and Opus for audio) use command like this:.

ffmpeg -f pulse -i default -video_size x -framerate 15 -f x11grab -i :0.0+<width>,<height> -b:v 1M -crf 10 output.webm
See these links for more details:

Animated Image

If you want to create an animated image you need to use the GIF image format (you could use an animated PNG as well, but that is not supported by all browsers).

You could use ffmpeg as well (just use output.gif file name), but in my tests the resulting image is too big for using on web pages. It's probably caused by the fact that ffmpeg uses dithering for images with 24bit colors which obviously leads to less compression. Maybe there are some options to tune this, but still writing the position of the recorded area manually is a bit uncomfortable...

Then I found the byzanz tool. It's by default available to install in the openSUSE distribution, simply run:

sudo zypper in byzanz xwininfo

(This will also install xwininfo package, see later why.)

Now you can record the desktop in a similar way like ffmpeg, see the accepted parameters:

byzanz-record --help

Again, you need to manually enter the coordinates of the recorded area if you do not want to record complete screens. And that's not trivial... Fortunately I found this nice byzanz-record-window helper script.

You can install it locally via these commands:

cd ~/bin
chmod a+x byzanz-record-window

The script uses the xwinfo helper to obtain the coordinates of the selected window. They are then passed to the byzanz-record tool.

I'd suggest to use about 3 second delay before starting the actual recording to have some time to get ready (switch to the correct window, position the mouse cursor, etc...).

So the final recording command would look like this:

byzanz-record-window --delay=3 --duration=5 screencast.gif

Final Notes

Be prepared to repeat the recording several times, you'll probably need more than a single attempt. I also found it easier to repeat the recording than editing and rebuilding the animation just to remove the useless parts at the beginning or the end.

Check also the resulting image size, for embedding into web pages it should be as small as possible. If it is too big then decrease the window size, do a shorter recording or avoid too many changes in the image.


ancorgs said...

I just found Peek, which is a outstanding GUI application that does the same than Byzant but in a fully graphical and intuitive way. And it's packaged for all major distros (including openSUSE, of course).

హాట్‌గర్ల్స్ said...

It's Really A Great Post. Looking For Some More Stuff.
Best MSBI Training in Bangalore
Best PEGA Training Institute in Bangalore
Best Oracle PLSQL Training Institutes in Bangalore
Best Advanced JAVA Training Institute in Bangalore
Best Salesforce CRM training institute in Bangalore
Best Oracle DBA Training Institute in Bangalore

I Digital Academy said...

Its a good post, helpful to the learners.
Spoken english Training in Bangalore

Unknown said...

It's A Really Great Post Thank You For Sharing. And it's Helpful to The Learners.
Best Digital Marketing Courses in Bangalore

Unknown said...

1. Best Digital Marketing Agency
Comment:Great Information, Thanks for sharing

Unknown said...

2. Best Digital Marketing company Anantapur
helpful information, thanks for writing and share this information

akhilapriya404 said...

The information which you have provided is very good. It is very useful who is looking for selenium Online Training Hyderabad

Unknown said...

The best case scenario for the bulls is that this count plays out. if this is the "worst" case scenario for the bears ... it's really not that bad ... if a top hasn't already been formed, we're close. night rats! may tomorrow bring you green shoots on whichever side of the fence you're on.

Unknown said...

While the relationship of stocks to the dollar has not always been "down dollar = up stocks" it has been this year. And in this market, that which gets rewarded gets repeated until someone's throat gets ripped out.
At times it has been that a strong dollar meant a strong America and a strong economy. All rules of logic are gone due to the oligarchs running the government.

Unknown said...

myTectra Placement Portal is a Web based portal brings Potentials Employers and myTectra Candidates on a common platform for placement assistance

Shriram Earth said...

The post was really very good.Thanks for sharing
prestige elysian

unknown said...

very nice post thankyou for sharing.
Sobha Royal Pavilion Sarjapur Road

Akash said...

I really enjoyed your blog Thanks for sharing such an informative post.
Indian Bookmarking list
Indian Bookmarking list
India Classified Submission List
Indian Classified List
Indian Bookmarking list
Indian Bookmarking list
India Classified Submission List
Indian Classified List

Training for IT and Software Courses said...

Thanks For sharing a nice post about MSBI Training Course.It is very helpful and MSBI useful for us.MSBI Training in Bangalore

meritstep said...

to starting a blog.If somebody take this blog article seriously in their life, he/she can earn his living by doing blogging.thank you for thizs article. pega online training , best pega online training ,
top pega online training

tejaswani blogs said...

Hi ,i am teju here to tell that explanation of this blog is clear and helpful as well.
1000 Social BookMarking Sites List
free social bookmarking sites list
new updated social bookmarking sites list

Venkygaming said...

Hi,im venky here to tell about that the explanation of content in this blog clear and helpful as well.

1000 Social BookMarking Sites List
free social bookmarking sites list
new updated social bookmarking sites list

Unknown said...

takipçi satın al
takipçi satın al
takipçi satın al

Educational Services said...

Thanks For Sharing such a wonderful article the way you presented is really amazing It was extraordinarily simple to discover my way around and amazingly clear, this is staggering!!!
Best Software Training Institutes

Unknown said...

Excellent Blog. Thanks for Sharing
Best Interior Designers

logesh said...

Thanks for posting the best information and the blog is very good.
ibm full form in india |
ssb ka full form |
what is the full form of dp |
full form of brics |
gnm nursing full form |
full form of bce |
full form of php |
bhim full form |
nota full form in india |
apec full form