my ideas in action

Monthly Archives: December 2012

Screencast with FFMPEG with sound (Ubuntu 12.04 / Mint 13)

This is how to make a high quality screencast with sound from the soundcard.
Great if you want to record for example screencast tutorial or  a webpage that contains sound.
system: Ubuntu 12.04/ Mint 13

  • Record without sound, image size relative to dimensions of your screen (my case is 1600×900):

ffmpeg -f x11grab -s 1600×900 -r 25 -i :0.0 -sameq output.mkv

  • Record with sound, from your microphone:

ffmpeg -f alsa -i pulse -ab 192 -acodec pcm_s16le -f x11grab -s 1600×900 -r 25 -i :0.0 -sameq output.mkv

To record with sound, from your microphone you have to do also the following steps ( only first time):

* Install Pulse Audio Volume Control. (through synaptic package manager)
* Repeat the second command, recording starts.
* Go to Pulse Audio; go to the tab ‘Recording’, it shows ffmpeg recording the sound. Change the pull down menu to Monitor from Built in Analog Stereo.
Now it records the sound stream in stead of your micro. Set your microphone sound level to the desired values.
That is basically it.

After you save the file you will need to cut first few seconds and last few seconds to remove the parts where you start/stop the ffmpeg command.

This can be done with the below command.

Basically in the below example I extract from “output.mkv” the video starting from second 10 . The length of the output file (clip-output-file.mkv) is set to 120seconds.

ffmpeg -ss 10 -t 120 -i output.mkv -acodec copy -vcodec copy clip-output-file.mkv

print some columns from CSV file

If you have a CSV ( comma separated values file) and you need to print only some columns then you can use sed, awk or cut. Today I will show the “cut” command. Do not confuse it with “cat” !!

CUT is quite easy to use and is more simple than AWK or SED. For example if you have a file like this

$ cat datafile.csv

device1 device2 device2a device4b device5a device8 device9

1 56 8 99 5 41 36 8

22 5 99 89 56 56 2

1 0 2 5 9 63 5

As you can see the delimiter is not comma but space. If you want to print only columns 2,3 and 5 then “cut” is the best tool.

$ cut -d” ”  -f2,3,5 datafile.csv

device2 device2a device5a

56 8 5

5 99  56

0 2 9

-d” ” = means to use ” ” (space) as delimiter in the input file

-f2,3,5 = means to print only the fields 2, 3 and 5

So by default the output delimiter is space. If you want a specific delimiter, like tab, you can use this :

$ cut -d” ”  -f2,3,5 –output-delimiter=$’\t’  datafile.csv

device2         device2a        device5a

56                 8                       5

5                   99                     56

0                  2                        9

The syntax $’\t’ is special because cut do not accept TAB as “\t”

For another delimiter you can use the option like : –output-delimiter=”.:.”

$ cut -d” ”  -f2,3,5 –output-delimiter=$’\t’  datafile.csv





Of course for all this there is a AWK or SED command but I think that for simple column selection a CUT command is easier.

More than that. The CUT command give also the possibility to select only some bytes or characters from the file. For example to print only the characters from 2 to 5 you have to use :

$ cut -c2-5 datafile.csv



2 5


not very useful in my case but nice to have in case the input file format do not have a delimiter.

see more info with “man cut”

Automatic numbering of the equations in LibreOffice

Sometime I have to write a article that contain various formulas. Previously I was using Microsoft Word, but now I do not wave aces to it. To use Latex/Tex or one of the derivatives was too complex for me. So I started looking at Libre Office.  Everything was fine except a annoying issue with a numbering of the formulas.

What I wanted is a number on the right side of each formula. More than that, I want that when I refer to a certain formula in the text, to correspond with the correct formula. Even if I update the article later and add or remove some formulas.

Let me show what is the format that I wanted:


So as you can see now my article looks professional , like in any book.

But how to do that in Libre Office ?

Actually is easier that I expected.

So you type some text and then you want to add a formula

Type “fn” (of course without “” !! ) and then press F3. A formula will appear and a number on the right side.

Then you can double-click that formula and edit it with your values.

Now if you want to make a reference in the text to a certain formula, then you have to :

1: from menu Insert –> Cross Reference

2: Select from the pop-up window :

  • Type–> text
  • Insert reference to –> Reference
  • Selection –> choose the formula number that you want , in my case number 2.
  • Click Insert and then Close


At the end you will obtain something like this :

libreoffice2As you can see the references are highlighted with gray color to avoid confusion with ordinary text.

Now if you want to insert a new formula between 1 and 2, then the new formula will become (2) and the old (2) will become (3). Of course the reference from the text will be automatically undated.

Thats it. Nice end simple.

More detailed explanation here: