Saturday, August 16, 2008

Microblog-Purple 0.1.2

Last week I create 2 releases of #mbpurple (Microblog-purple), a plug-in for Pidgin that make you communicate with Microblog like twitter.com. Latest release is 0.1.2. These releases fix lots of bug that occurred when there's something wrong with network connection, which may crash Pidgin. At least for me it's very stable now. Also, a potential memory leak has been fixed too.

Download it at Microblog-Purple project page.

Friday, August 15, 2008

OpenVPN on Vista

OpenVPN GUI ที่ใช้อยู่เกิดมีปัญหากับ Vista เพราะ add default route ไม่ได้ วิธีแก้ตอนนี้ง่ายๆคือไปหา OpenVPN เวอร์ชันใหม่ (ตอนนี้เป็น 2.1_rc9) มาลง และเวลารัน ให้กด Run as Administrator ด้วย ไม่งั้นจะติด permission add route ไม่ได้

อันนี้ผมลองลงด้วยการ Run as administrator ด้วยแล้วนะ ก็ยังไม่ได้ ต้อง Run as administrator ตลอดเวลาเลย

Sunday, August 03, 2008

:: JustUsers.net :: การแปลง DVD9 เป็น DVD5 ที่ถูกต้อง

ในที่สุดก็มีคนทำ doc วิธีการทำ CCE9Pass จนได้ เยี่ยมจริงๆ

:: JustUsers.net :: การแปลง DVD9 เป็น DVD5 ที่ถูกต้อง

ขออนุญาตก๊อปมานะครับ กลัวหายไป

** content ด้านล่างนี้ ก๊อปปี้มาจากเว็บข้างต้นทั้งสิ้น ผมไม่ได้ทำเอง **

ก่อนอื่นต้องศึกษาโครงสร้างของ DVD ก่อนครับ โดยใช้โปรแกรม DVD Remake Pro
เปิดโปรแกรม DVD Remake Pro แล้ว Import DVD
ทั้งนี้ DVD อาจอยู่ในรูป image file แล้ว mount ด้วย alcohol 120% หรือ daemon tool แต่ถ้าเป็นแผ่น DVD ที่ยังมีการ protect ไว้ แนะนำว่าให้ทำ image โดยใช้ dvddecryptor ก่อน
แต่อย่างที่บอกละครับว่า dvddecryptor มันนานแล้วอาจไม่มีการพัฒนาต่อ ให้ลง anydvd ก่อน แล้ว set ค่า โดยใช้การถอดรหัสของ anydvd ช่วยตามรูป



หลังจากนั้นก็แค่ update anydvd เป็น version ใหม่ๆ ท่านก็สามารถใช้ dvddecryptor ในการถอดรหัสทำ image file ได้ตลอด หลังจากนั้นไปที่ dvddecryptor เลือก mode เป็น ISO Read
แล้วกด decrypt รอสักพักก็จะได้ dvd image นามสกุล ISO ไว้ในเครื่อง
เมื่อ Import DVD แล้วให้กด Select ตามรูป



ก่อนที่จะทำอะไรต่อให้ Save Projectไว้ก่อน ไปที่ file Save project
ตัว DVD Remake Pro จะมีหน้าตาดังรูป



ด้านซ้ายมือจะเป็น VTS ต่างๆ สังเกตว่า VTS ที่ใหญ่ที่สุดจะเป็นตัวหนัง+Menu ส่วน VTS ที่เหลือจะเป็น special feature เป็นส่วนใหญ่
DVD ที่ผมใช้เป็นตัวอย่างคือ นางฟ้าชาลีภาค 2
เรามาดู VTS อันแรก Video Manager



ตรง domain content ที่เป็นช่อง 4 เหลี่ยม แถวยาวจะแสดงว่าแต่ละ VTS นั้นมี Block อะไรบ้าง อย่างเช่น Video Manager block ส่วนใหญ่จะเป็น title ของ บริษัทหนัง หรือ คำเตือน หรือ Menu เลือกภาษา เลือกที่แต่ละ Block แล้วกด Play ปุ่มสามเหลี่ยมด้านล่างก็จะรู้ว่าเป็น Block เปล่าๆ หรือมี Content อะไร จริงๆ ดูจากขนาดก็น่าจะทราบได้

หลังจากนั้น Block ไหนที่เราไม่ต้องการก็ให้ กด Mouse click ขวา แล้ว Hide Block แต่จำว่าหลัง Save Project แล้ว ถ้าเราต้องการ Block ไหนกลับมาจะใช้ Restore Block ไม่ได้



โดยปกติผมจะไม่ยุ่งกับ Video Manager เพราะอาจทำให้เปิดแผ่น DVD ไม่ติด ยกเว้น Block คำเตือนภาษาต่างๆ หรือปิด Button ใน Menu เลือกภาษา
ถ้า VTS ไหนมั่นใจแน่ๆ ว่าไม่เอา เลือก Hide all block ไปเลย



ที่นี้มาดูขั้นตอนสำคัญของการใช้ DVD Remake Pro คือ ปิด Button ที่ไม่ใช้งาน
ไปที่ VTS ใหญ่สุด เป็นตัวหนัง+ Menu
เลือก ที่ VTS6 จะเป็นตัวหนัง



หรือจะเลือกที่ Menu ตามภาพ



ก่อนอื่นถ้าหากว่าเจอ Menu เลือกภาษา ให้ปิดภาษาที่ไม่ได้ใช้ก่อนเลย เช่น ภาษาจีน เลือก Hide Button



หลักการมีอยู่ว่าก่อนที่จะปิด Button ไหน ให้ท่านลองกดใช้งาน Button นั้นดูก่อนว่ามัน Link ต่อไป Menu อะไร อาจจะลองเล่นในเครื่องเล่น DVD ดูก่อน หรือใช้ Program เช่น PowerDVD
อย่าง Button ที่เราปิดตามข้างบน จะทำให้ไม่สามารถเข้า Menu นี้ได้



หากต้องการปิด Button Designing Angels ตามรูป



ก่อนอื่นต้องดูว่า Designing Angels อยู่ใน VTS ไหน จากภาพ อยู่ใน VTS ที่ 2



ถ้าใน VTS นั้นๆ Block มี Block ที่เราต้องการปิดเท่านั้น ไม่มี Block อื่นๆ ที่เป็น Feature อยู่เลย (ไม่สน Block ที่เป็น Blank ไม่มีตัว file หนัง) อาจ Hide all block ไปได้เลย แล้วก็ไป Hide Button ต่อกันไปได้เลย
หลักๆในการปิด Button ก็มีเท่านี้

เรามาดูรายละเอียดที่ตัวหนัง VTS6 พบว่ามี Stream เสียง หลายเสียง (ดูที่ Audio Tasks ด้านขวามือ)



โดยหลักแล้ว DVD ส่วนใหญ่จะมีเสียง
Dolby Digital 5.1 Eng
Dolby Digital 5.1 Thai
DTS
Commentary

โดยปกติ ตัด DTS และ Commentary ออกไป คงเสียง Eng และ Thai ไว้
ถามว่าจะรู้ได้อย่างว่า stream ไหนเป็นเสียงอะไรบ้าง ดูจาก PowerDVD ได้



หลังจากนั้นก็ Disable Track in all PGC สำหรับเสียงที่ไม่ต้องการ
และอย่าลืมไปปิด Button เสียงที่เรา Disable ไปด้วย

ส่วน Subtitle ขอย้ำนะครับ ว่าให้เก็บไว้หมด ไม่ควรไปยุ่ง อะไรกับมัน เพราะการตัดทิ้งหรือไม่ ไม่มีผลกับคุณภาพ DVD ที่ได้แปลงแล้วแต่อย่างใด

หลังจากที่ปิด Feature ที่ไม่ต้องการจนพอใจเลือก Export DVD เลือก folder ที่จะ Save
หลังจากนั้นจะได้ Vob file เลือก file .IFO อันแรกซึ่งจะเป็น Menu ตามรูปเพื่อเล่นกับ PowerDVD แล้วดูว่าใช้ได้ตามความต้องการหรือยัง ก่อนที่จะใช้ DVDShrink หรือ Nero Recode สร้าง image ต่อไป



