ThuyDX

Just another WordPress.com site

Fedora 18 doesn’t play DVD (SOLVED)

Eager to start totem with a DVD you just borrowed from a Video shop?. Hopefully it works smoothly for you. But if you are unlucky like me today and totem tells you:

couldn't read dvd
Or
libdvdread: Error cracking CSS key for /VIDEO_TS/VTS_01_0.VOB (0x0000a380)

This may save your day.

The short solution

Shortly for people who have been trying to play their DVD and have installed all gstreamer1* and dvd* packages, but not regionset. Install regionset:

yum install regionset.x86_64

Now use the program:

regionset /dev/sr0

regionset version 0.1 -- reads/sets region code on DVD drives
Current Region Code settings:
RPC Phase: II
type: NONE
vendor resets available: 4
user controlled changes resets available: 5
drive plays discs from region(s):, mask=0xFF

Would you like to change the region setting of your drive? [y/n]:y
Enter the new region number for your drive [1..8]:2 <---- for Germany/Europe?
New mask: 0xFFFFFFFD, correct? [y/n]:y
Region code set successfully!

Enjoy your movie!

mplayer dvd:////dev/sr0

The How To: Preparing your Fedora 18 (>18?) for playing encrypted DVD

Enable 3rd-party repos

RPMFusion.org (Ref: http://rpmfusion.org/Configuration)

su -c 'yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm'

Livna.org

su -c "rpm -ivh http://rpm.livna.org/livna-release.rpm"

Installing required packages

Codecs, etc.,

yum -y install gstreamer-plugins-bad gstreamer-plugins-bad-free-extras gstreamer-plugins-bad-nonfree gstreamer-plugins-ugly gstreamer-ffmpeg ffmpeg mencoder ffmpeg2theora mplayer libdvdcss regionset lsdvd

and the gstreamer1-*

yum install gstreamer{1,}-{ffmpeg,libav,plugins-{good,ugly,bad{,-free,-nonfree}}}

Configurating DVD playback

regionset /dev/sr0

Would you like to change the region setting of your drive? [y/n]:y
Enter the new region number for your drive [1..8]:2 <---- for Germany/Europe?
New mask: 0xFFFFFFFD, correct? [y/n]:y

That’s it.

It still doesn’t work

Try running dvd playback program in console and google for the suspicious output.

rm -rf .dvdcss
mplayer dvd:////dev/sr0

Erroneous output looks like this:

MPlayer SVN-r35234-4.7.2 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing dvd:////dev/sr0.
libdvdread: Using libdvdcss version 1.2.12 for DVD access
There are 19 titles on this DVD.
There are 1 angles in this DVD title.

libdvdread: Attempting to retrieve all CSS keys
libdvdread: This can take a _long_ time, please be patient

libdvdread: Get key for /VIDEO_TS/VIDEO_TS.VOB at 0x0000014a
libdvdread: Elapsed time 6
libdvdread: Get key for /VIDEO_TS/VTS_01_0.VOB at 0x0000a380
libdvdread: Error cracking CSS key for /VIDEO_TS/VTS_01_0.VOB (0x0000a380)

Compile newest libraries

git clone git://git.videolan.org/libdvdcss

Useful links

http://www.videolan.org/developers/libdvdcss.html
http://www.squaregoldfish.co.uk/2010/01/08/dvds-that-wont-play-in-linux-and-how-to-make-them-behave/
http://www.liberiangeek.net/2013/10/heres-enable-dvd-playback-ubuntu-13-10/

Advertisements

Avermedia A835 on Fedora 16

====== Installing driver Avermedia A835 ======

I tried to install this cheap dvb-t usb receiver since Fedora 13 but without success. After installing Fedora 16 I tried again and this time it worked :-). Thanks a lot to this blog http://www.nbytes.org/2011/11/instalacion-de-avertv-volar-pro-hd-a835.html and opensource effort.

===== Prepare env =====

[root@localhost AF9035_xgaz_3.0.0]# yum -y install make gcc kernel-headers kernel-devel build-essential

===== Download driver source =====

