It is currently Fri Mar 29, 2024 3:46 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Making timelapse videos on Linux
PostPosted: Sun Apr 10, 2016 5:32 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Apr 27, 2010
Posts: 1453
Location: Sweden
Introduction

I thought I'd share my process for making "timelapse" videos under Linux. Since a few different programs and there are many to pick from it it took a few tries for me to arrive at a stable workflow. The type of video I'm talking about is a sped up recording of making a painting in your favorite program, adding sound to it afterwards, like this one:

www.youtube.com Video from : www.youtube.com


This tutorial covers all aspects of creating a Linux timelapse in detail, so depending on your computer literacy you can probably skip parts of it. The sections covered are:
  • Recording the video - using screen recorders, both in GUIs and from the terminal.
  • Speeding up the video using memcoder - this creates really smooth speedup.
  • Compositing the video in Kdenlive - combining video clips, audio and text
  • Uploading to Youtube
  • Summary

Recording the video

There are a bunch of different screen recorder options in Linux and I've tried them all with varying results. Some have various clever solutions to only record part of the screen that's changing, others have various tools for showing graphics around your mouse cursor. For highly sped-up videos, showing your mouse and keyboard input is not all that useful however. In the end what I went with is the small and effective recordmydesktop.

In Debian-derived Linux distributions (like Ubuntu, Mint etc) you can get recordmydesktop from your package manager or with
sudo apt-get install recordmydesktop
Recordmydesktop itself is a terminal-only program, and I use it as such. There are however GUI frontends for it, with buttons to press, in the form of gtk-recordmydesktop (found e.g. in the Ubuntu repo). If you prefer experimenting with those, you can get them in the same way.

The GUI way

I use the terminal but the easiest way to get started is to use one of the GUI frontends to recordmydesktop. I used to cover two options here, gtk-recordmydesktop and recorditnow. But I found that recorditnow produced very bad, choppy results for me. It may be just me not knowing how to configure it but out of the box its results are not suitable for what we want to do. So I removed it.

gtk-recordmydesktop

After starting gtk-recordmydesktop, the following window will pop up.

Image
gtk_recordmydesktop-01.png

By default it will record your entire screen, or both screens if you have two monitors like me. You can use the "select window" button to mark which parts of the (tiny, tiny) thumbnail should be recorded. Before continuing though, press the "Advanced button" and go to the "Performance" tab. Make sure "Encode on the fly" is checked, like this:

Image
gtk_recordmydesktop-02.png

This makes the video immediately available to you when you finish (otherwise the encoding will happen afterwards which can take more than an hour for long videos). It is CPU-heavy though. So if you have a weaker computer and find it stutters while recording, turn this back off.

Press "record" to start recording. There should be a stop button popping up in your toolbar, but I find this does not really happen in my KDE setup. So unfortunately I have to stop it by killing the program from the task manager. One way or another, a file "out.ogv" (and later out-1.ogv, out-2.ogv etc) will be popping up in your home directory. These are video files you can look at with any normal video player (like VLC or Mplayer). Move them to wherever you want them to be.

The Terminal way

The terminal gives complete control over the recording and is really quite simple - the length of this section is just because I explain every option in detail. If you are using Linux (or any computer, really). knowing the terminal is a good skill to have and you could view this as a simple learning project.