จาก การดู รายละเอียดของ DVD โดยใช้ DVD Remake Pro เราจะพบว่า DVD บางเรื่องมีขนาดตัวหนัง+Menu ไม่เกิน DVD5 เช่นเรื่องนี้ เราแค่ปิด feature แล้วใช้ DVD shrink รวมเป็น image ก็ได้ โดยไม่จำเป็นต้องใช้ DVD Rebuilder+CCE ด้วยซ้ำไป (สมัยก่อนผมใช้วิธีนี้เพราะ Com ไม่แรง)แต่ถ้าหากพบว่าใช้ DVD Remake Pro ลดขนาด DVD ไปแล้ว ยังเกินกว่า 5.5 G หรือ ต้องการเสียง Eng และ Thai
แนะนำว่าต้องใช้ DVD rebuilder+CCE ตามที่ผมจะกล่าวต่อไปนี้ (นำเอา file DVD ที่ตัด feature และ ปิด Button แล้ว ไปลดขนาดลง โดยใช้ DVD rebuilder+CCE)

หากหนัง DVD มีความยาวเกินกว่า 2.5 ชั่วโมงให้ใช้ DVD FAB ในการแบ่งเป็น DVD5 2 แผ่นแทน

ก่อนอื่นให้เข้าไปที่ rebuilder.ini ใน folder DVD-RB PRO เพิ่มข้อความตามรูป แล้ว Save



ซึ่งจะทำให้ได้ขนาด DVD เต็ม DVD5 ไม่งั้นอาจจะเจอปัญหาแปลงแล้ว ต่ำกว่า 4G หรือเกินกว่า 4.37 G

หลังจากนั้น Set ค่าตามรูปได้เลย











General set up ไม่ต้องไป set อะไรเลย ครับ เพราะเราเลือกเสียงกับ Sub จากใน DVD Remake Pro แล้ว

ในส่วนการ Set up ค่าของ CCE ใช้ตามรูป (คือ ค่า Default)





ให้เลือกใช้ 6 pass ดีที่สุดแล้วครับ เกินกว่านี้ดู TV ก็แยกไม่ออกหรอกว่าดีขึ้นหรือไม่
หลังจากนั้นก็กด Back Up ถ้า Com ผม Athlon X2 3800 Ram2 G ก็ใช้เวลาประมาณ 4-6 ชั่วโมงแล้วแต่ความยาวหนัง

ISO ที่แปลงเสร็จแล้วจะอยู่ใน folder output ซึ่ง folder เหล่านี้ สามารถ set เองได้ในหน้า general set up




Software ที่ใช้ทั้งหมด
- AnyDVD
- Cinema Craft Encoder SP v2.70.2.0
- DVDFab Platinum v.2.9.7.5
- DvdReMakePro 3.14
- DVD Rebuilder Pro
- DVD Decryptor 3.5.4.0


แนะนำเพิ่มเติม
1. ถ้าใช้ DVD Remake Pro disable Audio track ไปแล้ว ก็ ให้มา กดเป็นกากบาทตรง track ใน DVD Rebuilder pro ด้วย เวลาเข้า player มันจะไม่มี ให้เลือก มันจะข้ามไปให้ ไม่งั้น มันจะเป็นช่องเสียงว่างๆ ...
2. ใช้ DVD Deceypter อ่านออกมาอย่าให้อยู่ในรูป ISO ให้ออกมาเป็น mode file เลยดีกว่า เพราะถ้าเครื่องไม่แรงเนี้ย กว่าจะ export ออกมาได้ทีนี่นานอะ ให้ใช้เป็น mode file แล้ว ใช้ dvd remoke export เฉพาะ modifield แทนอะ แล้วก็ copy ไปแทนที่ folder เดิม ทุ่นเวลาได้เยอะเลย
อีกอย่างเลือก เป็น 64FPU หรือ 64IEEE ด้วยก็ดีนะ ... อย่าไปใช้ standard อะ ... ตามรูปๆๆ iDCT นี่อะ


1 กรกฎาคม 2549