[root@localhost AF9035_xgaz_3.0.0]# yum -y install make gcc kernel-headers kernel-devel build-essential

===== Download firmware =====

# cd /lib/firmware
# wget http://xgazza.altervista.org/Linux/DVB/dvb-usb-af9035-01.fw

===== Compile =====
Edit Makefile with correct path to kernel source:

...
#KDIR = /usr/src/linun-headers-`uname -r`
KDIR = /usr/src/kernels/`uname -r`
...

Compile/install:

# make
[root] make install

Dmesg output:

...
[160839.694147] usb 1-7: new high speed USB device number 7 using ehci_hcd
[160839.814318] usb 1-7: New USB device found, idVendor=07ca, idProduct=a835
[160839.814327] usb 1-7: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[160839.814333] usb 1-7: Product: A835
[160839.814338] usb 1-7: Manufacturer: AVerMedia TECHNOLOGIES, Inc
[160839.814343] usb 1-7: SerialNumber: 3030832015380
[160840.091134] IR NEC protocol handler initialized
[160840.095636] IR RC5(x) protocol handler initialized
[160840.097223] IR RC6 protocol handler initialized
[160840.098720] IR JVC protocol handler initialized
[160840.099882] dvb-usb: found a 'Avermedia AverTV Volar HD & HD PRO (A835)' in cold state, will try to load a firmware
[160840.100214] IR Sony protocol handler initialized
[160840.101726] IR MCE Keyboard/mouse protocol handler initialized
[160840.103532] lirc_dev: IR Remote Control driver registered, major 249
[160840.103762] IR LIRC bridge handler initialized
[160840.126733] dvb-usb: downloading firmware from file 'dvb-usb-af9035-01.fw'
[160840.427829] dvb-usb: found a 'Avermedia AverTV Volar HD & HD PRO (A835)' in warm state.
[160840.427948] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
[160840.428468] DVB: registering new adapter (Avermedia AverTV Volar HD & HD PRO (A835))
[160840.436269] af9033: firmware version: LINK:11.15.10.0 OFDM:5.48.10.0
[160840.438522] DVB: registering adapter 0 frontend 0 (Afatech AF9033 DVB-T)...
[160840.450275] tda18218: NXP TDA18218HN successfully identified.
[160840.451782] Registered IR keymap rc-empty
[160840.451956] input: IR-receiver inside an USB DVB receiver as /devices/pci0000:00/0000:00:1d.7/usb1/1-7/rc/rc0/input14
[160840.452179] rc0: IR-receiver inside an USB DVB receiver as /devices/pci0000:00/0000:00:1d.7/usb1/1-7/rc/rc0
[160840.452184] dvb-usb: schedule remote query interval to 200 msecs.
[160840.452189] dvb-usb: Avermedia AverTV Volar HD & HD PRO (A835) successfully initialized and connected.
[160840.461424] usbcore: registered new interface driver dvb_usb_af9035
[root@localhost AF9035_xgaz_3.0.0]#

===== Install player =====
* Totem (Mplayer) normally installed.
* gnome-dvb-daemon
* run gnome-dvb-control and configure device: http://live.gnome.org/DVBDaemon/UserGuide

===== View tv with totem =====
* Edit -> preferences: enable gnome-dvb-daemon plugin.
* View -> Digital TV: A list of programs will be display. gnome-dvb-daemon is automatically started (ps -aux to confirm).

Linux installation from usb

These are the steps to create a bootable usb and put a netinst iso on it. With Fedora the following command will do the job:

dd if=netinst.iso of=/dev/sdx

Unfortunately it doesn’t work with Debian (as I knew) so we need some more steps:

Preparing

  1. A linux box.
  2. Download x from here: ;http://http.us.debian.org/debian/dists/stable/main/installer-amd64/20110106%2bsqueeze3/images/hd-media/boot.img.gz .
  3. Get a netinst.iso or bizcard iso http://www.debian.org/CD/netinst/#netinst-stable