First, set aside somewhere in your home folder for storing your stuff. I made a Videos folder in my home directory. First open a terminal (usually from a start menu or app launcher). This can be named Terminal, Konsole, Gnome Terminal, Xterm or similar depending on your window manager.
cd
mkdir Videos
cd Videos
Since every recording tends to be started in the same way, I made a simple bash script to start my recording. I use the VIM editor myself, but learning that is a bit outside of this tutorial. Installing something like gedit (sudo apt-get install gedit) is probably best - it's something like Notepad on Windows. Let's make a simple bash script:
gedit record_current_screen.sh &
The ending "&" means you can still use the terminal even though the gedit program is running: Just move your mouse back to the terminal and press return to get the terminal prompt back. In this script, add the following then save:
#! /bin/bash
echo "Starting recordmydesktop. Abort with Ctrl-C."
recordmydesktop --no-sound --on-the-fly-encoding --workdir /var/temp -o desktop_recording.ogv
echo "Stopped."
Ok, let's look at what this does.
  • #! /bin/bash must be at the very first line! There can not be an empty line above it. This tells Linux that this is a script that should be run with the bash shell.
  • echo lines (both of them) simply echo the text following them to you when the script runs. We put some in to help you remember how it works.
  • The recordmydesktop line is the actual starting of the program. We give it options:
    • --no-sound: Don't record any sound. This makes for a less CPU-demanding recording, and since we are speeding the recording up later, sound would not work anyway.
    • --on-the-fly-recording: This is important. It encodes the video immediately instead of just storing the raw frames in a temporarly location and encoding it afterwards. The advantage of this is that when you stop the recording you will immediately have a new .ogv file to look at. The drawback is that it's heavier on your CPU. So if you find your computer is affected by the recording (it stutters when you draw), turn this off. However, if you do, the encoding may take an hour or more after you stop the recording, so you must leave the terminal open to let it do its thing!
    • --workdir /var/temp: This allocates the temp folder for it to store temporary files in. It's probably not too important, but if your /var is on a very small hard drive you might want to move this elsewhere.
    • -o desktop_recording.ogv: This tells it to output the resulting video to a file desktop_recording.ogv. If you record multiple times and there is already a file with that name, subsequent files will be named desktop_recording-1.ogv, desktop_recording-2.ogv etc.

Let's test it out. Go back to the terminal (if you started gedit with & at the end, press return to get the prompt back).
ls
(returned:) record_current_screen.sh
So we have a new script file created. Let's make it executable:
chmod u+x record_current_screen.sh
If you do "ls" again, you should, if your terminal shows color, find that the file is green. The "chmod" command (which stands for "change mode") is used to change the permissions of a file. "u+x" means that we give the user (you) the right to "execute" the file. That is, to run it like a program.

So let's run it:
./record_current_screen.sh
(returned:) Starting recordmydesktop. Abort with Ctrl-C.
(returned:) Initial recording window is set to ...
(returned:) ...
The first text we see returned in the terminal is just the first echo of our script file. After that is a lot of recordmydesktop output. You should see a grey box appear around your screen. You are now recording your screen! Move your mouse and window a little then go back to the terminal and press Ctrl-C to stop the recording.

If you enter "ls" now, you will see a new desktop_recording.ogv file. You can look at it with VLC or Kaffeine or mplayer or whatever video player you have installed. Henceforth you can just run the script to record your screen whevever you like.

A note on dual monitors
If you have two screens you will normally be recording across both of them If you want to change to only record one of them that you need to specify the starting point and the width/height of the square in which to record when you call recordmydesktop. For example, I have two monitors, each 1680 pixels wide and 1050 high. Here's how I call recordmydesktop for recording on the left monitor:
recordmydesktop --no-sound --on-the-fly-encoding -x 0 -y 0 --width 1680 --height 1050 --workdir /var/tmp -o desktop_recording.ogv
And on the right monitor:
recordmydesktop --no-sound --on-the-fly-encoding -x 1680 -y 0 --width 1680 --height 1050 --workdir /var/tmp -o desktop_recording.ogv

The options are
  • -x and -y: These define the starting top left corner of the rectangle to record. -x 0 -y 0 means to start at the top left corner of the leftmost monitor. -x 1680 -y 0 means to start 1680 pixels to the right (that is, all the way across the leftmost monitor).
  • --width and --height: These specify the width and height of the recording area. We put them equal to one monitor's size.

Recording the video

Just start the recording and do the artworkd you want to record as as timelapse. This bit is entirely up to you. If you want to take a break, just stop the recording and start it again later. You will end up with multiple video files, but this is okay, we'll put them all together later.

Speed up the video

It's really quite dull to watch a painting being created in real time. Speeding it up makes it a lot easier to summarize the process and keep people from getting bored. In principle the video editor program should be able to speed up the video. However, I have found that my editor of choice (Kdenlive) is actually pretty flaky about that, and the quality is not always great. So I do the speedup in a separate tool, mencoder, which stands for "mplayer encoder". Get it from your package manager or via
sudo apt-get install mencoder
We will assume your new video file is called "desktop_recording.ogv" (replace with your actual filename). Open a terminal if you don't already have one open.
(cd to place you have your newly recorded video file)
mencoder desktop_recording.ogv -ovc xvid -oac mp3lame -xvidencopts pass=1 -pfps 48 -o "desktop_recording.mp4" -speed 8
This will convert your ogv file to a desktop_recording.mp4 file sped up 8 times (the speedup can be worth experimenting with). That long line is a lot to remember though, so let's make a script to run this easily, similarly to what we did in "The Terminal way" above. The gedit program is, as mentioned above, a simple text editor you can use. Let's make a small script called speedup_video.sh by entering
gedit speedup_video.sh &
(The "&" means you can keep using the terminal even though gedit is running). In gedit, enter these two lines and save:
#!/bin/bash
mencoder "$1" -ovc xvid -oac mp3lame -xvidencopts pass=1 -ofps 48 -o "$1.mp4" -speed "$2"
Here's what it means:
  • #! /bin/bash must be at the very first line! There can not be an empty line above it. This tells Linux that this is a script that should be run with the bash shell.
  • "$1" and "$2" will be replaced by the arguments we use to execute this script later. Think of them as placeholders - when the script runs, they will have values that we give it, in this case $1 will be the name of the video file and $2 the speedup factor.
  • -ofps 48 sets the resulting framerate to 48, which I find makes for a very nice and smooth video, especially when sped up.
  • The other options specify encoding formats and processing that just works. Look into the memcoder docs if you want more details.

If you saved in gedit, doing "ls" should show you that the new file speedup_video.sh has popped up. Now, make our new script executable:
chmod u+x speedup_video.sh
The "chmod" command (which stands for "change mode") is used to change the permissions of a file. "u+x" means that we give the user (you) the right to "execute" the file. That is, to run it like a program. Which we'll do next:
./speedup_video.sh desktop_recording.ogv 8
Note how we supply the name of the video file to speed up (desktop_recording.ogv), and then the speedup factor (8). In the script, these will replace the $1 and $2 when calling memcoder. From now on, you don't need to remember all those other memcoder options and can just run this on whatever video file you want.

Combining the video with music

For actually editing the video together with sound, we need a video editor. There are a open-source ones around for Linux, varying in complexity and scope. I have probably went through most of them and found that the simplest and easiest one is Kdenlive. It has relatively few bells and whistles - but we don't really need too fancy features for what we want to do. It allows for easy editing in a very intuitive way - and now that our video is pre-sped-up it will be even easier. One thing though - make sure to save your project often - Kdenlive can be a bit unstable at times. Get it via your package manager or via apt-get as usual:

sudo apt-get install kdenlive


When you open Kdenlive, this window faces you:

Image
kdenlive01.png

First, save your (currently empty) project in the File menu. Kdenlive projects have the file ending .kdenlive. Make sure to hit Ctrl-S often, just to be safe.

To add a new clip, go to the Project menu and choose "Add Clip":
Image
kdenlive02.png

Pick your sped-up video file from the selector. You may get a pop-up asking if you want to adapt your vide profile to the clip. Accept doing so. Your clip will now appear as one of the available clips. If you stopped/resumed your recording you will have multiple files (all sped up as above). Load those as well.

Next, add another clip, but this time select the finished painting (like a jpg file). We will show this as the "final result" at the end of the video.

Image
kdenlive03.png

Now just click-and-drag the video clip(s) onto the timeline below. If you have multiple videos, you can put them one after another. As seen above, I put the final image at the end. I also pulled at the edge of it to make it show longer. Note that I put the image clip on the "lower" timeline. The reason for this is because we want to put some text "on top of it" (those time lines work a little like layers). You can press Space to start playing the video in the small window to the upper right. Click in the time line to move the "timeline marker" around.

