Wednesday, January 17, 2007
Sunday, December 17, 2006
Put Youtube video to ipod using ffmpeg
However, I have developed a fondness for ffmpeg through my previous effort of making movies from still images. In addition, I found out that a lot of the existing video authoring programs are actually derivatives of ffmpeg. With a little googling around, I found this page - Converting video to play on your iPod with FFmpeg. After messing around different options, I finally settle with this command line:
I download flash videos using firefox videodownloader extension. All the downloaded video dimensions are 320x240, so no more fiddling is needed. It seems that people often misinterpret the -maxrate option. The correct meaning of it is maximum bitrate tolerance, so the output bitrate is usually dictated by the input bitrate since we don't want too much deviation.
If you are a fetish Java user, try this code to pool all the videos into a folder and convert them all at onece
import java.io.*;
import java.util.Arrays;
import java.util.Comparator;
/**
* Convert the flv video files into ipod video files using ffmpeg.
* Usage:
* java itube [source_path] [prefix] [number_of_files]
*
* @author yctan
*
*/
public class itube {
public static class AlphabeticComparator implements Comparator {
public int compare(Object o1, Object o2) {
String s1 = (String)o1;
String s2 = (String)o2;
return s1.toLowerCase().compareTo(s2.toLowerCase());
}
}
public static void main(String[] args) {
File path;
String[] list;
if(args.length == 0)
path = new File(".");
else
path = new File(args[0]);
list = path.list();
if(list == null) {
System.err.println("File not found.");
System.exit(1);
}
Arrays.sort(list, new AlphabeticComparator());
String prefix = null;
if(args.length > 1) prefix = args[1];
int nfiles = list.length;
if(args.length == 3)
nfiles = Integer.parseInt(args[2]);
try {
PrintWriter logfile = new PrintWriter(new BufferedWriter(new FileWriter("itube.log")));
for(int i = 0; i < nfiles; i++) {
int dot = list[i].lastIndexOf('.');
if(dot==-1 || !list[i].substring(dot+1,list[i].length()).equals("flv")) continue;
String cmd = "ffmpeg -i " + path.getPath() + '/' + list[i];
cmd += " -f mp4 -maxrate 1000 -b 300 -qmin 3 -qmax 5";
cmd += " -bufsize 4096 -g 300 -vcodec mpeg4 -acodec aac ";
if(prefix!=null) cmd += prefix + '-';
cmd += list[i].substring(0, list[i].lastIndexOf('.'));
cmd += ".mp4";
// System.out.println(cmd);
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(cmd);
InputStream stderr = proc.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
logfile.println("Converting " + list[i] + " ... ");
while((line = br.readLine()) != null)
logfile.println(line);
logfile.println("Done.");
int exitVal = proc.waitFor();
logfile.println("Process exitValue: " + exitVal);
}
logfile.close();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Wednesday, December 06, 2006
Convert RMVB to iPod Video
- Download MPlayer 1.0rc1 Windows and grab "windows-all-20061022.zip" from codecs directory.
- Unzip both of them into the same directory. Let's say, C:\mplayer.
- Assume you want to convert "Cars.rmvb" and it is in "C:\Documents and Settings\All Users\Documents\". Open Notepad to type the following textbox as a single line and save the file as "encode.bat".
- Double click "encode.bat" to execute it. "Cars.mp4" will be created. Use iTune or gtkpod (on your linux machine) to transfer the mp4 into ipod :-)
"encode.bat"
The first thing we should keep in mind is the video ipod limitation. From ipod specs, we can immediately learn that the allowed video formats are H.264 and MPEG-4, and the allowed audio codec is AAC. For MPEG-4, the pixel limit is 640x480 and the max. frame rate is 30 fps. As a result, "vcodec=mpeg4" and "acodec=aac" are used.
Of course, we also need to understand the command line of mencoder to successfully convert every given RMVB file. The listed command line in "encode.bat" is very similar to Encoding to Sony PSP video format from the mencoder documentation. We'd better have this documentation ready to explain every parameter that can be used.
Another crucial element is understanding the video source - video bit rate, fps, and aspect ratio. Read video info using either Real Player or Real Alternative. For example, the source Cars.rmvb has these properties
- Avg Stream Bit Rate: 996.9 Kbps
- Dimensions: 800x452
- Encoded Frame Rate: 24.0 fps
- vbitrate=800 to sacrifice a little bit quality to control the output file size, I certainly don't think there is any benefit to use bit rate larger than 996.9 Kbps.
- -ofps 24.0 to match the output frame rate. Otherwise, mencoder will keep complaining skipped frames.
- -vf scale=640:362 to keep the correct aspect ratio and shrink the pixel size (remember the ipod limitation).
Monday, December 04, 2006
Black Forest Delight
How-to: Bake devil's food cake mix. Dissolve cherry gelatin and pour into cake layers. Mix sour cream and powdered sugar and stir in whip cream. Spread whipped topping mixture and cherries on the first cake layer. Place second cake layer on the first cake layer. Frost with remaining whipped topping mixture. Drizzle chocolate on the top. Garnish with cherries. Yummy.
Monday, June 26, 2006
Saturday, December 31, 2005
Make Mouse Scroll Wheel Work

I just made my PS/2 mouse scroll wheel work again in SUSE Linux 10.0. Who would have thought the correct protocol name should be imps/2? The protocol change does not take effect until the system is restarted, so the testing immediately after the switch is meaningless. Despite all the wonderful features in the latest SUSE Linux version, there are still some quirks I have picked up so far.
- My 16X DVD-ROM drive is treated as a CD-ROM drive such that no DVD can be read. I need to painfully do a switcheroo with a Plextor DVD drive during the initial system setup.
- By switching the USB and PS/2 mice after the initial system setup, I lost the correct setup for the PS/2 mouse. Hence I endured the annoyance of the loss of scroll wheel function until I figured out what protocol I need to choose.
- A sudden loss of OpenGL function due to some incompatible system packages (although I never figured out the real cause). The solution is to re-install the Nvidia video driver.
- Eclipse (3.1 and 3.2) will somehow become unstable and finally cannot start on the 64 bit JVM provided by SUSE, but it manages to work under the latest JVM 1.5.0 update 6 directly from Sun.
Monday, November 28, 2005
Give Me a Break
Michael Scofield and his team are going to break out of Fox River State Penitentiary tonight :-)
On November 18, my new computer ceased to work after being assembled merely three weeks earlier. Without understanding the true cause of the breakdown, I placed the blame on the mother board - Epox 9NDA3J nForce3. I regretted the premature disposal of the packaging boxes because by doing so I cannot refund the defected items from NewEgg.com. Desperately I bought another mother board - Gigabyte Uli 1689 from NewEgg, and it should arrive today. The temperature rises to a near-term peak today. And I will be assembling my new computer tonight ...
My last blog - trip to Yellowstone - is heavily spammed in addition to my mailbox. I don't exactly know how the spammers benefit from commenting my blog entry and placing a link back to their web sites. Are they trying to raise the Google ranking of their own web sites?
XBox 360 started selling on November 22, which is right before the Thanksgiving shopping craze. But rumor has it - PS3 will be sold with Linux pre-installed. Very sweet. With all the hype on HD gaming, yesterday I installed, DOSBox, a MS-DOS emulation program such that my Mom can play Lode Runner, a pre-historic yet extremely fun game. And that's what a brilliant video game should have, an innovative gameplay instead of only pretty high resolution.
Saturday, August 06, 2005
Yellowstone trip

Long time no blog until I found out my wife posted an excellent blog about our Yellowstone trip. I am just too lazy writing up a long and exhaustive memento. It was a pretty nice trip in the hot summer of 2005.
Thursday, June 09, 2005
Poa Annua
These things popped up in my lawn since about two weeks ago. Their appearances really get on my nerves, and it will be tough to wage a war against them. I contacted Scotts Lawn Service to have a free lawn analysis. Hopefully they can suggest something useful but not too costly.
Based on what I have read so far, I guess I made mistakes in not doing some prevention work in early spring and then mowing the lawn too short. I will try to stop mowing my lawn for a while and apply Ortho Grass-B-Gon Garden Grass Killer. I will also consider mowing with bagger to collect the seeds of them.
$%@x#!, I really hate my lawn!
Friday, May 27, 2005
BigKid : Xbox 360 vs PS3
Monday, May 23, 2005
Dantzig's obituary
Posted by timothy on Sunday May 22, @10:00PM
from the life-well-lived dept.
Markus Registrada writes "George Dantzig, the inventor of the Simplex method for solving Linear Programming problems, died on May 13. He was also the now-legendary student who turned in solutions for what he had taken to be a homework assignment, only to find out they had been posted as examples of what were suspected to be unsolvable problems."
Friday, April 08, 2005
Plextor 716A DVD burner
Friday, April 01, 2005
Google Maps
Thursday, March 31, 2005
Matrix Toolkits for Java
Friday, March 18, 2005
Frequently Unanswered Questions
Monday, March 07, 2005
I just increased my swap space with a swap file
/sbin/swapon -s
Filename Type Size Used Priority
/dev/hda5 partition 1044184 0 -1
df -m
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/hda7 372 81 272 23% /
/dev/hda2 46 10 34 22% /boot
/dev/hda6 9705 2325 6887 26% /home
none 251 0 250 0% /dev/shm
/dev/hda3 26537 2113 23076 9% /usr
/dev/hda8 251 64 173 27% /var
su
dd if=/dev/zero of=/usr/extraswap bs=1M count=1024
/sbin/mkswap /usr/extraswap
Setting up swapspace version 1, size = 1048572 KiB
/sbin/swapon /usr/extraswap
/sbin/swapon -s
Filename Type Size Used Priority
/dev/hda5 partition 1044184 0 -1
/usr/extraswap file 1048568 0 -2
cp /etc/fstab /etc/fstab.mybackup
emacs /etc/fstab&
diff /etc/fstab /etc/fstab.mybackup
10d9
< /usr/extraswap none swap sw 0 0
Saturday, March 05, 2005
Eclipse
The interface is of motif theme that seems outdated, but, again, it is a HP-UX version. I will need a windows version for a fair comparison. The perspective, in my opinion, is a pretty good idea. It let you switch around different arrangements of the panels for each specific task. Switching over from JBuilder is not easy since it also has many merits and I am very accustomed to it. I will explore other notable features of Eclipse after I have accumulated more play time.
Friday, March 04, 2005
The Dow Jones Expensive Merlot Index
By DOROTHY J. GAITER AND JOHN BRECHER
In a broad tasting of American Merlots that cost $20 to $50, mostly from the 2001 vintage, these were our favorites. While most inexpensive Merlots are meant to be drunk immediately, many better Merlots, including these, will age beautifully for some years. These pair well with steak and similarly serious foods.
| Vineyard/Vintage | Price | Rating | Tasters' Comments |
| Duckhorn Vineyards 2002 (Napa Valley) | $49.99 | Delicious | Best of tasting. Intense, dark and rich, with herbs, earth and cedar -- all in a package that's so sensual it's like blackberry chocolate fondue. Very young. |
| Sarah's Vineyard 'Besson Vineyard' 2001 (Santa Clara Valley) | $20.00 | Very Good | Best value. Lighter than some, with more obvious fruit flavors. It tastes like great grapes, left alone to taste good -- fruity yet not at all sweet. Very pleasant. |
| Steltzner Vineyards 2001 (Stags Leap District, Napa Valley) | $24.98 | Very Good/Delicious | A deep, complex wine, with a sense of place and plenty of layers. Slightly herbal and nicely tight, with such great acids it demands a big meal. |
| Corte Riva Vineyards 2002 (Napa Valley) | $44.99 | Very Good | Hefty, with great body and structure, some herbs and plenty of earth. Blackberries and cream. A real mouthful of wine. |
| Groth Vineyards & Winery 2001 (Napa Valley) | $34.99* | Very Good | Elegant, with Bordeaux-like structure and a long, dry finish. Could age for a long time. |
| Joseph Phelps Vineyards 2001 (Napa Valley) | $38.99 | Very Good | Smells like chocolate, blackberries and rich soil, with some nice hints of herbs, too. Tight and nicely earthy. |
| Larkmead Vineyards 2001 (Napa Valley) | $36.00* | Very Good | Very serious wine, with hints of black tea and soil. Have it with roast meat. |
| Matanzas Creek Winery 2001 (Sonoma County) | $29.95 | Very Good | It looks and even tastes dark, with hints of tobacco and coffee and a kind of leathery toughness. Classy wine. |
| Provenance Vineyards 2001 (Carneros, Napa Valley) | $26.95 | Very Good | Grapey and pleasant, with some spice and cream, a dark core and nicely dry finish. |
| Rombauer Vineyards 2001 (Napa Valley) | $25.95 | Very Good | Very pleasant, plum-like fruit and terrific acids for food. Quite complete. More forward and easier to drink than some. |
NOTE: Wines are rated on a scale that ranges: Yech, OK, Good, Very Good, Delicious, and Delicious! These came from California, Florida and New York. *We paid $36.95 for the Groth and $29.97 for the Larkmead, but these prices appear to be more representative. Prices vary widely.
Thursday, March 03, 2005
4 8 15 16 23 42
Episode 18 - Numbers
4 8 15 16 23 42
I am tired of guessing. The facts that interest me are
- The flight number of their crashed plane is 815
- Someone has already registered the domain name http://www.4815162342.com
Episode 19 - Deus Ex Machina (Latin for "God from the machine"). This episode will center on Locke (BTW, John Locke is the name of a English philosopher). The title is so tantilizing that ABC is going to make us wait for a LONG LONG time (April 13 according to TV Tome). Some quick notes are:
- Deus Ex Machina refers to an implausible ending where everything is solved and justice is served.
- The episode title is also similar to the title of Chapter 48 of Watership Down "Dea ex Machina." (Watership Down is the book that Sawyer was reading that came from Boone's suitcase).
Facts provided by TV Tome
Sunday, February 20, 2005
A small form factor PC
-
Put Any YouTube Video On Your iPod is a good source for expanding the video library on the wonderful video iPod. A Beginner's Guide to ...
-
There are a number of things are newsworthy. Michael Scofield and his team are going to break out of Fox River State Penitentiary tonight :...
-
It seems nowadays a great number of geeks could take the Linux kernel and bundle it with different flavors of software and make their own di...