Here we go

  1. Put the boot image on usb: zcat boot.img.gz /dev/sdx
  2. Mount usb: mount /dev/sdx /media/usbinst
  3. Copy iso to usb: cp /path/to/iso /media/usbinst
  4. Unmount usb: umount /dev/sdx

Problem

I remember having problem when copying iso to usb “not enough space”. I will update this post the next time I have to do this!. Anyway there is definitely enough space for a bizcard.iso.

Relating solutions:

http://unetbootin.sourceforge.net

DTAUS parser/checker

In a project I had to study DTAUS format, a standard to electronically communicate money transfer data between banks. It is still widely used in at least German speaking areas. More about infomation on Wikipedia:

http://de.wikipedia.org/wiki/DTAUS

There is also an online tools to check DTAUS files:
https://www.xpecto.de/index.php?id=148,7

This tools only tell you very minimal information about the correctness of DTAUS file. So I wrote a simple python script to parse and check the file myself. For now it fulfil my need of producing some checksums. It would be nice if I or someone can further develop it to be a fully function checker/parser. I hope I don’t have to use it anymore, though :)).

Usage:

#> python dtaus_checker.py dtaus_file

dtaus_file:

A-record
C-record
...
C-record
E-record

Source dtaus_checker.py:

#!/usr/bin/python
"""
    dtaus_checker.py
    @Author: thuydang.de@gmail.com
"""
import re
import sys

lines_count = 0
record_count = 0
sum_account_nr = 0
sum_bankcode = 0
sum_euro = 0

def is_A_record(line):
    patternA = r'(^d{4}A)(.*)'
    matchObj = re.match(patternA, line)
    if matchObj:
        return True
    else:
        return False

def is_C_record(line):
    patternC = r'(^d{4}C)(.*)'
    matchObj = re.match(patternC, line)
    if matchObj:
        return True
    else:
        return False

def is_E_record(line):
    patternE = r'(^d{4}E)(.*)'
    matchObj = re.match(patternE, line)
    if matchObj:
        return True
    else:
        return False

def process_A_record(line):
    pattern = r'(^d{4})(A)([GL][KB])(d{8})(d{8})(D{27})(d{6})(s{4})(d{10})(d{10})(s{47})(d{1})'
    matchObj = re.match(pattern, line)
    if matchObj:
        #for gr in matchObj.groups():
        print(matchObj.groups())
        return True
    else:
        print("print group errorn")
        return False
def process_C_record(line):
    global record_count
    global sum_account_nr
    global sum_bankcode
    global sum_euro
    #pattern = r'(^d{4})(E)([GL][BK])(d{8})(d{8})(w{27})(d{6})(s{4})(d{10})(d{10})(w{47})(d{1})'
    pattern = r'(^d{4})(C)(d{8})(d{8})(d{10})(d{13})(d{2})(d{3})(s{1})(d{11})(d{8})(d{10})(d{11})(s{3})(.{27})(s{8})(.{27})(.{27})(d{1})(s{2})(d{2})(01|02|03)(s{27})(01|02|03)(s{27})(s{11})'
    matchObj = re.match(pattern, line)
    if matchObj:
        print(matchObj.groups())
        record_count += 1
        sum_bankcode += int(matchObj.group(4))
        sum_account_nr += int(matchObj.group(5))
        sum_euro += int(matchObj.group(13))
        return True
    else:
        print("print group errorn")
        return False

def process_E_record(line):
    pattern = r'(^d{4})(E)(s{5})(d{7})(d{13})(d{17})(d{17})(d{13})(s{51})'
    matchObj = re.match(pattern, line)
    if matchObj:
        print(matchObj.groups())
        return True
    else:
        print("print group errorn")
        return False

def process_line(line):
    global lines_count 
    lines_count = lines_count + 1
    print("%d: %s") % (lines_count, line)
    if is_A_record(line):
        return process_A_record(line)
    elif is_C_record(line):
        return process_C_record(line)
    elif is_E_record(line):
        return process_E_record(line)
    else:
        print("__ERROR__ line %d: invalid linen") %(lines_count) 
        return False

print("DTAUS checker v%d.%d") %(0,1)