To add some text to the final image, click to place the timeline marker over the final image clip, Go to the Project menu again choose "Add Title clip". The following window will appear:

Image
kdenlive04.png

Make sure to check the "Show background" so you see where to put text relative to the image (which is "below" it in the timeline stack). This bit works like a text editor, you write text, align it etc. Think of it as writing on a transparent sheet over the video. When you exit, you will have a new "Title Clip" available. Pull this to the timeline above your final image and extend the two to match:

Image
kdenlive05.png

Let's add sound! If you aren't making your own music, you need to download this from somewhere. You can't use just any music either, you must use music with a license allowing you to use it for free (you could also license music for money of you really wanted to, of course). A good idea is to search google for "royalty free music". There are lots of musicians that release music that you can use. Remember that if you want to monetize your video on Youtube (have it show ads), you must also check so the music license allows commercial use.

Once you have your music. you need to do the normal "Add Clip" from the Project menu to get your music MP3 files. Pull those onto one of the "Audio" tracks.

Image
kdenlive06.png

Most musical pieces are only 3-4 minutes long so you probably need to add multiple music files one after another to last the length of your video.

A final touch is to add fade-ins/outs. You find them under the "Effects" tab in the center of the Kdenlive window.

Image
kdenlive07.png

There are separate fades for the video and for the audio. Just pull them onto the right clip to add the effect (they will be added to the beginning or end of the clip depending on if you are fading in or out). This is a very easy way to blend music and clips together (such as fading out the previous clip and fading in the final result at the end of the video). It's pretty intuitive so you should be able to figure it out. There are plenty of other effects, experiment - just remember to save your progress often.

Image
kdenlive08.png

Finally we want to render the file into a final video, sound, text and all. Press the "Render" button in the Kdenlive toolbar and you'll get the pop-up above. You can set the output file to the final filename you want for your video. MP4 is a good format to go for. For putting on Youtube, I use default settings and choose MP4/MPEG-4/MP3 as seen above - it has worked well for me but you may experiment if you want.
Press "Render to File" and your video will be created. If your video is long, this may take a while.

In the end you'll have your very own video that you can play on your computer!

Uploading your video to Youtube

This is the easy bit, although the process may be a bit slow if your video is big. First you need a Google account. You use that to log into Youtube. If you go to your own "channel" you will have an "Upload" button you can click. This will give you the option to upload a new video. I recommend you first set the video to "Private". This gives you time to add any extra stuff to the video before anyone else can see it.

Once you've chosen your video file (or drag&dropped it), you will need to wait for it to upload. While uploading you can't close the browser window. After that the Youtube progress bar will show that the video is "Processing". This can take a long while sometimes, and you don't have to sit around to wait for it - when the processing is done the video will just pop up as one of your videos. If you set it to private you then have all the time in the world to set its name, description, choose monetization options and what have you. I often add Annotations (pop up notes) to give some more background on what I'm doing in a painting.

When you are done, just switch the video to being "Public" and you have your timelapse online ready for everyone to see!

www.youtube.com Video from : www.youtube.com


Summary

This may have been a long read, but most of this tutorial describes setting things up. When I create a video, my full work flow is this:

    1) Start gimp/krita/mypaint/whatever and open terminal
    2) run ./record_left_screen.sh
    3) Paint the image, then Ctrl-C to stop recording
    4) run ./speedup_video.sh desktop_recording.ogv 8
    5) Open kdenlive and edit
    6) Post to YouTube

_________________