Friday, August 01, 2008

Microblog-Purple 0.1

It's beginning on Thursday 2 weeks earlier. I start feeling irritate more and more with my Google Twitter Gadget. The update failed silently, bugs in GUI that made lots of empty space between each tweet, and I have to re-login every time I turn on my laptop. And well, I'm more used to the way twitter communicate with my IM. Having it only on desktop gadget made me miss a lot of tweets.

So I decided to do something. And here it is. Microblog-purple project is a Pidgin plug-in that make your Pidgin or any LibPurple-base client, like Finch (tested) or Adium (hopefully it'll works. Waiting for @markpeak), communicate with twitter.com directly. I spent last two weeks coding this during my free time, with the help of my friends. The very first alpha came out last week (in SVN), and now I think it's stable enough to have the official release (0.1).

Please see the download page to download the plug-in for your platform. Right now we have Windows and Ubuntu (32|64)bit. Many thanks to
  • @sugree - features, bug fixes, Windows installer, and Ubuntu port
  • @chanwit - nice patch for text formatting. make my life much easier.

Wednesday, May 28, 2008

Water leakage

This is the third time that we 've leakage in our house. This time it's quite serious, because I don't know when it start "massive" leaking. I woke up this morning and found that our bathroom is flood with lots of water.

it is really broken into two pieces. this is what's left attached to my wall.

I found that our pipe connector was just broken into 2 pieces. It occurred before stop-valve so there's no choice but to stop water coming to both of our bathrooms. Today me and my wife have to use water stocked from bucket by our external or kitchen faucet.

The problem occurred because we use galvanize-base pipe connector. All 3 leakages have exactly the same problem. Either water supply in Thailand is not clean enough, or the galvanize pipe connector is not durable enough. I don't know which one. But I'll not using this type of connector again. This is just about a year and a half since my house is finished.

The copper-base connector seems to be more durable. I bought one ready for this fix.

copper-base pipe connector. Thai name is "เกลียวนอกเกลียวใน"

From the quick look, this is the last joint with galvanize connector. Hope that our showers is not connected with galvanize.

Right now I'm still waiting for water supply technician to help me. I don't dare to fix it myself or it might broken the PVC pipe, which will lead to a lot of chaos.

Update 12:00pm

The fix was just finished. I found a lots of tip

1. Don't use lead or galvanize connector. It's fragile. Use copper instead.

2. Don't use plier to wheel the connector to PVC pipe. It might break the pipe, especially after some demolition using nail to demolish the rest of connector

3. Use lots of rubber tape for the connector, don't put stop-valve directly with PVC pipe. It might break PVC pipe when moved. Copper connector can help lessen the force apply to the pipe


The key to destroy the connector is by using concrete nail. Slowly and softly hammer the rest of connector with concrete nail. Be patient.

Thursday, May 22, 2008

Getting issuer hash from a root CA

I forgot this all the time
openssl x509 -issuer_hash -noout -in cacert.org.crt

Sunday, April 20, 2008

DVD Encoding with Mplayer2

I recently having some problem playing the recorded TV program from my Snazio Video Capture card. The card can record to MPEG1, MPEG2 stream, and also VCD and DVD format, even the DivX format is supported. However, the generated DVD stream is not compliant with DVD format and need to be reencoded! Recorded DivX file also have problem in picture/sound synchronization.

I usually do the record using DVD format and write the raw .mpeg file to playback on my Philips DVP-3040K. It works fine unless the file size is less than 2GB, which is the limit of ISO format file size. However, some TV program in Thailand is 2 hours+ length, which usually yield about 4GB file size.

One way to fix this is to stop recording in the middle :). But that requires me to sit and wait for commercial ads to press stop. So I need some solution to quickly fix the stream and put it into DVD-Video.

I tried Cuttermaran + BatchDemux + DVDAuthorGUI and it works quite well for me. Except that the generated DVD Video can play but not seek on my DVP-3040K! (Somehow it can seek on other DVD player.......). So I need to find some other solution.

