Tuesday, May 27, 2008

How to convert DVD movie to .3gp

Most modern mobile phones can play movies in .3gp format. Here's an example, how to convert a movie on DVD to .3gp format. Of course this is not the only way how to do it:
  1. Open DVD Shrink, go to "Edit" -> "Preferences" -> "Output files" & uncheck "Split VOB files into 1GB size chunks
  2. open DVD, choose Re-author
  3. Drag the Main movie title into "DVD structure" window
  4. Go to "Compression settings", and choose only one language, uncheck all subtitles. Be sure that the video compression is set to 100% or "no compression" (although not mandatory, this is major time saver option)
  5. In the "DVD structure" windows, right click on the movie title, and choose "Set Start/End frames". This way you can remove unwanted frames from the beginning or the end of the movie .- e.g. opening and closing credits (again not mandatory, but it is space saver option)
  6. Click "Backup", in "Select backup target" choose "Hard disk folder", and set the target folder for DVD output files, e.g. "c:\movie"
  7. Click "OK" and wait a couple of minutes until DVDShrink finishes its job.
  8. Now go to DVD output folder (e.g. c:\movie) and rename the biggest file (something like VTS_01_1.VOB) to movie.mpg. You can delete all other files. Now you have a movie in one .mpg file, with one audio track and no subtitles. And in the same step we 've cut the credits from the movie.
  9. In the following steps we'll try go get some movie details, and figure out which parts of the movie we can cut
  10. Open movie.mpg in your favourite movie player, and pause at some bright scene
  11. press "Alt"+"Print Screen" on your keyboard, open paint (START->All programs->Accessories->Paint) and paste the clipboard (edit->paste)
  12. Zoom the spot just above the movie, and draw a line through the black part, that we want to crop from the final movie. Check the length of the line in the lower right corner of the paint window, and choose the next even number (in this example the length is 71 px, so we choose 72)
  13. Repeat the same procedure for the lower black part of the movie, for the movie width and the movie height. See the picture below:
  14. Now some simple math; our input movie is 1024x426. We want to resize it to 320 px width and keep the aspect ratio. So we can calculate the output height like that:
      • 1024/426=320/width => width = 133
      • we choose the next even value, so the size of our output movie will be 320x134
  15. In the next steps we'll convert the .mpg file to .3gp, using a command line tool "ffmpeg"
  16. Get the ffmpeg binaries here and extract the archive somewhere, e.g. c:\programs\ffmpeg (I got this version from super installation, because not all windows binaries have support for 3gp. This version does, at least it works on my system)
  17. open command line (START->Run->cmd)
  18. in terminal windows, type :
    1. > cd \programs\ffmpeg
    2. > ffmpeg.exe -i c:\movie\movie.mpg -croptop 72 -cropbottom 78 -vcodec mpeg4 -b 144k -bitexact -hq -s 320x134 -r 25 -acodec aac -ac 2 -ar 48000 -ab 24k -f 3gp c:\movie\movie.3gp
  19. Some explanation of the above command:
    • -i :input file
    • -croptop/-cropbottom :set crop top/bottom band size (what we've measured before)
    • -r :frame rate
    • -b :bitrate
    • -hq :higher quality
    • -s :output size (what we've measured and calculated before)
    • -acodec :audio codec
    • -ac :use 2 for stereo, 1 for mono
    • -ar :audio sampling rate
    • -ab :audio bitrate
    • -f :force format
  20. After a while you'll have a brand new .3gp movie, with the original aspect ratio, without black borders and without credits!
  21. transfer the movie.3gp file to your mobile phone and enjoy the silence of your kids watching the movie when you're in traffic jam ;-)

If you have time, you can use 2-pass encoding, which should produce a better quality movie. Although I'm not really sure if you'll spot any difference on your small mobile phone screen.
For 2-pass encoding use the following commands:
  • > ffmpeg.exe -i c:\movie\movie.mpg -croptop 72 -cropbottom 78 -vcodec mpeg4 -b 144k -bitexact -hq -s 320x134 -r 25 -acodec aac -ac 2 -ar 48000 -ab 24k -f 3gp -pass 1 c:\movie\movie.3gp
  • > ffmpeg.exe -i c:\movie\movie.mpg -croptop 72 -cropbottom 78 -vcodec mpeg4 -b 144k -bitexact -hq -s 320x134 -r 25 -acodec aac -ac 2 -ar 48000 -ab 24k -f 3gp -pass 2 c:\movie\movie.3gp

Some gui alternatives, if the procedure above is too complicated, although at my knowledge they can't handle movie in DVD format, but only a movie already in one file (.avi, .mpg or something):

Monday, May 19, 2008

How to stamp date on digital photos

Using a totally free command line tool jdatestamp, works in GNU/Linux and in Windows:

- get jdatestamp here (for windows click on jdatestamp-1.1-win32.zip)
- extract the zip archive somewhere (e.g. c:\programs\jdatestamp)
- put all the photos, which you want to stamp with the creation date, in one folder (e.g. "c:\pictures\orig")
- open command line (START->Run->cmd)
- in terminal window, type:
> cd c:\programs\jdatestamp
> jdatestamp -datefmt "@d.@m.%Y" -pointsize 40x -color goldenrod1 -trans 40 -outfile "c:\pictures\stamped\@f" "c:\pictures\orig\*.jpg"

- wait until the program finishes. You'll find stamped photos in "c:\pictures\stamped\" directory.

Short explanation:
- datefmt : date format string (date helper page here)
- pointsize : size of the text; if followed by "x" (e.g. 40x) the size is relative
- color : self explanatory (all possible colors here - basically you can choose any 24 bit color)
- trans : set the transparency of text


More detailded userguide here. Of course you can choose the options however you like.


This is what you get with the above options:

SSH authentication using keys

First you have to create a key. Although using a password to further protect your key is not obligatory, I personally very much recommend using a password:

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): xxxxxxxxxxx
Enter same passphrase again: xxxxxxxxxxx
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx user@host


Then you have to upload your public key to the remote host:

$cat /home/user/.ssh/id_rsa.pub |ssh user@host "cat >> .ssh/authorized_keys"

Before you connect to the remote host, you can use the following command:

$ ssh-add
Enter passphrase for /home/user/.ssh/id_rsa:
Identity added: /home/user/.ssh/id_rsa (/home/user/.ssh/id_rsa)


This way you don't have to provide the password for your key each time you connect to the remote host.

Great page with some more very useful ssh tricks here.