Last edited by Griatch on Sun May 01, 2016 3:50 am, edited 5 times in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: ~
PostPosted: Sun Apr 10, 2016 11:16 am  (#2) 
Offline
GimpChat Member

Joined: Apr 29, 2013
Posts: 203
~

_________________
~


Last edited by Zeo on Tue Nov 30, 2021 10:15 pm, edited 1 time in total.

Top
 Post subject: Re: Making timelapse videos on Linux
PostPosted: Sun Apr 10, 2016 11:51 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Apr 27, 2010
Posts: 1453
Location: Sweden
Zeo wrote:
By the way, the picture in this tutorial can't be seen in my browser...


Gack, sorry about that, I'm not really used to how the new Google photos deal with sharing photos. They should be visible now, let me know if there are still problems with seeing the images!

Zeo wrote:
Recently, I try to make my first time-lapse in Linux too. (Linux Mint 17.2 XCFE)
And, by pure luck, I use similar software used in this tutorial (except using memcoder). Not too familiar with terminal, I use gtk-recordmydesktop, and the icon do appears in my panel/toolbar so it is easy to begin/stop the recording process.
...but unfortunately I use the default setting at recordmydesktop, and, at the end of timelapse, the encoding process took looooooonng time, and last part of the video is missing... :oops:

Yeah, if not using the immediate-encode option, you will be waiting a very long time to actually encode the video after finishing. I think it's doing this to make sure your computer sees no slowdown at all while recording, but I've not seen any issues with encoding at the same time (I have a decently powerful machine though). The problem is that if you abort the encoding you will lose your progress and likely the movie entirely. It IS possible to get it back as long as you don't turn off the computer in between (I remember doing that for one of my Christmas cards, the raw data is still in your /var/tmp somewhere so there are ways to encode them still).

The reason I use memcoder is that speeding things up in Kdenlive has been very error-prone for me - if you tweak things too much I've found the program crashing, and sometimes the result is not so smooth as it should be I think. Memcoder will produce an even-speedup and simply makes the work in Kdenlive so much nicer for me.

Nice timelapse video you did there! Good light on that mecha, too bad you didn't get all of the video down. If you use Kdenlive to edit it, I would recommended you cut away the two minutes where you leave to eat - it's not that interesting to look at nothing happening after all. ;)
.
Griatch

_________________


Top
 Post subject: Re: Making timelapse videos on Linux
PostPosted: Sun Apr 10, 2016 12:52 pm  (#4) 
Offline
Global Moderator
User avatar

Joined: Nov 16, 2011
Posts: 5128
Location: Metro Vancouver, BC
Excellent info Griatch.
Recordmydesktop is good one, did you test Kdenlive's 'Screen Grab'?

_________________
Image
Gimp 2.8.18, Linux, median user
Gimp Chat Tutorials Index
Spirit Bear (Kermode)


Top
 Post subject: ~
PostPosted: Mon Apr 11, 2016 5:46 am  (#5) 
Offline
GimpChat Member

Joined: Apr 29, 2013
Posts: 203
~

_________________
~


Last edited by Zeo on Tue Nov 30, 2021 10:16 pm, edited 1 time in total.

Top
 Post subject: Re: Making timelapse videos on Linux
PostPosted: Thu Apr 14, 2016 12:23 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Apr 27, 2010
Posts: 1453
Location: Sweden
Zeo wrote:
Oh sorry about that eating part... I just... want to make the video as realistic as possible with no edit. :hehe
Just this morning I try again record a painting video with 'encoding on the fly' turned on, but weirdly after about an hour the computer suddenly back to login screen, the recording is still intact as .ogv file, but all the program closed (but, music player is in 'pause'). Maybe random crashes, or it is me that playing around with the machine's default setting. :hehe

If the window manager crashes, it may be a memory problem. How much RAM do you have in your computer?
Good thing that you didn't loose your .ogv file at least!
.
Griatch

_________________


Top
 Post subject: Re: Making timelapse videos on Linux
PostPosted: Sun May 01, 2016 3:52 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Apr 27, 2010
Posts: 1453
Location: Sweden
Update: I removed my coverage of the recorditnow screen recorder since it produced very poor, choppy video for me. It may well be that it's default configuration could be adjusted to work better for our purpose but as it is I can't recommend it.
.
Griatch

_________________


Top
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts How I Make Videos With Gimp And G'MIC

1

No new posts Subtitle Transcripts From YouTube Videos

2

No new posts A family friendly Christmas videos site.

2

No new posts Timelapse video: Christmas Card 2021

3

No new posts Annotated timelapse: Landscape painting and big wolves in Krita

7



* Login  



Powered by phpBB3 © phpBB Group