Wednesday, October 15, 2008
pasting vob's together
Wednesday, September 24, 2008
Ubuntu - Google Toolbar
sudo apt-get install libxul-dev libstdc++5 gcc-4.1 libstdc++6
2. delete your ~/.mozilla folder
3. restart
4. install google toolbar
Wednesday, July 23, 2008
jenn encoding 2
Thursday, May 29, 2008
dual-monitor xorg.conf with rotation
Here is my xorg.conf file:
# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings: version 1.0 (buildd@vernadsky) Tue Mar 4 20:24:34 UTC 2008
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" 0 0
Screen 1 "Screen1" 1920 0
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
EndSection
Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
EndSection
Section "Module"
Load "dbe"
Load "extmod"
Load "type1"
Load "freetype"
Load "glx"
EndSection
Section "ServerFlags"
Option "Xinerama" "1"
EndSection
Section "InputDevice"
# generated from default
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/psaux"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
EndSection
Section "InputDevice"
# generated from default
Identifier "Keyboard0"
Driver "kbd"
EndSection
Section "Monitor"
# HorizSync source: edid, VertRefresh source: edid
Identifier "Monitor0"
VendorName "Unknown"
ModelName "DELL 2405FPW"
HorizSync 30.0 - 81.0
VertRefresh 56.0 - 76.0
Option "DPMS"
EndSection
Section "Monitor"
# HorizSync source: edid, VertRefresh source: edid
Identifier "Monitor1"
VendorName "Unknown"
ModelName "DELL 2005FPW"
HorizSync 30.0 - 83.0
VertRefresh 56.0 - 75.0
Option "DPMS"
Option "RandRRotation" "on"
Option "Rotate" "CCW"
EndSection
Section "Device"
Identifier "Videocard0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "GeForce 8800 GTS"
BusID "PCI:1:0:0"
Screen 0
EndSection
Section "Device"
Identifier "Videocard1"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "GeForce 8800 GTS"
BusID "PCI:1:0:0"
Screen 1
EndSection
Section "Screen"
Identifier "Screen0"
Device "Videocard0"
Monitor "Monitor0"
DefaultDepth 24
Option "TwinView" "0"
Option "metamodes" "DFP-1: 1920x1200 +0+0; DFP-1: 800x600 +0+0; DFP-1: 640x480 +0+0"
SubSection "Display"
Depth 24
EndSubSection
EndSection
Section "Screen"
Identifier "Screen1"
Device "Videocard1"
Monitor "Monitor1"
DefaultDepth 24
Option "TwinView" "0"
Option "metamodes" "DFP-0: 1680x1050 +0+0"
SubSection "Display"
Depth 24
EndSubSection
EndSection
Thursday, May 22, 2008
jenn-caves
mencoder s01e04\ -\ Caves.avi -ss 00:37:56 -endpos 00:01:23 -oac copy -ovc copy -o temp.avi
Monday, May 19, 2008
Ubuntu Hardy Heron - ZODB
1. sudo apt-get install build-essential
2. sudo apt-get install python-dev
3. sudo apt-get isntall python-setuptools
4. sudo easy_install ZODB3
Sunday, May 18, 2008
ubuntu - hardy heron - pulseaudio
1. It seems the alsa 5.1 channels are all muted, for whatever reason. Since pulseaudio just sits on top of alsa that means 5.1 sound appears not to work. Just use the mixer and put all the channels up full in alsa.
2. Flash on firefox still won't work because you need to:
sudo apt-get install libflashsupport
This library does something to enable the sound to work.
3. set everything alsa to use pulse by adding the following to ~/.asoundrc
pcm.pulse {
type pulse
}
ctl.pulse {
type pulse
}
pcm.!default {
type pulse
}
ctl.!default {
type pulse
}
Why they made pulseaudio the default, firefox the default, and didn't include this library is beyond me...
4. they make pulseaudio the default, but don't include the tools. interesting. run this and install all the configurations and tools for pulseaudio:
sudo apt-get install libasound2-plugins "pulseaudio-*" paman padevchooser paprefs pavucontrol pavumeter
Monday, May 12, 2008
Special Keyboard or Remote Keys and Binding
1. xev - This command will open a window and print the keycode for whatever key you press. For my new remote I press the key with a "<-" on it and I get this:
KeyPress event, serial 28, synthetic NO, window 0x1c00001,2. vi ~/.xmodmap - create this file if it doesn't exist and use it to add your new keys. I want the back button to be the "escape" key, as that exits and/or backs up a menu level. so I open .xmodmap and type something like:
root 0x13b, subw 0x0, time 113488598, (381,88), root:(388,139),
state 0x10, keycode 234 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
keycode 234 = Escape3. xmodmap ~/.xmodmap - this will add my new key binding to the map and immediately should start working.
Add this to start-up if you want it to always load on boot.
Wednesday, March 12, 2008
Monday, March 10, 2008
desktop .mplayer/config
channels=6
monitoraspect=16:9
stop-xscreensaver=yes
ontop=yes
alang=en
ao=pulse
zoom=yes
mediacenter .mplayer/config
channels=6
monitoraspect=16:9
stop-xscreensaver=yes
ontop=yes
fs=yes
alang=en
ao=alsa:device=plug=test
mixer-channel="SoftVol"
#ao="oss:/dev/dsp"
# channels 6 (# of channels) : 3 (# of paths) : 4 (audio chann) : 2 (speaker)
# 0-left front, 1- right front, 2- center
#
#sound channels
#0 - Front Left
#4 - Center
#1 - Front Right
#3 - Rear Right
#2 - Rear Left
#5 - LFE
#
#af="channels=6:3:0:0:1:1:4:2","channels=2"
zoom=yes
vf=scale=1920:1080
mediacenter .asoundrc
type dmix
ipc_key 1024
ipc_key_add_uid false
ipc_perm 0666
slave {
pcm "hw:0,0"
channels 6
period_time 0
period_size 1024
buffer_size 8192
rate 48000
}
}
ctl.dmix51 {
type hw
card 0
}
pcm.stereo {
type plug
slave.pcm "dmix51"
ttable.0.0 1
ttable.1.1 1
}
pcm.!default {
type route
slave.pcm "dmix51"
slave.channels 6
ttable.0.0 1
ttable.1.1 1
ttable.4.2 1
ttable.3.1 1
ttable.2.0 1
ttable.5.5 1
}
pcm.duplicate {
type plug
slave.pcm "dmix51"
slave.channels 6
route_policy duplicate
}
pcm.test {
type softvol
slave {
pcm surround71
}
control {
name "SoftVol"
card 0
}
}
#upmixing:
pcm.ch51dup {
type route
slave.pcm test
slave.channels 6
ttable.0.0 1
ttable.1.1 1
ttable.0.2 1
ttable.1.3 1
ttable.0.4 0.5
ttable.1.4 0.5
ttable.0.5 0.5
ttable.1.5 0.5
}
Desktop .asoundrc
# type plug
# slave.pcm "surround51"
# slave.channels 6
#}
pcm.dmix51 {
type dmix
ipc_key 1024
slave {
pcm "hw:0,0"
channels 6
period_time 0
period_size 1024
buffer_size 8192
rate 48000
}
}
ctl.dmix51 {
type hw
card 0
}
#pcm.!default {
# type dmix
# ipc_key 1024
# slave {
# pcm "hw:0,0"
# channels 6
# period_time 0
# period_size 1024
# buffer_size 8192
# rate 48000
# }
#}
pcm.!default {
type plug
slave.pcm "dmix51"
}
pcm.dsp0 {
type plug
slave.pcm "dmix51"
}
#upmixing:
pcm.ch51dup {
type route
slave.pcm "dmix51"
slave.channels 6
ttable.0.0 1
ttable.1.1 1
ttable.0.2 1
ttable.1.3 1
ttable.0.4 0.5
ttable.1.4 0.5
ttable.0.5 0.5
ttable.1.5 0.5
}
Encoding dvd movies with mencoder and x264, fixing sync issues
mkfifo audiodump.pcm
mencoder dvd://1 -oac copy -ovc copy -ofps 24000/1001 -vf pullup,softskip,harddup -aid 128 -channels 6 -o movie.vob
faac -q 100 -I 1,6 -P -R 48000 -C 6 -X audiodump.pcm -o audio.mp4 & mplayer movie.vob -vc dummy -vo null -ao pcm:nowaveheader:fast -channels 6
mencoder movie.vob -o /dev/null -ofps 24000/1001 -vf crop=720:352:0:62,harddup -ovc x264 -x264encopts bitrate=1800:frameref=6:analyse=all:me=umh:subme=7:trellis=2:bframes=1:subq=7:brdo:mixed_refs:weight_b:bime:no_fast_pskip:direct_pred=auto:mixed_refs:nr=200:threads=auto:turbo=2:pass=1 -oac copy -of rawvideo
mencoder movie.vob -o movie.264 -ofps 24000/1001 -vf crop=720:352:0:62,harddup -ovc x264 -x264encopts bitrate=1800:frameref=6:analyse=all:me=umh:subme=7:trellis=2:bframes=1:subq=7:brdo:mixed_refs:weight_b:bime:no_fast_pskip:direct_pred=auto:mixed_refs:nr=200:threads=auto:pass=2 -oac copy -of rawvideo
MP4Box -add audio.mp4 -add movie.264 -fps 23.976 movie.mp4
sleep 5
rm audiodump.pcm
rm audio.mp4
Tuesday, February 19, 2008
Linux (Ubuntu Gutsy) Firefox, Flash, Alsa, and a bullet to the head.
I played with PulseAudio, and it is OK. Honestly I found it to be more trouble than it was worth. All I want is to play audio from multiple apps at once, and many apps have no support for pulseaudio, and I could never get it to behave very well anyway. So I needed something else.
I finally decided to check out alsa, and I discovered it could do everything I wanted. It's an amazingly versatile tool once you dive into it a little bit. So first order of business was to fix this whole flash nonsense.
In case you don't have it:
$sudo apt-get install alsa-oss
This will get the compatability layer for oss. Everything does oss, even if it does not do alsa. So this is a no-brainer. We will let firefox think it is using OSS and we will just pipe that to alsa.
Now the trick to ALSA it turns out is setting up your ~/.asoundrc file. I'm still outrageously noob at this, and the documentation is, as expected, abysmal. But I have managed to put this much together.
First I want to have all my apps be able to make sounds simultaneously. We can do that with alsa using "dmix" which is the alsa software mixer. I have some intel 5.1 sound in my machine (from the motherboard) so I decided to stick with that.
A good way to figure out what is going on with your sound is the "aplay" command.
$aplay -l
$aplay -L
Will list out the details of your sound card as alsa understands it. My intel card is card 0, so now I:
$vi ~/.asoundrc
I want a mixer so I set up the following sections:
pcm.dmix51 {
type dmix
ipc_key 1024
slave {
pcm "hw:0,0"
channels 6
period_time 0
period_size 1024
buffer_size 8192
rate 48000
}
}
ctl.dmix51 {
type hw
card 0
}
Ok, so what we just did was create a software ALSA mixer and associated it with the sound card at "hw:0,0". We can test it in mplayer using:
$mplayer somefile -ao alsa:device=plug=dmix51
or
$speaker-test -Dplug:dmix51 -c6 -twav
From this I get sound. The speaker-test program actually will send sound to each speaker in your 5.1 setup with a girl saying which channel she expects to be in, making sure you have it right.
Since this is a software mixer you should now be able to use sound from lots of programs through the alsa/dmix51 plug-in. Now we just need to get stuff to use it.
So we have 2 problems now. We want to make the default ALSA device our software mixer, and we want to make firefox use it through the oss layer. Luckily both are now very easy. Open up the ~/.asoundrc file if you closed it. We need to add 2 more sections.
To make the default for every program using alsa to be using your mixer, add the following:
pcm.!default {
type plug
slave.pcm "dmix51"
}
Software looks to this !default tag if no specific device is given ("mplayer -ao alsa" will use this; "mplayer -ao alsa:device=plug=default" will also). So all we do is make a dummy !default plug pointing to our mixer.
The alsa-oss plug defaults to "dsp0", so we need to set up a dummy for that too:
pcm.dsp0 {
type plug
slave.pcm "dmix51"
}
Now we save the file and exit. I then went to the desktop. System->Preferences->Sound. In the "Devices" tab I changed everything to "ALSA". In the "Sounds" tab I disabled "ESD". I continued to have problems so I rebooted at this point.
Upon reboot I changed the firefox launcher command from "firefox" to "aoss firefox" and wuala! Sound from flash. I then went to all my programs (amarok, mplayer, xine, ...) and changed them all to use ALSA for sound output. Now I can have more programs making sound than I could want.
In the future we all will be able to browse the web and listen to music at the same time!
Linux (Ubuntu Gutsy) - Ripping DVD to h264 (using mencoder and x264)
For a while I was ripping all my content to avi files using the xvid codec. I liked the codec well enough, and the encode times were really good. The downside was the end result was not great. If I had a DVD where I was really concerned with quality I just kept it in it's original form. If I was just trying to archive a season of something I compressed it. Some of my favorite shows just don't require any kind of quality (Penn & Tellers Bullshit, Law & Order, etc...)
A friend told me how great h264 was, so I thought I'd give it a try. For the most part I was really pleased with it. If I just want a low quality copy, but still enjoyable, I go for about a 1k bitrate. If I want the best quality/size ratio I go for about 1.8k. If it's something I really want quality on I either leave it as a DVD or give it a 2.5k+ bitrate. The real downside is encode times. Holy spaghetti monster does h264 take time to encode.
During this process I added several libraries to Ubuntu from the repositories. I don't remember them all, so if we come across a command you don't have search the ubuntu pages for it. I didn't do anything special as far as that goes. If I am using it here, it is in the Ubuntu repositories.
I also want to write my own encoder program. So everything I am doing has an eye on me being able to do this process programmatic in the future. Next time I'll talk about my python program I'm writing to automate all of this. So be warned everything is command-line.
Step 1: Get DVD Info
So you pop your DVD in the drive and now you need to figure out what is on it. The best tool I've found for this is "lsdvd".$lsdvd
Disc Title: THE_DISC_TITLE
Title: 01, Length: 00:29:51.153 Chapters: 05, Cells: 05, Audio streams: 03, Subpictures: 00
Title: 02, Length: 00:29:56.043 Chapters: 05, Cells: 05, Audio streams: 03, Subpictures: 00
Title: 03, Length: 00:28:04.110 Chapters: 05, Cells: 05, Audio streams: 03, Subpictures: 00
Title: 04, Length: 00:29:51.043 Chapters: 05, Cells: 05, Audio streams: 03, Subpictures: 00
Longest track: 02
So this shows us the tracks on the dvd. If you include the -a switch ("lsdvd -a") it will also show you the audio for each track. Now we know what is on the DVD, and we decide what to rip.
Step 2: Rip Your Tracks
Let's say we decided we want Track 1. Now we need to rip it to the hd. Again it's very easy:$mplayer dvd://1 -v -dumpstream -dumpfile myfile.vob
You can replace the "1" with whatever track you want. So if you want track 2 "mplayer dvd://2...". Replace "myfile.vob" with whatever you want to call the file.
Step 3: Cropping
Most DVD's are not at the actual 720x480 resolution of a DVD. We can save file size by cutting out the extra black borders. Yet again mplayer can help us. It has a tool for detecting the best crop rate.
$mplayer -vo null -ao null -vf cropdetect myfile.vob
[CROP] Crop area: X: 0..719 Y: 0..479 (-vf crop=720:480:0:0).0 0
The output will spit out a lot of those [CROP] lines. One frame for each frame as the vob file plays. I've found it's best to skip around the movie until you find a spot where it settles down. This tool does weird things at the beginning (as most movies and shows start black). So let it run a bit and once it settles down to the same "crop=" line, then you have mplayers recommended crop settings. In the case above it is "720:480:0:0". Remember this, we will need it later.
Step 4: FPS and DVD weirdness
For this part we need a quick understanding of what is going on in these DVD's. From what I gather basically nothing is produced in the 29.97 frames per second (fps) that a DVD plays at. There are 3 main ways that the content is transferred to DVD's. They are Progressive (Star Wars 3), Interlaced (Penn & Tellers Bullshit), and Telecine (History Channel: The Universe).
Progressive (Star Wars 3):
In movies like this they are normally shot at 23.976 fps. Since a DVD plays 29.97 fps, the extra frames have to come from somewhere. Progressive means that entire extra frames where inserted per second to make up the difference. When playing the file you shouldn't see any jagged lines appearing. Encoding is as simple as stripping these extra frames away, and the fps is 23.976.
Telecine (History Channel: The Universe)
In this case the original is also at 23.976 fps, but the missing frames were made differently. Just playing one of these files using mplayer should show jagged lines. I gather that what is going on here is that the frames that were produced to fill up the space are actually combinations of different frames around it, instead of full duplicate frames. A good way to tell if you have a telecine video is to detelecine it and see if that fixes the jagged lines:
$mplayer myfile.vob -ao null -vf pullup,softskip
The "pullup" filter understands what is going on with the duplicate frames and removes them. If this command shows you your video without the jagged lines, then you have telecine content. Basically the same as above. We just need to drop these extra frames, and the output is 23.976 fps.
Interlaced (Penn & Tellers Bullshit)
In this case the footage was originally shot in 60 fps. You can't just halve the fps for a video like this. The end result comes out with choppy motion as the whole motion was recorded in 60 fps not 30 fps. So what they do is make a series of 30 frames where each is 1/2 of the original 2 (ie this frame never existed in the original video, it is a combination of the 2 frames it is replacing). You basically have 2 options:
1) re-create the extra frames returning it to 60 fps
2) deinterlace
Both essentially do the same thing. You cannot actually get the content back to it's original glory. Half the data is simply gone. In my tests returning things to 60 fps made the picture look no better while simultaneously adding to encode time, upping the decode requirements, and making the file bigger. None of that is selling it to me. We can just deinterlace the content and leave it at 29.97 fps. That's about the best we can do. You can check to make sure this fixes the picture:
$mplayer myfile.vob -ao null -vf yadif
If the lines are gone, then you have an interlaced picture and an output of 29.97 fps.
**yadif can fix telecine material. The output isn't as good though. So be sure to check for telecine first, don't just assume that since yadif works it must be interlaced.
By knowing which of the 3 above you have, we can now move on to encoding.
**I believe I have found a way to programmatic determine which of the above you have. That will be for next time though, when we try to make a python program to automate this process.**
Step 5: Audio
Ultimately I want to write a program to do this so I had to settle on an audio spec. I want everything to be standardized. If I go shopping for any multimedia device I just have to worry about 1 video and audio codec. Since mp3's can't do 5.1 sound (at least to my knowledge) I decided to go with aac. The quality is good, encoding is fast, file size is good, and it does stereo and/or 5.1 surround sound. I just think all that makes this the best for audio of this nature. We can even rip the audio directly from the vob file in 1 step.
When using "lsdvd -a" you will see the audio channels for each track listed. The "Stream id:" value is the one you want. It's reported as something like 0x80 or 0x81, etc. I don't know what or why (I haven't bothered to look that up yet) but those are the audio channels. We need them in integer form so (0x80=128, 0x81=129, ...).
$mkfifo audiodump.pcm
2 Channel Stereo like this:
$faac -P -R 48000 -q 100 -C 2 -X --mpeg-vers 4 -o myfile.aac audiodump.pcm & mplayer myfile.vob -aid 128 -vc dummy -vo null -ao pcm:nowaveheader:fast -channels 2
6 Channel 5.1 like this:
$faac -q 100 -I 1,6 -P -R 48000 -C 6 -X audiodump.pcm -o myfile.mp4 & mplayer myfile.vob -aid 128 -vc dummy -vo null -ao pcm:nowaveheader:fast -channels 6
As you can see they are very similar. In mplayer "-aid 128" will select the audio track 128. Change as needed. The difference is the "-C" flag for "faac" and the "-channels" flag for mplayer. "-C 2" and "-channels 2" tells them both to do 2 channels. For whatever reason the 6 channels will not map correctly by themselves, so we have to remap them (otherwise the channels are messed up; ie center will come out some other speaker, and left and right will be jumbled). That's what "-I 1,6" does in "faac". With "-I" you can specify the channel that has the center speaker and the one for the sub-woofer. In my tests those are channels 1 for center, and 6 for sub. So "-I 1,6" fixes the audio.
Step 6: Encoding
Now we're ready to encode, here are the commands I use. If you want more details, then go look them up.
Progressive:
mencoder myfile.vob -o /dev/null -ofps 24000/1001 -vf crop=720:480:0:0,scale,harddup -ovc x264 -x264encopts bitrate=1800:frameref=6:analyse=all:me=umh:subme=7:trellis=2:bframes=1:subq=7:brdo:mixed_refs:weight_b:bime:no_fast_pskip:direct_pred=auto:mixed_refs:nr=200:threads=auto:turbo=2:pass=1 -oac copy -of rawvideomencoder myfile.vob -o myfile.264 -ofps 24000/1001 -vf crop=720:480:0:0,scale,harddup -ovc x264 -x264encopts bitrate=1800:frameref=6:analyse=all:me=umh:subme=7:trellis=2:bframes=1:subq=7:brdo:mixed_refs:weight_b:bime:no_fast_pskip:direct_pred=auto:mixed_refs:nr=200:threads=auto:pass=2 -oac copy -of rawvideo
Telecine:
mencoder myfile.vob -o /dev/null -ofps 24000/1001 -vf pullup,crop=720:480:0:0,softskip,harddup -ovc x264 -x264encopts bitrate=1800:frameref=6:analyse=all:me=umh:subme=7:trellis=2:bframes=1:subq=7:brdo:mixed_refs:weight_b:bime:no_fast_pskip:direct_pred=auto:mixed_refs:nr=200:threads=auto:turbo=2:pass=1 -oac copy -of rawvideomencoder myfile.vob -o myfile.264 -ofps 24000/1001 -vf pullup,crop=720:480:0:0,softskip,harddup -ovc x264 -x264encopts bitrate=1800:frameref=6:analyse=all:me=umh:subme=7:trellis=2:bframes=1:subq=7:brdo:mixed_refs:weight_b:bime:no_fast_pskip:direct_pred=auto:mixed_refs:nr=200:threads=auto:pass=2 -oac copy -of rawvideo
Interlaced:
mencoder myfile.vob -o /dev/null -ofps 30000/1001 -vf crop=720:480:0:0,yadif=3,framestep=2,harddup -ovc x264 -x264encopts bitrate=1800:frameref=6:analyse=all:me=umh:subme=7:trellis=2:bframes=1:subq=7:brdo:mixed_refs:weight_b:bime:no_fast_pskip:direct_pred=auto:mixed_refs:nr=200:threads=auto:turbo=2:pass=1 -oac copy -of rawvideomencoder myfile.vob -o myfile.264 -ofps 30000/1001 -vf crop=720:480:0:0,yadif=3,mcdeint,framestep=2,harddup -ovc x264 -x264encopts bitrate=1800:frameref=6:analyse=all:me=umh:subme=7:trellis=2:bframes=1:subq=7:brdo:mixed_refs:weight_b:bime:no_fast_pskip:direct_pred=auto:mixed_refs:nr=200:threads=auto:pass=2 -oac copy -of rawvideo
Step 7: Wrapping up
Once this is all done all we have left is to combine the 2 files together into the new mp4 file. I do this with "MP4Box". All you need is the name of the video file, audio file, and the fps to use.
$MP4Box -add myfile.264 -add myfile.aac -fps 23.976 myfile.mp4
Change "myfile.aac" to "myfile.mp4" if you made 6 channel audio. Also change "-fps 23.976" to "-fps 29.97" if you deinterlaced. The result should be a reasonably good h264 compression of a dvd.
Now to make a python program to automate this whole mess.