Mac OSX で動画を PSP 用に変換する

携帯動画変換ちゃんを使えば、QVGA や 368×208 などの解像度で PSP 用の動画に変換することは簡単にできるけど、せっかく 480×272 の解像度なんだからその大きさに合わせて変換したいと思っていろいろ探してやっとできるようになったので、まとめておく。



  1. 携帯動画変換君 ( を MobileHackerz からダウンロードして展開
  2. ffmpeg (OSX用バイナリ) を らけった::ffmpeg SVN-r8638u からダウンロード
  3. ffmpeg_svnr8638 を 3GP_Converter/cores に保存
  4. 携帯動画変換ちゃん ( を 配布サイト からダウンロード
  5. 携帯動画変換ちゃんを 3GP_Converter のフォルダに保存
  6. fixtitle を 3GP_Converter/cores に保存
  7. Transcoding_PSP.ini を 3GP_Converter/default_settings 以下に作成 (サンプルは下)


PSP 向け Transcoding.ini のサンプル

Title=Model: MP4 for PSP
TitleE=Model: MP4, for PSP
Description=Copied from and then modified to 480x272 and 368x272
; 480x272 (16:9)
Title=AVC 480x272(16:9) 1pass ABR/入力と同じfps/768kbps ステレオ/128kbps
TitleE=AVC 480x272/768kbps Stereo/128kbps
Command0=""<%AppPath%>/cores/ffmpeg_SVN-r8638u" -y -i "<%InputFile%>" -timestamp "<%TimeStamp%>" -s 480x272 -b 768k -vcodec h264 -coder 1 -level 30 -aspect 16:9 -bufsize 2048kb -g 250 -mbd 2 -cmp 2 -subcmp 2 -qmin 10 -qmax 51 -crf 20 -trellis 2 -me umh -me_range 16 -subq 6 -chroma 1 -refs 3 -partitions all -acodec aac -ac 2 -ar 48000 -ab 128k "<%OutputFile%>.MP4""
Command1=""<%AppPath%>/cores/ffmpeg_SVN-r8638u" -y -i "<%InputFile%>" -f image2 -ss 5 -vframes 1 -s 160x120 -an "<%OutputFile%>.jpg""
; 368x272 (4:3)
Title=AVC 368x272(4:3) 1pass ABR/入力と同じfps/768kbps ステレオ/128kbps
TitleE=AVC 368x272/768kbps Stereo/128kbps
Command0=""<%AppPath%>/cores/ffmpeg_SVN-r8638u" -y -i "<%InputFile%>" -timestamp "<%TimeStamp%>" -s 368x272 -b 768k -vcodec h264 -coder 1 -level 30 -aspect 4:3 -bufsize 2048kb -g 250 -mbd 2 -cmp 2 -subcmp 2 -qmin 10 -qmax 51 -crf 20 -trellis 2 -me umh -me_range 16 -subq 6 -chroma 1 -refs 3 -partitions all -acodec aac -ac 2 -ar 48000 -ab 128k "<%OutputFile%>.MP4""
Command1=""<%AppPath%>/cores/ffmpeg_SVN-r8638u" -y -i "<%InputFile%>" -f image2 -ss 5 -vframes 1 -s 160x120 -an "<%OutputFile%>.jpg""

参考: 雲の流れるままに – エンコ設定を貼り付けとく

Mac OSX で動画を PSP 用に変換する

How to shutdown a server


The linked article describes example of how to shutdown a server by anyone from beginners to experts. This is the summary.

Beginners: Login as root and then shutdown.

Intermediates: Login as root, and then check if active TCP connection, services and processes. Shutdown the services and the processes. Shutdown the server.

Experts: Confirm input command several times, and then press enter. Shutdown after doing “sync” x3 and confirm if he miss some operations. Experts are very cautious.

At the end of article, he wrote commands when he shutdown a server.

# ps -ef|more
# netstat -an|more
# w
# free

ps – report a snapshot of the current processes.
-e Select all processes.
-f does full-format listing.

netstat – Display  network  connections, routing tables, interface statistics, masquerade connections, netlink messages, and multicast memberships
-a print all sockets, including the listening server sockets.
-n shows numerical  addresses instead of trying to determine symbolic host, port or user names.

w – Show who is logged on and what they are doing.
free – Display amount of free and used memory in the system

How to shutdown a server

Building a full-text search engine in “ONE” day

Building a full-text search engine in “ONE” day

stanaka who is a developer in Hatena Inc. wrote a full-text search engine in a day. He wrote the code as an outcome of reading introduction to Information Retrieval.

It tokenizes strings with bi-gram for multi-bytes characters and with delimiter for single-byte characters.

The indexer that is the first example code puts tokens to hash. The searcher  searches each token recursively if its keyword is multi-bytes and then merge the results. If its keyword is single-byte, it simply gets the results in the hash.

The sample data contains number of bookmarks (bcount), and number of stars (scount). Number of bookmarks comes from Hatena Bookmark which is the most popular social bookmarks service in Japan. Number of starts come from Hatena Star which is a kind of rating service. It’s a tool to express your appreciation.

Basically the scoring of this search engine is based on the “bcount”, “scount” and “date.” You can change its weight.

The source code is published at

Building a full-text search engine in “ONE” day

Check points of security for your web apps


There is some articles about the security of web application.The article title is “Why there are a lot of security holes in PHP applications.” But the articles are described how to avoid security hole on your web apps. It’s more conceptual than PHP specific know how.

I pick up some points from these articles.

SQL injection
There are 2 ways to prevent SQL injection according to the article.

  • Escape all variables
  • Execute all query as prepared query

He reccomend to use prepared query.

Script injection
There are 10 check items to prevent script injection (for PHP).

  • Define default character code (default_charset) in HTTP header
  • Verify character code against input values
  • Have strict validation rule against input values
  • Escape output strings as default
  • Make sure that the output strings is safe if you output the strings as is
  • Do not allow any HTML tags in strip_tags()
  • Do not use regular expression to parse HTML
  • Verify strings with strict “white list” if you output HTML tags and/or attributes
  • Verify strings with strict “white list” if you generate CSS dynamically with input values
  • Verify strings with strict “white list” if you generate Javascript dynamically with input values
Check points of security for your web apps