Wednesday, September 3, 2008

Experience with mencoder

mencoder encodes videos, I use it to encode my DVB recordings. When you run mencoder without any tunning, you will waste useful space. Here is my experience with mencoder:

Removes all black borders
Really !! You can use the filter cropdetect to find the values for the crop filter or use the filter rectangle:
$ mplayer -vf cropdetect video.avi
$ mplayer -vf rectangle=716:428:: video.avi

Avoid odd numbers
as a general advise.

Height and Width
must be a multiple of 16. The video codec encodes the video with 16x16 blocks and if the size isn't a multiple of 16, you will waste space. The filter cropdetect returns values that are a multiple of 16, but also crops the video sometimes to much.

Scale
can help to solve this problem. And sometimes it's better to have a smaller height and width. First just crop only the black borders, then scale the video height and width to a multiple of 16.

For example:
$ mplayer -vf crop=716:428::,scale=640:-10

The new width is 640 and height 352.
The parameter -10 tells the scale filter to calculate the height using the width and to round the height to the closest multiple of 16.

Use filter hqdn3d=2:1:2
Use filter harddup
See man page why

Two Pass Mode
The  first pass analyzing the whole video and writes a statistics file. The second pass reads the statistics file and bases ratecontrol decisions on it. The output file from the first pass can be deleted or send directly to /dev/null

File Size
Should the movie fit on a CD, then you have of calculate the bitrate of your movie:
Bitrate = (Target_Size_in_MB - Audio_Size_in_MB - AVI_overhead_MB) * 1024 * 1024 / Length_in_secs * 8 / 1000
Use the video codec xvid and it will do it for you, you just need to set the video file size in KB (See example).
How to calculate it ? When you use the Two Pass Mode, write down the audio size after the first pass has finished.
Video_Size_MB = Target_Size_in_MB - Audio_Size_in_MB - AVI_overhead_MB
Video_Size_KB = (Target_Size_in_MB - Audio_Size_in_MB - AVI_overhead_MB) * 1024

AVI Overhead
When you use AVI as your container, some MBs will be wasted for the AVI header and index.
For a 350MB file ~ 5MB
For 700MB ~ 8MB

Example

First Pass
$ mencoder -ovc xvid -xvidencopts pass=1:autoaspect:threads=2 -vf crop=715:428::,scale=640:-10,hqdn3d=2:1:2,harddup -oac mp3lame -lameopts aq=3:preset=standard video.mpg -o /dev/null

Second Pass
$ mencoder -ovc xvid -xvidencopts pass=2:bitrate=-595968:autoaspect:threads=2 -vf crop=715:428::,scale=640:-10,hqdn3d=2:1:2,harddup -oac mp3lame -lameopts aq=3:preset=standard video.mpg -o video.avi


Is the value for the bitrate option negativ, it sets the video size in kilobytes [700 (CD) - 110 (audio size) - 8 (AVI overhead) = 580 * 1024 = 595968kb].
The threads option is only useful if you have more than one CPU else remove it.

DVB Streams

If you record a DVB streams you will notice sooner or later, that they aren't small.
For two hours 5 GB space, isn't that small and won't fit on a CD.

To encode a video, first you have to demux with ProjectX (http://sourceforge.net/projects/project-x) and remux with mplex (package mjpegtools) the stream to fix possible transmission errors. If you don't to that, you will maybe get a video where the audio and video is out of synchronization. It is also possible to export the subtitles from the Teletext.

$ java -jar ProjectX.jar myVideo.mpg

After running the program, you will find for every video and audio track an own file. To see all available options from ProjectX, run it without any parameters.

Then remux the video and audio together with mplex:

$ mplex -f 8 -o newVideo.mpg myVideo.m2v myVideo.mp2

When mplex returns without any errors, all files are no longer needed except newVideo.mpg.

Now cut out the advertisement, for example with dvbcut or avidemux and encode the video the get a smaller file size.

Saturday, August 16, 2008

My Linux Stuff

I have set up a new web page where i place all the Linux Stuff which has no place at this blog like long scripts and so on ...

http://linux.thaj.net63.net/

Wednesday, July 30, 2008

Horrible MP3 sound ?

When i played MP3 files, they sound horrible and had a bad quality.

I don't know why, but if I set the PCM control to 80% or lower (thanks
to a hint from a forum), i will get the quality before I switched to
Linux.

