Saturday, June 6, 2009

splitting a video file using mencoder

Just got asked from a friend to do video cutting, just to fetch the video and mp3 for portion of time 01:07:26 to 01:09:49

Here's what i did after after googling around for some great resources.

To get the range-cutted video, we need to do a two-steps process :

mencoder -endpos 01:09:49 -ovc copy -oac copy in.avi -o out.avi

in.avi is the original avi file
out.avi is the cutted avi file, starting from the beginning to 01:09:49 (hh:mm:ss) of in.avi

mencoder -ss 01:07:26 -oac copy -ovc copy out.avi -o out2.avi

out.avi is the output of the previous step
out2.avi is the final avi file, starting from 01:07:26 (hh:mm:ss) of out.avi till the end of it

Now, the last part, is to extract audio from the cutted video clip

mencoder out2.avi -of rawaudio -oac mp3lame -ovc copy -o file.mp3

The outputs are, out2.avi for the video and file.mp3, the audio extracted from out2.avi

Friday, May 29, 2009

The Lawyer and the Chinese

A lawyer and and a Chinese are sitting next to each other on a long flight.

The lawyer is thinking that all Chinese are so dumb that he could get over on them, easy.
So the lawyer asks if the Chinese would like to play a fun game.

The Chinese is tired and just wants to take a nap, so he politely declines, and tries to catch a few winks.
The lawyer persists, and says that the game is a lot of fun.
I ask you a question, and if you don't know the answer, you pay me only $5; you ask me one,
and if I don't know the answer, I will pay you $500, he says.
This catches the Chinese's attention and to keep the lawyer quiet, he agrees to play the game.

The lawyer asks the first question. 'What's the distance from The Earth to the Moon?'
The Chinese doesn't say a word, reaches in his pocket, pulls out a five-dollar bill, and hands it to the lawyer.

Now, it's the Chinese's turn. He asks the lawyer, 'What goes up a hill with three legs, and comes down with four?'
The lawyer uses his laptop and searches all references he could find on the Net.
He sends e-mails to all the smart friends he knows, all to no avail.
After one hour of searching he finally gives up.

He wakes up the Chinese and hands him $500. The Chinese pockets the $500 and goes right back to sleep.
The lawyer is going nuts not knowing the answer.
He wakes the Chinese up and asks, 'Well, so what goes up a hill with three legs and comes down with four?'
The Chinese reaches in his pocket, hands the lawyer $5 and goes back to sleep. Don't mess with Chinese.

Monday, October 27, 2008

From AVI to DVD Video

So, here i am, stucked with several avi files, and i need to burn these files as DVD videos for my parent's friends. And i've never before done this kind of thing on a linux pc.

After doing some research, here are the steps i took to make this work :

1. Convertion from AVI files to MPEG files
We need to convert the AVI files to MPEG files, and i use mplayer for this. Here's my example script of (NOTE : please aware that the vcodec parameter is too long for a good view, so i truncate it into several lines. So the lines ending with 4016: actually continues to keyint=12 without a new line, and line that ends with cbp: continues to mv0: without a new line)

mencoder -of mpeg -mpegopts format=dvd:tsaf -ovc lavc -oac lavc -vf harddup -srate 48000 -af lavcresample=48000 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:vbitrate=4016:
mv0:vqmin=1:lmin=1:dc=10:acodec=ac3:abitrate=192 -ofps 30000/1001 $1.avi -o $1.mpeg

So in my case i would do this command for my opening.avi file to get an output file of opening.mpeg

$ ./ opening

The output of this step is MPEG file[s]

2. Make a DVD filesystem
In this step i use the dvdauthor software to achieve this. Here's an example script of mine ( :

dvdauthor -o dvd/ -T
dvdauthor -o dvd/ $1.mpeg
dvdauthor -o dvd/ -T

If you want to split the mpeg file into chapters every 15 minutes, we can modify the script into this (my video is only 2 hours duration, so it ends with 2:00:00):

dvdauthor -o dvd/ -T
dvdauthor -o dvd/ -t -c 0:00:00,0:15:00,0:30:00,0:45:00,1:00:00,1:15:00,1:30:00,1:45:00,2:00:00 $1.mpeg
dvdauthor -o dvd/ -T

Here's an example of command i'd issue for my opening.mpeg :

$ ./ opening

Wait a minute ! What if i have several mpeg files and would like to make them into one DVD filesystem ?
Dont worry ! In this case, you should make an XML file like this :

<vmgm />
<vob file="myfile1.mpeg"
<vob file="myfile2.mpeg"

And then to make a DVD filesystem based on this XML file with the command :

$ dvdauthor -o dvd -x input.xml

The output of this step is a directory named dvd that contains the DVD filesystem

3. Make a DVD ISO image
Okay, now i have the dvd directory, ready to be made into a burnable DVD ISO image. All i have to do is this :

$ genisoimage -dvd-video -v -o mymovie.iso dvd

The output of this step is a DVD ISO image.

4. Play the DVD ISO image
This step is optional, but i like making sure of things before burning it onto a DVD-R. In this step, i just need to issue this command :

$ mplayer dvd://1 -dvd-device mymovie.iso

If i want to play specific chapters that i've made during step 2, i'd use this command :

$ mplayer dvd://1 -chapter 2 -dvd-device mymovie.iso

5. Burn the DVD ISO image
Okay, you've tested the ISO file and everything is like you wanted. Now you can proceed to burn the DVD ISO image. I use K3b for this. Just fire the application, choose from menu, Tools -> Burn DVD ISO Image

References that help me achieve this :

Monday, October 13, 2008

Burning DAT VCD File

I'm in a situation where i need to burn a .DAT file that was copied from a VCD disc.
Looking around inside K3b, and found no tools for that.

After googling around, i found out about the usage of a tool package called vcdgear.
But havent tried that tool, because after reading more at the search results, i found out a very user friendly tool called devede.

Fired up my SuSE YaST -> Softare Management -> search for devede, and installed it successfully !

The proggie is quite user friendly. It can even convert the DAT file to a ready-to-be-burned cue and bin files. So what i did is add a new file, choose the DAT file, and click forward to start the conversion process. After that i'd just burn the output image file using K3b from the Tools menu -> Burn CD Image, and then selecting the cue file.

Creating DVD or CD ISO file

To create a DVD ISO, one can use this command at shell (i'm using bash)
dd if=/dev/dvd of=/mydir/myDVDImage.iso

Or to create a CD ISO, one can use this command
dd if=/dev/cdrom of=/mydir/myCDImage.iso

Or if one prefers a friendly GUI tool, i suggest K3B burning tool. Click on menu Tools -> Copy DVD / Copy CD. And dont forget to check the "Create Image Only" checkbox before start copying the DVD or the CD. Notice the directory too that will hold the output image file in the burn window dialog.

Saturday, July 12, 2008

Tux4Kids !

Just found a bunch of softwares for kids to learn about math, drawing creativity, etc, and best of all, these softwares are free and available for many platforms like windows operating system, linux ,etc.

Here's a screenshot of tux math, and you can download it from the download page.

And here's the homepage for tux paint :-)

Monday, June 23, 2008

The Greatests

The greatest achievement is selflessness.
The greatest worth is self-mastery.
The greatest quality is seeking to serve others.
The greatest precept is continual awareness.
The greatest medicine is the emptiness of everything.
The greatest action is not conforming with the worlds ways.
The greatest magic is transmuting the passions.
The greatest generosity is non-attachment.
The greatest goodness is a peaceful mind.
The greatest patience is humility.
The greatest effort is not concerned with results.
The greatest meditation is a mind that lets go.
The greatest wisdom is seeing through appearances.