Archive for ‘September, 2008’

SSH Tunneling to mysql server using Putty

datePosted on 12:55, September 25th, 2008 by Many Ayromlou

 I’ve had this question a couple of times in the past few months (since I posted the command line version of this method here ). To make it short and sweet, yes you can use Putty in a windows environment to setup ssh tunnels. Here is the specific scenario with pics for setting up a tunnel to your mysql server (assuming mysql server is running on a machine that you have ssh access to) using putty. This allows you to run mysql-gui-tools under windows and connect thru ssh to your server, without having to open the server to accept connections from the network.

  1. Download Putty full install package 
  2. Run putty and your’ll see the following screen. Fill in the hostname of the DB server and choose SSH as protocol.
  3. Go down to SSH and Tunnels options. Fill in 3306 for Source port, 127.0.0.1:3306 for local Destination port and click Add. This will forward (through SSH) all traffic sent to 127.0.0.1:3306 (aka. localhost:3306) to the remote host’s (DB Server) port 3306. You’ll see how this works in a second.
  4. Now go back to Sessions, Give the session a meaningful name (eg: MYSQLTunnel) and click Save so that it’s saved.

So now you’re done. If you need to access your mysql server, first run putty, load the session we just saved, connect and you’re good to go. You can use any network based mysql frontend and even the ODBC connector under windows and point them at host: 127.0.0.1 and port: 3306, the SSH tunnel will then take the traffic and safely transfer it to your mysql server box. This way you can run your mysql server in local mode — where it will not accept connections from outside network — for safety reasons and have network access to it when you need.

FFmpeg commands for ipod video encoding…

datePosted on 12:04, September 25th, 2008 by Many Ayromlou