Crazy, isn't it ?

Sunday, July 6, 2008

What happend with "Have a lot of fun ..."

Do you remember ? After a successful login on a tty, the text "Have a lot of fun ..." was displayed on the screen in the old days.

But nowadays ?

Friday, July 4, 2008

MythTV - a dream become true ...

MythTV is next generation of watching TV aside from Video on Demand. With MythTV you can pause, rewind, forward and more what you are watching. And that's all possible because MythTV records everything you are watching. It's your personal digital video recorder. For this you need a fast PC and a lot of free space on your hard disk. I have 2,0 GHz and somethings the video jitter. Watching HDTV is impossible.


Installation

Installing the program with ./configure && make && make install took a while til i had installed all need libraries and header files. The program files are installed into /usr/local which is not a default location on Fedora and so you start MythTV, it won't find the libraries.

Solution 1: Run ./configure --prefix=/usr
Solution 2: Create a new file named mythtv.conf in /etc/ld.so.conf.d and put in it where the libraries are, usually /usr/local/lib, run ldconf to apply the changes.

And do your eyes a favor: Install the additional themes package.


Tip 1: MySQL

MythTV uses MySQL to store its configuration and data. If you run mythbackend and mythfrondend on one PC, MySQL can run with a small configuration to save memory and disk space. Disable innodb (see skip-innodb), MythTV doesn't used it and with the default configuration it uses 10MB of your hard disk.

[mysqld]
#port = 3306
#datadir=/home/jorg/.mythtv/db
#socket=/home/jorg/.mythtv/db/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

skip-locking
key_buffer = 16K
max_allowed_packet = 1M
table_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K

server-id = 1

skip-bdb
skip-innodb

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[isamchk]
key_buffer = 8M
sort_buffer_size = 8M

[myisamchk]
key_buffer = 8M
sort_buffer_size = 8M

[mysqlhotcopy]
interactive-timeout

After a restart of the mysql server you can remove the innodb files from your mysql data directory to free up the disk.


mythtv-setup

Configure MythTV the first time with mythtv-setup is hard, if you do not know what you are doing:

2. Capture Cards
Here you define your TV card.
3. Video Sources
Here you define where MythTV can find the program information for the EPG.
With DVB-S the "Transmitted guide only" is a good choice.
4. Input connections
Here you say Capture Card x can find his program information at video source y.

Scan for channels: That's a torture. Every time you do a Full Scan (Tuned) you have to reenter all the data. And with this type only a few data(?) channels are found. But i got the transponder list. And with a Full Scan of Existing Transports i got my channels. The first times i run it, i had the feeling the program hang up because no screen update for a long time and error messages in the log file. Go and get a cup of tea, the scan took longer than the dvbscan, about 10-20 minutes.

The next step is to download the channel logos, only if you like. I think, this tool is buggy. When you choose a logo for a channel from a list of choices, the logo get downloaded, but the channel is not updated, so you have to enter the filename by hand. If the program choose automatic a logo because there is only one, the channel will get updated. For the filename you have to enter the full path, e.g. /home/bob/.mythtv/channels/logo.jpg


Tip 2: Edit channels

If you are to lazy, like me, to install MythWeb there is another smart way to edit the channel list:
Export the channels into channels.csv:
$ mysql -u mythtv -p mythconverg -e "SELECT * FROM channel" > channels.csv
And you get a tabulator separated file, import it with e.g. OpenOffice.org Calc. Edit the channels, save and import it back:
$ sed -e "s/\"NULL\"/NULL/g" channels.csv > channel.csv
$ mysqlimport -u mythtv -p mythconverg --columns=`sed -n -e "y/\t/,/" -e "s/\"//g" -e P -e q channel.csv` --ignore-lines=1 --local --delete --fields-optionally-enclosed-by=\" channel.csv
You need the parameter --columns for the case, you changed the order of the columns.

The commands explained:

sed -e "s/\"NULL\"/NULL/g" channels.csv > channel.csv
Replace "NULL" with NULL, save into channel.csv
sed -n -e "y/\t/,/" -e "s/\"//g" -e P -e q channel.csv
Returns the first line which contains the column names, replace the tabulator with "," , replace the field separator " with nothing.