infile_name = sys.argv[1]
#   infile_name = "finput"

outfile_name = "foutput"

fi = open(infile_name, "rt")

while fi:
    line = fi.readline()
    result = process_line(line)
    if not result:
        break
    if not line:
        print("__EOF__")
        break

print(lines_count)
print("records count: %dn sum account nr: %dn sum bankcodes: %dn sum euro: %d") %(record_count, sum_account_nr, sum_bankcode, sum_euro)


sort, diff in… Windows

In my new job, I have to use Windows again. I’ve never thought that I would have any task like what I used to have. Once I had to compare 2 randomly sorted files. I can do that but how would I with Windows?.

‘sort’ is available in Windows but you don’t have the option to sort by a choosen column. OK, you can still sort by the selected position in a line. The command is pretty familiar:


sort /+n file1 > file1_sorted

Now I have 2 files and want a diff file. Fortunately there is gnu-diff on Sourceforge.org. Just install it and add its path to ENV. Voila!


diff file1_sorted file2_sorte > diff_1_2

To visually compare files, you can use Notepad++. It has compare plugin which is very useful. There are also plugin repo where you can easily find and install new plugin, e.g. hex editor.

Development on Meego netbook

== Essential packages for development on Meego ==
gcc compiler

sudo zypper install kernel-netbook-devel glibc-devel gcc-c++ make libtool autoconf

git

sudo zypper install git

qt

zypper install qt-devel-tools libqt-devel

Intrution detection: Sipvicious attack

1. The symptom.

Observation of network traffic showed that, a server sent a lot of udp sip packets to a foreign destination. This udp flooding consumed bandwidth and raised alarm when services are slower than usual. For network traffic observation tcpdump… can be used.

2. Find out which process sends the packets.
TODO:

‘top’ showed an active process named httpd :-). It could easily be bypassed because on this is on a webserver. ‘ps aux | grep httpd’ showed the full command of the trojan ‘httpd’. A better way to trace all connection is to use ‘lsof’.
top, lsof …

3.

Wifi Connection WM 6

1. Available WLAN APIs.
TODO
– NDIS / NDISUIO.
– Wlanapi: linux & wm. source?.
– OpenNetCF.
– Connection manager.
…?

2. Connenting to wlan a network with NDISUIO.
TODO:
– scan.
– disassociate.
– set mode infrastructure/adhoc.
– set encryption.
– register for connection event notification.
– set SSID.
– check connected notification.

From WM 5.0, WM applications use Connection Manager (refs) to request network connection. Connection Manager will choose the best connection. IE for example will requires a connection even if the device is associated with an AP with the code above.
Hence point 3.

3. Provide Connection Settings with Connection Manager API.
TODO:

=== Conclusion

It took me awhile to know the way around msdn. Instead of directly diving into msdn doku and get lost and tired of them, a lot of good introduction articles in msdn magazine help you understand the whole picture more quickly.
NDIS is in msdn well documented. It’s also easy to understand having source code from open community as reference. Connection Manager appears in the search results for Wifi API but doesn’t really provide a hint, how a wlan connection can be built.

=== Resources:
== NDIS ==
— msdn.
http://www.tech-archive.net/Archive/PocketPC/microsoft.public.pocketpc.wireless/2007-01/msg00004.html
— wpa_supplicant.
== Connection Manager ==
http://blogs.msdn.com/b/cenet/archive/2006/06/06/620360.aspx
http://archive.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=mag200812GoingPlaces&ReleaseId=1819
http://msdn.microsoft.com/en-us/magazine/dd263096.aspx?pr=blog
http://msdn.microsoft.com/en-us/library/ee497077%28v=WinEmbedded.60%29.aspx

My Fedora Linux

I haven’t found a way to type Vietnamese with my Linux. So it’s best to post a picture of my Fedora. Next post might be ‘How to input Vietnamese in Linux’. O je, how to take a screenshot!? never did this before :)).

Ok, Google points to this hint:

gnome-panel-screenshot

and with delay

gnome-panel-screenshot --delay 10

voila!

fed_td_20110306

Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!