If I need to do encoding, DivX encode would be great. I had done XVID encoding and it works very well in term of quality and file size. However, the quality of generated file, when played on my DVP-3040K, will be a little bit worse than DVD-Video file, which is not too bad. The worst thing is that the player stop playing the video after about 1:30 hour of playing. I can't seek to the point after that too. I wonder why this is happening but seems DVP-3040K has some trouble with large DivX file...... (it has problem with DVD image too, can't see any file after 700th file on my DVD-Image).

So I tried TMPGenc DVD Author, a good old tool that I used for so long. There's no problem in the output but the time required to produce one takes about 2 hours, not including time to cut the commercial ad out. I want some quicker solution. Which I think I found at last......

Mplayer 1.0rc2 now can generate EDL files, a file list the start/end point to skip the play back. Combining with Mencoder, this can be used to quickly generate a DVD Video that's playable on my DVP-3040K.
mplayer -edlout edl.txt file.mpg

mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf -vf scale=720:576,harddup -srate 48000 -af lavcresample=48000 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=15:vstrict=0:acodec=ac3:abitrate=192:aspect=16/9 -ofps 25 -o C:\Temp\output.mpg -edl edl.txt TV_20080417_203429.mpg

Press "i" during play back to record start/end point of commercial ads. This is very quick and the file can also being used for other application as well (it's just a text file). The quality of encoded DVD is good enough (a little bit worse than TMPGenc). But it took only 60 minutes to encode the video on my laptop. Should be quicker on faster desktop machine.

The generated output.mpg still need to be process by TMPGenc DVD Author or DVDAuthorGUI, but it takes about 20-30 minutes to work with that (not including DVD Writing time of course). At least I find something that's working well and quick for me.

Saturday, February 23, 2008

Video encoding

อาทิตย์ที่ผ่านมา ผมเกิดมีโอกาศจะต้องทำอะไรๆเกี่ยวกับการแปลง/อัดหนังจากทีวี และดีวีดี จากแต่เดิมที่คิดว่าทำเป็นอยู่แล้วพบว่าตัวเองยังไม่รู้อะไรอีกเยอะเลยครับ

โจทย์ของผมมี 2 ข้อ 1. มีดีวีดีแต่เป็น DVD9 จะเก็บยังไงให้สะดวก 2. มีหนังทีวีที่อัดมา (หนังไทยนี่แหละ) แล้วจะมาแปลงให้ดูได้ทำยังไงถึงจะดีที่สุด

โจทย์จริงๆก็ไม่ยากครับ tool ที่จะช่วยนั้นหาได้ไม่ยากเลย มีทั้งฟรีและไม่ฟรี แต่สิ่งที่แตกต่างกันคือ คุณภาพและความถูกต้องของผลลัพธ์

เอาโจทย์แรกก่อน ไม่ขอบอกว่าหนังอะไรละกันครับ แต่เป็นหนังซีรีส์ของ US (มั้ง) ที่คงยังไม่มีลิขสิทธิ์ในไทยแน่ๆ เพราะได้แผ่นมาจากเพื่อนที่อยู่ต่างประเทศ ก่อนอื่นผมลองด้วย dvdshrink กับ dvd fab platinum ก่อนเลย ผลที่ได้ไม่ค่อยจะดีเท่าไหร่ เพราะคุณภาพของหนังลดไปเหลือแค่ 62% หลังตัด subtitle และเสียงต่างๆออกไปหมดแล้ว พอดูด้วยเครื่องเล่น DVD ปรากฎว่าภาพบางช่วงมืดๆสว่างๆด้วย แปลกดี และภาพก็แตกเห็นเป็นเหลี่ยมๆ ผมดูแล้วรับไม่ค่อยได้เท่าไหร่ อ้อ เครื่องเล่นของผมคือ Philips DVD3040k เล่น Divx ได้ แถมเล่น Divx Subtitle หรือจริงๆก็คือไฟล์พวก .srt ได้ด้วย

ผมมาคิดๆดูคุณภาพมันลดไปตั้ง 40% มันก็คงจะไม่แปลกที่มันจะห่วยลงมาก อีกอย่างคือมันเป็นหนังซีรีส์ รวมเวลาของหนังทั้งหมดแล้วราวๆ 200 นาทีแน่ะ ยาวกว่า DVD หนังปกติ (ในแผ่นไม่มี Extras เลย) คงเป็นอีกสาเหตุที่คุณภาพของหนังลดลงมาก ผมเลยมองหาทางเลือกอื่นคือใช้ Encoder คุณภาพสูงมากๆมาช่วย ผมเห็นที่เขานิยม
กันมากๆก็คือ CCE รู้จักแต่ชื่อย่อแต่ไม่รู้สักทีว่าจริงๆมันคืออะไร ลองถาม Google ดูก็คิดว่าคงเป็น Cinema Craft Encoder ครับ เป็น Encoder ที่ Encode VBR multipass ได้หลายๆ Pass แบบว่ากดเลือกๆได้เลยว่าจะเอากี่ Pass ปัญหาของผมคือ CCE เป็นแค่ Encoder แต่เราต้องการ DVD Editor มาตัดพวก Subtitle, เสียงภาษาอื่นๆทิ้งไปเพื่อเพิ่มที่ด้วย สุดท้ายมาลงที่ DVD Rebuilder Pro ซึ่งจะตัดเสียงพวกนี้และส่งต่อให้ CCE Encode และลดขนาดเหลือ DVD5 ได้

แต่ปรากฎว่าผลกลับไม่เป็นอย่างที่คิด เพราะ DVD RB ดันทำไฟล์ออกมา โดยตัดเหลือแค่หนังตอนแรกเท่านั้น ผมเข้าใจว่าปกติมันคงจะเซ็ตเอาไว้ดึงเอาหนังหลักกับเมนู โดยตัด Extras ทั้งหมดทิ้งไป ผลเลยกลายเป็นยังงี้ ผมลองเลือกแบบไม่ตัดอะไรเลยก็ไม่สำเร็จ แถมทำแต่ละทีเสียเวลาชมัดเลย สุดท้ายผมเลยไม่ได้เลือกวิธีนี้

ระหว่างนั้นผมลองอีกวิธีคือการทำ paralle mencoder โดยใช้ xvidenc ซึ่งให้ผลดีกว่าใช้ lavc มากเลยครับ ภาพคมชัดดีทีเดียว ขนาดไฟล์ก็เล็กลงจนสามารถเก็บลงใน DVD5 แผ่นเดียวได้ ที่ติดปัญหาก็คือเรื่องซับไตเติ้ล ผมใช้ subrip ดึง sub ออกมาและปรับๆนิดหน่อยก็ใช้ได้ จริงๆแล้วซับอังกฤษมีให้ดาวน์โหลดด้วยแหละครับถ้าหาดีๆ แต่ timing มันจะไม่ตรงกัน (ไม่รู้ทำไม)

แต่โจทย์เรื่องหนังทีวีนี่หนักหน่อย แรกสุดก็ใช้ TMPGenc Dvd Author3 ซึ่งก็ได้ผลดีทีเดียว คือหนังออกมาเวิร์คใช้ได้ แต่ไม่ชัดครับ ไม่รู้ทำไม TMPGenc แต่ก่อนถือว่าใช้ได้แต่ตอนนี้พอ encode ออกมาแล้วกลับไม่ค่อยจะชัดเท่าไหร่ ขนาดปรับขนาดให้ออกมาใหญ่มากก็ยังไม่ชัด

ทางเลือกอื่นๆก็มีอีกหลายทาง แต่ปัญหาคือทำยังไงถึงจะตัดโฆษณาออกไปได้ โปรแกรมที่น่าใช้อีกตัวคือ Cuttermaran อ้อ แล้วก็ Adobe Premiere ด้วย แต่ทั้งคู่ก็ยังให้ผลได้ไม่ดี Adobe Premiere จริงๆแล้วคงใช้ได้ แต่เวลา Encode นานมากเลยทีเดียว ผมพยายาม Encode ผ่าน CCE แล้วปรากฎว่าไฟล์ออกมาเสียงกับภาพไม่ตรงกัน Cuttermaran ตัด Mpeg ได้โดยไม่ต้อง reencode แต่เสียงกับภาพจะเหลื่อมกันอีก มีวิธีแปลกๆอีกคือใช้โปรแกรม Comskip ซึ่งจะ detect หาโฆษณาและตัดออกให้อัตโนมัติ แต่ว่ารันตั้งนานก็ยังวิเคราะห์ไม่เสร็จสักที ตัดเองยังเร็วกว่าครับ (เพราะหนังไม่ยาว) แล้วก็อีกวิธีก็คือใช้ Mpalyer เล่นในโหมด edlout เพื่อระบุช่วงเวลาที่จะ skip แต่บน Windows กลับไม่เวิร์ค EDL ที่สร้างออกมา timing ผิดหมดเลย สุดท้ายก็ต้องยอมแพ้กลับไปใช้ TMPGenc แต่ Encode เป็น Divx นะ ก็เวิร์คดีครับ แค่ไม่ค่อยชัด เอาไว้คราวหน้าค่อยลอง Cuttermaran + Mplayer ดีๆอีกที

Saturday, December 08, 2007

Convert ชื่อไฟล์ภาษาไทยที่มาแบบผิดๆ ให้อ่านออก

เนื่องจากโปรแกรมที่ใช้ดาวน์โหลดไฟล์ตอนนี้มีปัญหากับภาษาไทย (ทีเ่ป็น tis-620) พอสมควร เลยต้องเขียนโปรแกรมมาแก้ชื่อไฟล์จากเดิมภาษาไทย (แบบผิดๆ ที่เป็น utf8 ทั้งๆที่จริงๆต้องเป็น tis-620) ให้กลายเป็น tis-620 แบบที่อ่านได้ใน windows

import os, sys, string

encoder = 'cp874'
decoder = 'utf8'

def replace_invalid_char(line,utf_char,tis_char):
return line.replace(utf_char,tis_char)

def convertline(line):
# CHECK INVALID CHAR
# line=replace_invalid_char(line,"\xe2\x80\x98","'")
# line=replace_invalid_char(line,"\xe2\x80\x99","'")
# line=replace_invalid_char(line,"\xe2\x80\x9c",'"')
# line=replace_invalid_char(line,"\xe2\x80\x9d",'"')
# line=replace_invalid_char(line,"\xe2\x80\xa6","...")
# line=replace_invalid_char(line,"\xef\x9c\x8f","\xe0\xb8\x8d") #YOR YING
# line=replace_invalid_char(line,"\xef\x9c\x9a","\xe0\xb8\xba") #PINTU
# line=replace_invalid_char(line,"\xe2\x80\x93","-")
# line=replace_invalid_char(line,"\xef\x82\xae","->")
# line=replace_invalid_char(line,"\xef\xa3\x82","?") # UNKNOWN
# line=replace_invalid_char(line,"\xef\xa3\x83","?") # UNKNOWN
return line.decode(decoder).encode(encoder)

f = open('error.txt', 'w')
for root, dirs, files in os.walk('.') :
for ent in files + dirs :
if ent == '.' or ent == '..' :
continue
try :
new_name = convertline(ent)
except :
f.write('convert:' + os.path.join(root, ent) + '\n')
continue
if new_name != ent :
src = os.path.join(root, ent)
dest = os.path.join(root, new_name)
#print 'renaming ' + src + ' -> ' + dest
try :
os.rename(src, dest)
except :
f.write('permission:' + src + '->' + dest + '\n')
f.close()


เอาบางส่วนของโค้ดมาจาก http://www.thaitux.info/node/115 ครับ

Friday, November 16, 2007

ลง Office2007 ไม่ได้!

เจอปัญหาแปลกๆอีกล่ะ สาเหตุเพราะ... นะ เพราะ WindowsXP ที่ลงน่ะแหละ แต่สรุปว่าไฟล์บางไฟล์ที่ควรจะมี มันกลับหายไป ไฟล์นั้นคือ c:\program files\common files\microsoft shared\web server extensions\40\bin\fp4autl.dll ไปดาวน์โหลดไฟล์จาก

http://www.dlldump.com/download-dll-files_new.php/dllfiles/F/fp4autl.dll/4.0.2.7523/download.html


มาวางก็เป็นอันใช้ได้

Thursday, November 01, 2007

Convert WMA to MP3 - LinuxQuestions.org

Command สำหรับการแกะ wav ออกจากไฟล์ wma บน Linux
mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader input_file

จะได้ไฟล์ autidodump.wav มา แก้ได้โดย -dumpfile (มั้ง)

Monday, October 08, 2007

Python Script สำหรับเปลี่ยน FourCC ของไฟล์ AVI

ไปเจอสคริปต์ในเน็ต เอามาแก้ดูก็ใช้ได้ดีบนวินโดวส์นะ
#!/usr/bin/env python
import sys, glob

if len(sys.argv[1:]) < 2:
print """USAGE: %s ....
Displays old FourCC and optionally changes it to the given new one.""" % (
sys.argv[0])
sys.exit(1)

newFourCC = sys.argv[1]
assert len(newFourCC) == 4

for arg in sys.argv[2:] :
for fname in glob.glob(arg) :
f = file(fname, "r+b")

f.seek(0x70)
a = f.read(4)
f.seek(0xbc)
b = f.read(4)
print 'old fourcc %s: ' % fname, a, b

f.seek(0x70)
f.write(newFourCC)
f.seek(0xbc)
f.write(newFourCC)
f.close()

Monday, June 04, 2007

Syncing Google Calendar with Phone Mobile (various approach)

I just purchase a cheap multimedia phone Nokia 3110 classic. Since this Mobile support GPRS/EDGE and have built-in Calendar & SyncML (are there still any phone without this functionality). I'm interest in synching its calendar with my Google Calendar. Somehow I have multiple calendar which I want to sync with my mobile phone Calendar, so the solution must be able to sync multiple calendar with my phone. There's somehow many solutions
  1. Syncing Google Calendar with Outlook Calendar and sync again with Nokia PC Suite - I can't do this since I'm not using Outlook anymore.
  2. Gcalsync - This seems to be the best solution. Somehow it's not 100% working for me. Gcalsync refuse to connect to my Calendar (invalid ports). And I can't set my phone proxy as said in Gcalsync web-site. Anyways I can sync the calendar if I specified my full private URL, thus means I can only sync 1 calendar.
  3. Scheduleworld - A free services, using Open-Source sync server funambol & SyncML, which you can store your mobile phone contacts, calendar, and notes on server. Scheduleworld can also sync with Google Calendar, although only one calendar at a time (but you can specify any Calendar). This works for me. But again, one calendar.
  4. Goosync - A (partially) free services to sync Google Calendar with Mobile phone Calendar using SyncML. This seems to be my perfect solution. Somehow syncing multiple calendar is not free. Free service only allow you to sync your default Calendar. I don't sure if this works because I didn't try it out, but looks very promising.
  5. WAP page of Google Calendar - Google actually have a WAP page to access Calendar on Mobile phone. Anyways think of the cost that I need to pay to access it every time. Anyways I can use this to add my event & appointment.
Anyways I found my solution. I setup Gcalsync to sync my personal Calendar, while setting Scheduleworld to sync my work Calendar. This updates my phone Calendar with both Google Calendars that I want. I'll wait until Gcalsync work totally for me and switch back to 100% Gcalsync. For now this is just works.

Friday, May 25, 2007

Setting per-node slot for SGE

Instead of disable hyper-threading, we can also
qconf -sq all.q

Then change the number after "hostname=" to appropriate value

Thursday, May 24, 2007

IPMI Tool

IPMI setup on Linux
  1. service ipmi start
  2. ipmitool -I open chassis status
  3. ipmitool -I open sdr list
  4. ipmitool -I open sensor list

Sunday, May 13, 2007

Solaris 10 Patch (update) management

คำสั่งที่สำคัญ
  1. pprosetup - Setup patch เช่น บอกให้รันทุกวัน ทุกเดือน ฯลฯ
  2. pprosvc - download & install patch (น่าจะคล้ายๆ yum)
  3. smpatch - ลง patch (ใช้เวลาที่ลง patch ไม่ได้)