So I found out the hard way that the new ipod’s (with video out) can actually play 640×480 video and also figured out how to get iTunes to accept the encoded files (so that I could sync them with the device)…….here is the run down:

  • “TV-Out” mode – 1.5Mbit/s 640×480 H.264 videos
    • BIT_RATE <= 1500 kbps
    • 640×480
    • Up to 30 fps
    • “Low-Complexity” H.264 Baseline Profile
    • 1 reference frame
    • Up to H.264 level 3
    • 640 pixels maximum frame width
    • Sample Aspect Ratio (SAR) must be 1:1
    • UUID atom must exist containing the following hex data: 6B 68 40 F2 5F 24 4F C5 BA 39 A5 1B CF 03 23 F3….This allows you to add the video into iTunes. You need AtomicParsley for this which can be checked out from their subversion repository . See below for usage.
  1. For 1-pass encoding use:
  2. ffmpeg -i INPUT -acodec libfaac -ab 128k -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me umh -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 10M -bufsize 10M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect WIDTH:HEIGHT OUTPUT.mp4AtomicParsley OUTPUT.mp4 --DeepScan --iPod-uuid 1200 --overWrite

  3. For 2-pass encoding use:
  4. ffmpeg -i INPUT -an -pass 1 -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions 0 -me epzs -subq 1 -trellis 0 -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 10M -bufsize 10M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect WIDTH:HEIGHT OUTPUT.mp4 ffmpeg -i INPUT -acodec libfaac -ab 128k -pass 2 -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me umh -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 10M -bufsize 10M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect WIDTH:HEIGHT OUTPUT.mp4AtomicParsley OUTPUT.mp4 --DeepScan --iPod-uuid 1200 --overWrite

  • “Standard” mode – 768kbit/s 320×240 H.264 videos
    • BIT_RATE <= 768 kbps
    • 320×240
    • Up to 30 fps
    • H.264 Baseline Profile up to level 1.3
  1. For 1-pass encoding use:
  2. ffmpeg -i INPUT -acodec libfaac -ab 128k -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me umh -subq 5 -trellis 1 -refs 5 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 768k -bufsize 2M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -title SOME_TITLE OUTPUT.mp4

  3. For 2-pass encoding use:
  4. ffmpeg -i INPUT -an -pass 1 -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions 0 -me epzs -subq 1 -trellis 0 -refs 1 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 768k -bufsize 2M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -title SOME_TITLE OUTPUT.mp4 ffmpeg -i INPUT -acodec libfaac -ab 128k -pass 2 -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me umh -subq 5 -trellis 1 -refs 5 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 768k -bufsize 2M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -title SOME_TITLE OUTPUT.mp4

      ffmpeg command line quickies…..

      datePosted on 11:05, September 25th, 2008 by Many Ayromlou

      Here are a bunch of ffmpeg command lines that will do just about everything you need.

      1. Getting info from a video file
      2. ffmpeg -i video.avi

      3. Turn a sequence of images into video
      4. ffmpeg -f image2 -i image%d.jpg video.mpg

      5. Turn a video into a sequence of images
      6. ffmpeg -i video.mpg image%d.jpg

      7. Encode video for Ipod/IPhone
      8. ffmpeg -i source_video_file.avi -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv -trell 1 -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X output_file.mp4

      9. Encode video for PSP
      10. ffmpeg -i source_video_file.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac output_file.mp4ORffmpeg -i "OriginalFile.avi" -f psp -r 29.97 -b 768k -ar 24000 -ab 64k -s 320x240 "OutputFile.mp4"

      11. Extract audio from a video file and save it as mp3 format
      12. ffmpeg -i source_video_file.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 output_file.mp3

      13. Convert a wave file to mp3
      14. ffmpeg -i original_audio_file.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 output_file.mp3

      15. Convert a avi video to mpeg
      16. ffmpeg -i original_movie.avi output_file.mpg

      17. Convert a mpeg video to avi
      18. ffmpeg -i original_movie.mpg output_file.avi

      19. Convert a avi video to uncompressed animated gif
      20. ffmpeg -i original_movie.avi output_file.gif

      21. Add audio to an existing video-only file (mix audio and video)
      22. ffmpeg -i son.wav -i original_movie.avi output_file.mpg

      23. Convert a avi video to flv (flash video)
      24. ffmpeg -i original_movie.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv output_file.flv

      25. Convert a flv video to mpeg
      26. ffmpeg -i myFile.flv -ab 56 -ar 22050 -b 500 -s 320x240 myFile.mpg

      27. Convert a avi video to dv
      28. ffmpeg -i original_movie.avi -s ntsc -r ntsc -aspect 4:3 -ar 48000 -ac 2 output_file.dvORffmpeg -i original_movie.avi -target ntsc-dv output_file.dv

      29. Convert a avi video to mpeg specifically for DVD creation
      30. ffmpeg -i source_video.avi -target ntsc-dvd -ps 2000000000 -aspect 16:9 finale_video.mpeg

      31. Compress a avi video to Divx
      32. ffmpeg -i original_movie.avi -s 320x240 -vcodec msmpeg4v2 output_file.avi

      33. Convert a Ogg Theora video to mpeg specifically for DVD creation
      34. ffmpeg -i original_movie.ogm -s 720x576 -vcodec mpeg2video -acodec mp3 output_file.mpg

      35. Convert a avi video to mpeg2 for SVCD creation
      36. ffmpeg -i original_movie.avi -target ntsc-svcd output_file.mpg

      37. Convert a avi video to mpeg2 for VCD creation
      38. ffmpeg -i original_movie.avi -target ntsc-vcd output_file.mpg

      Speed up Mac OS X Mail application…..

      datePosted on 17:07, September 22nd, 2008 by Many Ayromlou

      Does your OSX Mail app crawl when you start it. Well here is a quick tip to speed things up again. Just issue this command from a terminal window (make sure you’re not running Mail app first).

      sqlite3 ~/Library/Mail/Envelope\ Index vacuum;
      You should notice a bit of a performance improvement the next time you start the Mail application. This only works for the OSX mail.app, not other mail applications.

      How to make a ISO out of a DMG file under OSX

      datePosted on 17:01, September 22nd, 2008 by Many Ayromlou

      Here is a quick command line for all you OSX ppl. If you’re ever in need of turning/converting a .dmg file into a .iso use the following command line:

      hdiutil makehybrid -iso -o newfile.iso yourfilename.dmg

      Where newfile is the name of the iso you want, and yourfilename.dmg is the dmg. Have Fun……

      How to mount CD/DVD images from command line under Linux

      datePosted on 16:45, September 22nd, 2008 by Many Ayromlou

      Here are some quick CLI commands to get those CD/DVD images mounted under Linux (without having to burn them first).

      # ISO
      mount -t iso9660 -o loop,user file.iso /path/mount_directory

      # MDF
      mount imagen.mdf /path/mount_directory -o loop=/dev/loop0

      # NRG
      mount -o loop,offset=307200 imagen.nrg /path/mount_directory

      Basic APT commands

      datePosted on 16:37, September 22nd, 2008 by Many Ayromlou

      Okay, now for a bit of CLI goodness. Here is a quick list of basic apt commands.  Debian and most derivatives (Ubuntu) use these for package maintenance.
      #search
      apt-cache search packagename

      #package info
      apt-cache show packagename

      #clean
      sudo apt-get clean
      sudo apt-get autoclean #old packages

      #check
      apt-get check

      #get source code
      apt-get source packagename

      #get dep
      apt-get build-dep packagename

      #update/install/remove/upgrade
      sudo apt-get update
      sudo apt-get install packagename
      sudo apt-get remove packagename
      sudo apt-get upgrade
      sudo apt-get dist-upgrade

      Eject your Mac’s CD tray from command line……

      datePosted on 12:53, September 22nd, 2008 by Many Ayromlou

      Yeah I know what you’re thinking…..who the heck would need that. Well since mac’s don’t have a physical CD eject button on the front plate (ie: eject is done by eject key), if you ever need to put a CD/DVD into a machine without keyboard (server machine and/or if you’re using teleport to share a keyboard/mouse) you’re in trouble. It turns out those Apple geniuses knew about this and gave you a way out…..just open up a terminal (or ssh to your server) and type the following command:
      drutil eject

      FunctionFlip frees your mac’s function keys…..

      datePosted on 16:11, September 21st, 2008 by Many Ayromlou

      When I bought my Macbook Pro the first thing I noticed was that the function keys didn’t “function” like those on my Powerbook. With all the new expose and spaces functions, you had to decide if you wanted the old style keys (ie: press F5 to increase volume and press Fn-F5 to get whatever was assigned to F5) or the new style (ie: pressing F5 by itself gets you whatever action is assigned to F5 — which btw is nothing — but pressing Fn-F5 will increase the volume). Well FunctionFlip lets you have your cake and eat it too. It turns the Function keys into Hybrid keys. You dicide what the primary function is and what the Fn-Fx function (if any) is. Free and OSX only. Here is a quick run through once you get the control panel installed (just double click it).

      1) You choose the layout of keys on your Mac by choosing the function that’s printed on F6 and F8 key on your keyboard.
      2) Then on the right hand pane you decide which keys you want to Flip. When you flip a key you make it perform the function printed on the key itself. In my case I like to have F1 and F2 control brightness settings without having to use Fn key with them, but I like to keep my F8-F10 for expose features.

      Disruptive Tech: Canon 5D MKII to shake up the DCinema Scene….

      datePosted on 15:27, September 21st, 2008 by Many Ayromlou

      When Canon announced their new 5D MKII DSLR Camera everyone was wowed by the 21MP sensor and all the other new goodies. What everyone has missed/neglected is the fact that this little beauty has the potential to become the new RED Camera. You see, with it’s 2K video output (1080P) in quicktime RAW format at 30 fps and superb low-light performance, Canon has created a dynamite hybrid camera for the photo jounalists (or anyone who doesn’t want to spend 20-30K on a RED camera). Vincent Laforet has done a very in depth review of this camera’s video capabilities on his blog (video is upcoming). To quote Vincent:

      It produces the best video in low light that I’ve ever seen – at 1080p. A top commercial film editor who who regularly edits RED camera footage – and has seen the raw footage from the 5D MKII – says the 5D MKII is “far superior to the RED camera” in terms of low light performance…

      We’re talking about a $2700 camera that can take the entire range of 35mm lenses offered by Canon (and now Zeiss as well), will shoot 2K RAW video in CF card (which is quicktime and hence drop-ready for Final Cut Pro). I think it’s time to get excited….start saving now :-)

      12Next