Tip 3: EPG

Be patient. The EPG needs its time. And it only collects the EIT information when the LiveTV is not running. Well, if you don't trust the program, run only the backend with

$ mythbackend -v eit

and do nothing, wait one minute (default setting, to change run mythtv-setup, go to General, Page EIT)


If you followed the install instruction correctly, you will be ready for the next generation of watching TV.
Have a lot of fun ...

Tuesday, July 1, 2008

CyberLink Remote Control

The CyberLink IR receiver is recognized as two simple USB keyboard (I don't know why two) and one mouse.

Kernel Log:
kernel: input: TopSeed Tech Corp. USB IR Combo Device  as /class/input/input3
kernel: input,hidraw0: USB HID v1.00 Keyboard [TopSeed Tech Corp. USB IR Combo Device ] on usb-0000:00:02.1-3
kernel: input: TopSeed Tech Corp. USB IR Combo Device as /class/input/input4
kernel: input,hiddev96,hidraw1: USB HID v1.00 Mouse [TopSeed Tech Corp. USB IR Combo Device ] on usb-0000:00:02.1-3

With the default, not really useful (for me) keycodes are assigned.
For example the the red button has the keycode KEY_F15 (389), green KEY_F17 (391), yellow KEY_MEDIA (226), blue KEY_VIDEO (393). (The funny thing is: xev doesn't report these keys.)

Remapping with keycodes and scancodes doesn't work because USB keyboards have no scancodes. A good explanation you can find on http://lkml.org/lkml/2006/6/9/307.

I was looking for a simple way to remap the keys to other keys. I looked quick over http://lineak.sourceforge.net/ and maybe that will do it also. But i wrote my own program to change the keys.

With this program you set your own keycodes. The default mapping is for MythTv. The change the mapping, just edit keys.h and recompile the package.

The source code of the program is available under
http://twe.awardspace.com/cyberlink/

Saturday, June 28, 2008

TT-budget S-1401

TT-budget S-1401 from TechnoTrend is a PCI card to watch digital satellite TV (DVB-S) on your pc.
The good news: With a new kernel it works.

This card is one of the cheapest, it only supports free channels (without some help ...).

All you need to watch TV you can find on http://linuxtv.org/.
For a first test you should install the dvb-apps package.

Now here are my tips for a quick try-out:

You should have a working channels.conf file (http://linuxtv.org/wiki/index.php/Testing_your_DVB_device)
I tried mplayer and xine, both can work with a dvb stream.

The apps search for the channels.conf in there config directory, so simply create a symbolic link:
(1) mplayer (2) xine
(1) $ cp -s ~/channels.conf ~/.mplayer/channels.conf
(2) $ cp -s ~/channels.conf ~/.xine/channels.conf
Start the app:
(1) $ mplayer -cache 4096 dvb://ProSieben
(2) $ xine dvb://ProSieben

Attention: The channel names are case sensitive !

Notes about mplayer:
Without -cache the video appears to jitter.

Notes about xine:
xine will crash if call without a channel name on command line or if the you click on the dvb button.


With these apps you can only watch TV, no EPG, no teletext and so on. My next try will be MythTV.

Monday, June 9, 2008

SANYO CA6 Xacti (VPC-CA6)

My mother bought herself a nice, tiny digi cam SANYO CA6 Xacti (VPC-CA6). The offer was a special offer and so I think the price is ok for that what you get. Else you would get the same cheaper, normally you pay more just for the brand name. The manufacturer says that it is the first water proof digi cam. I haven't tried it out.


The test:

Of course, I tried it out with Linux: Reading/writing from/to the memory card and playing the videos worked without any problems. Then i tried to use it as a web cam, plug in the cam, selected the entry at the display and looked at my log file:
kernel: usb 1-5: new high speed USB device using ehci_hcd and address 2
kernel: usb 1-5: configuration #1 chosen from 1 choice
kernel: Linux video capture interface: v2.00
kernel: uvcvideo: Found UVC 1.00 device SANYO Digital Camera (0474:024f)
kernel: usbcore: registered new interface driver uvcvideo
kernel: USB Video Class driver (v0.1.0)

That's fine, Linux has a driver for it.


Now my problem was, that i hadn't any program to test it.
I found xawtv, usually for watching TV but should also work with web cams. It didn't worked.

After a long search i found on a page which i couldn't read but has the cam's picture.
There was a link to LUVCview. I complied the program, connected the cam, started the program and it worked.
Also a picture of Ekiga is on the site, so i think it will work too.


The results:

The resolution is only 320x240, but enough for a web cam. I haven't tried the Windows version, maybe better resolutions are possible.
When you close the program, it is not possible to open it again, the following message is logged:
kernel: uvcvideo: Failed to query (1) UVC control 1 (unit 0) : -110 (exp. 26).
The workaround is to unplug the cam.


Links:

Saturday, May 10, 2008

Evolution: Import addressbook from old home directory

When i switch from Ubuntu to Fedora, i just backuped my home directory and didn't create a backup from my mails/addressbook with the function provided in Evolution. I thought copy the mails and addressbook from your old to your new home directory will do the job. For the mail the idea is right, but not for the addressbook. because in the background a database server is running.

Open Evolution, create the same numbers of addressbooks you had in your old one, create for every addressbook one contact (without this step no directory will be created in $home/.evolution/addressbook/local for an addressbook).

Close Evolution and stop the database server with

evolution --force-shutdown

Now copy the addressbooks and start Evolution.
The next time i will use the backup function from Evolution, sure !

UFO AI on Fedora 8

UFO AI (http://ufoai.sourceforge.net) is a nice game, you have to save to world from aliens.

I wanted to play it, so i had to install it first. First I used yum, but the version available was one number behind. So i downloaded the Linux installer from the site, 400MB. The installation was easy as the download. You also need the packages SDL and SDL_ttf. Your graphic card should support direct rendering, you can get information about your card with glxinfo. The command glxgears draws running gears on your screen.


To start the game, call $ufoai/ufoai.
Do not call $ufoai/ufo directly because the script ufoai sets necessary environment variables. If you do, you will see a window with a red border and nothing more.

After starting i got this nice error:
./ufo: error while loading shared libraries: libcurl-gnutls.so.4: cannot open shared object file: No such file or directory

I started yum, looked for libcurl-gnutls, couldn't find anything. Searched the web. Found out that the binary is compiled on Ubuntu, the knowledge didn't solve my problem.

To get ride of this problem, i tried to create a link from libcurl.so.4 to libcurl-gnutls.so.4 and it worked.

cd /usr/lib
ln -s libcurl.so.4 libcurl-gnutls.so.4


Run again $ufoai/ufoai, the game started but without a sound and hanged up on exit. The problem was that SDL loaded the wrong sound driver. Comment out the line SDL_AUDIODRIVER="alsa" in $ufoai/ufoai solved the problem.

Now the game even works better than on Windows.
When i run the game in full screen mode, the multimedia keys on the keyboard, like Launch Calculator or volume lower/raise, doesn't work.

Wednesday, May 7, 2008

Huawei E220 UMTS Modem

One of the reasons why i changed to Fedora was my UMTS Modem. Ubuntu does not detect it as a modem and calling the program with udev doesn't work. So every time i plugged-in the modem, i had to run the program.

That page helps a lot for the first time with a E220 modem (and others, in German): http://linux.frankenberger.at/Huawei_E220.html

With Fedora 8 you just need to create a new network interface with the Network Manager, enter the phone number, user, password and the init connection string for your connection. Then you are ready to start your connection with ifup/ifdown.


Disable PIN code
If you are to lazy, like me, to disable the pin code, use udev to send the pin code every time the modem is pluged in:
Create a file with the name /etc/udev/rules.d/50-UMTS.rules and put the content in it:

BUS=="usb", KERNEL=="ttyUSB0", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1", SYMLINK+="umts", RUN+="/usr/bin/wvdial -n --config /etc/wvdial-pin.conf"

Maybe you have to replace the values of SYSFS{idProduct} and SYSFS{idVendor} to match your modem, use lsusb to get the values.

As you can see, you need also the file /etc/wvdial-pin.conf which contains the pin:

[Dialer Defaults]
Modem = /dev/ttyUSB0
Baud = 460800
SetVolume = 0
Dial Command = ATDT
FlowControl = NOFLOW
Init1 = ATZ
Init2 = AT+CPIN=XXXX


Replace XXXX with your PIN code.
Warning: The file wvdial-pin.conf should only be readable for root and no other users. (chown root:root /etc/wvdial-pin.conf;chmod u=rw,go-rwx /etc/wvdial-pin.conf)

When your remove the -n option for the wvdial command in the file 50-UMTS.rules, you will see in a log file (usually messages), what wvdial is doing and your PIN code, so be careful.


Nice script for the desktop
I have written a script for ifup/ifdown that shows the status/errors via a nice windows. First it wats til /dev/ttyUSB0 is available.

Command: network.sh up|down networkinterface
A newer version of the script can be found at my Linux Stuff page.
#!/bin/sh


if [[ $1 = "up" ]] ; then
CMD="/sbin/ifup"

#wait for modem

DEV=/dev/ttyUSB0

if [ ! -e $DEV ] ; then
(echo 1; while [ ! -e $DEV ] ; do sleep 3; done; sleep 7; echo 100) | zenity --progress --text="Auf Modem warten ..." --auto-close --auto-kill --pulsate
fi
fi

if [[ $1 = "down" ]] ; then
CMD="/sbin/ifdown"
fi


if [[ ! $CMD || ! $2 ]] ; then
zenity --error --text="Was willst du machen ?"
exit 1
fi

zenity --progress --auto-kill --text="Bitte warten ..." --percentage=30 --pulsate <<<30 progress_pid="$!" msg="`$CMD">&1`
EXIT_CODE=$?

kill $PROGRESS_PID

if [ $EXIT_CODE != 0 ] ; then
echo $MSG
zenity --error --text="$MSG"
exit $EXIT_CODE
else
if [[ $1 = "up" ]] ; then
zenity --notification --text="Verbindung hergestellt" --window-icon=info &
PROGRESS_PID=$!
sleep 30
kill $PROGRESS_PID
fi
fi

exit 0

Nautilus - where are my backup files ?

Some nice editors create a backup file with the extension *.*~
But it would also be nice, if you could see them in the file browser. But this isn't the case.
I tried the option "View/Show hidden files", but that showed me only the files starting with a dot.
The only solution to show your backup files is to open the settings dialog and check the option "Show hidden files and backup files". But that isn't a solution you can live with because you do not want to see your hidden files every time you open a browser.

I search the web for a solution and i found a setting which seems to solve my problem.
gconftool-2 -s -t bool /desktop/gnome/file_views/show_backup_files true

But it doesn't work. Later i have found out that this is an unsolved bug from 2005!! (http://bugzilla.gnome.org/show_bug.cgi?id=313307).

Monday, May 5, 2008

Where the hell is the Launch Calculator entry in gnome-keybinding-properties ?

Short answer: There is no entry like in Ubuntu. I searched the web, but nobody knows why. The workaround is to create a custom shortcut.

HOWTO:
  • gconftool-2 --set --type string /desktop/gnome/keybindings/calc/binding "XF86Calculator"
  • gconftool-2 --set --type string /desktop/gnome/keybindings/calc/action "gcalctool"
replace calc with something that describes your shortcut.
replace XF86Calculator with your key, use the command xev to get the name of the key
action is the executed command when the key is pressed.
Restart your Gnome session. I think logout and login will do.

Switch from Ubuntu to Fedora

"Never change a running system"

Ubuntu worked (for me). Why i wanted to change ?
  • my UMTS modem was not really supported by the kernel.
  • i missed many basic apps (yes, i can download it via the internet, but do i know all the names of the packages ?)
  • i got my ordered Fedora DVD
I created a backup from my home directory and installed Fedora.
Now the real pain begins. Stuff that have worked in Ubuntu won't work in Fedora.
  • "Launch Calculator" key on the keyboard
  • Evolution won't import my old addressbook.
  • Apps crash
The only thing that works without a problem is my UMTS moden.

Friday, April 4, 2008

How it began ...

Some time ago i decided to change my main os from win2k to linux. From the cradle i was a fan of Red Hat. So the distro has to be Fedora. But nowadays you are not able to find a distro which fits on a CD or two and does not extend my 3GB limit. I had have to order a Fedora DVD. In the meantime i downloaded Ubuntu, it fits on a CD and does not extend my limit.

After the install of Ubuntu the my pain begins ...