2013年6月5日 星期三

ffmpeg 使用心得







使用了一陣子的 FFMpeg 處理影片,越用越喜歡這套軟體。
一開始,為了要將影片轉成 ipod touch 3代,可用的格式,特別學習
ffmpeg,試了好幾天,終於找出來滿意的方法,特此記錄下來,免得忘了。

轉檔時的指令

ffmpeg -i $1 -s 720x406 -vpre ipod -ac 2 -sn -y -vf subtitles=$1.srt $1.m4v
其中
-i \$1 是要轉檔的檔名
-s 720x406 是轉檔後的解析度,406 = 720 * 720 /
1280,(原始檔的解析度為
1280x720)。這個一定要去計算,不然,在電視上看,畫面比例會不對,字幕可能出不來。
-vpre ipod 是為了 ipod 特別找出來的 preset,設定如後。
--ac 2 是轉成立體聲,不然 ipod touch 沒辦法播放。
--sn 不顯示原始檔中的字幕。因為,我要用另外的字幕檔。
--vf subtitles 為 srt 字幕檔。

preset設定

preset 可以放在 \~/.ffmpeg,檔名為 arg.ffpreset。
例如,我設定了一個專門轉到 ipod touch 的 preset 檔,命名為
ipod.ffpreset。 :
strict=-2

vcodec=libx264
vprofile=main
level=30
maxrate=10000000
bufsize=10000000

preset=fast
#preset=slower

crf=20
#bf=0
#refs=1

#ab=192k

字幕

參考 How to burn subtitles into the
video

原檔中已有圖片格式的字幕時,可直接燒錄:

-filter_complex '[0:v][0:s:1]overlay[v]' -map [v] -map 0:a
此處 -map 一定要下,不然會有錯誤訊息。 其中 -map 0:a
是指所有的音軌,也可以直接指定音軌 -map 0:1
出現的訊息如下:
Stream mapping:
  Stream #0:0 (h264) -> overlay:main (graph 0)
  Stream #0:4 (pgssub) -> overlay:overlay (graph 0)
  overlay (graph 0) -> Stream #0:0 (libx264)

加入外部字幕檔

1. 自行編輯字幕檔

這個很少用到,在 linux 中,就找到 aegisub
是可用的,那就拿來用了,沒有什麼特別的考慮。

2. 提取 mkv 內 srt 或 ass 字幕

提取 mkv 內的文字字幕,用 :
ffmpeg -i $1.mkv -vn -an -scodec copy $1.ssa
或:
ffmpeg -i \$1.mkv -vn -an -scodec copy \$1.srt
有時會出現下列的錯誤訊息,內嵌的應該就是圖片格式字幕。 :
Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted
爲了能改變字型大小,使用 ass 格式。

3. srt

先轉成 ssa 檔,
ffmpeg -i s.srt s.ssa
s.ssa 中加上
; 同步字幕
Synch Point:0
; PlayResX/Y 影片解析度
PlayResX:720
PlayResY:480
; 調整字幕速度
Timer:100.0000
作出 ssa 檔後,可以用文字編輯器開啓,修改一下 fontname 和
fontsize,讓字型美一點。 各參數用法見 ASS
字幕格式

如果不想控制字幕格式,就不須轉成 ass 格式,就用下列指令燒錄到影片。
-vf subtitles=sub.srt

4. 字幕轉成繁體

可以再用 opencc 把字幕轉成繁體:
opencc -i $1.ssa -o o.ssa

5. ass

用 -vf 燒錄到影片中。
-vf ass=s.ssa
或直接加入影片中,不是燒錄上去。
ffmpeg -i video.avi -i sub.ass -map 0:0 -map 0:2 -map 1 -c:a copy -c:v copy -c:s copy video.mkv
其中 video.avi 有一個視頻軌、兩個音頻軌,取其中的視頻軌 (mpa 0:0)
和第二個音頻軌 (map 0:2) 加 sub.ass (map 1) 做成 video.mkv
而不重新編碼。
重點注意: -i sub.ass -map 1 -c:s copy。 此處的 sub.ass 也可以是
sub.srt。

合併多個影片

參考 How to concatenate (join, merge) media
files

mpeg:
ffmpeg -i "concat:input1.mpg|input2.mpg|input3.mpg" -c copy output.mpg
not mpeg:
This is easiest to explain using an example::

    ffmpeg -i input1.mp4 -i input2.webm \
    -filter_complex '[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]' \
    -map '[v]' -map '[a]' <encoding options> output.mkv

On the -filter_complex line, the following:

'[0:0] [0:1] [1:0] [1:1]
tells ffmpeg what streams to send to the concat filter;
in this case, streams 0 and 1 from input 0 (input1.mp4 in this example),
and streams 0 and 1 from input 1 (input2.webm).

concat=n=2:v=1:a=1 [v] [a]'
This is the concat filter itself. n=2 is telling the filter that there are two input files;
v=1 is telling it that there will be one video stream;
a=1 is telling it that there will be one audio stream.
[v] and [a] are names for the output streams, to allow the rest of the ffmpeg line to use the output of the concat filter.

Note that the single quotes ' ' around the whole filter section are required.

-map '[v]' -map '[a]'
This tells ffmpeg to use the results of the concat filter rather than
the streams directly from the input files.

catflv

寫了個小小的 script,用來合併 flv,並轉成 ipod可用的 mp4。 :
#!/bin/bash

icnt=0

for file in $@
do
    filenames="$filenames -i $file "
    scat="$scat[$icnt:0][$icnt:1]"

    #echo $filenames, [$icnt], $scat
    icnt=$(($icnt+1))

done

scmd="ffmpeg $filenames -filter_complex '$scat concat=n=$#:v=1:a=1 [v] [a]' -map '[v]' -map '[a]' -vpre ipod -ab 132k out.mp4"
echo $scmd
eval $scmd

DVD備份

DVD to ISO

爲了保存有價值的影片,儘量用比較高品質的壓縮方法。
​1. 參考:Encoding DVD into HQ flash video using
ffmpeg

將 DVD copy 成 ISO 檔,並掛上: :
$ dd if=/dev/cdrom of=dvd.iso
$ mkdir mnt
$ sudo mount dvd.iso mnt -o loop
$ ls -al mnt/
total 10
dr-xr-xr-x 4 4294967295 4294967295  136 2009-09-30 20:45 .
drwxr-xr-x 5 dpavlin    dpavlin    4096 2009-10-15 22:01 ..
dr-xr-xr-x 2 4294967295 4294967295   40 2009-09-30 17:25 AUDIO_TS
dr-xr-xr-x 2 4294967295 4294967295  560 2009-09-30 18:45 VIDEO_TS
​2. 或使用 dvdbackup,就不必再 mount dvd.iso,而且可以用 libdvdcss
解除保護。
yaourt -S dvdbackup libdvdcss
dvdbackup -i /dev/cdrom -M -o ~/dvd_backup

DVD to MKV

先將 ISO 轉成 MKV :
cat VTS_01_[1234].VOB | ffmpeg -i - -probesize 214748000 -analyzeduration 214748000 \
-map 0:0 -map 0:1 -map 0:2 \
-crf 18 -preset veryslow -tune help\
-filter:v yadif \
-c:a copy -c:s copy -y a.mkv
-probesize 214748000 -analyzeduration 214748000
有時會因爲音軌或字幕軌太晚出現,ffmpeg
會偵測不到,這時就加長偵測的時間和大小。
-map 0:0 -map 0:1 -map 0:2 是要封裝到 mkv 的軌道。
-crf 18 -preset veryslow
用這個參數大概就好了,眼睛看不出來與原始有何差異。 有必要時可以再加上
-tune。
-filter:v yadif 就是 deinterlace。
-c:a copy -c:s copy 音軌和字幕軌都不重新編碼。
如果沒有字幕,可以先取得字幕檔,再保存到 mkv 中,如下: :
$ cat VTS_01_[1234].VOB | ffmpeg -i - -i a.ssa \
-map 0:0 -map 0:2 -map 1 \
-crf 18 -preset veryslow -tune zerolatency \
-filter:v yadif \
-c:a copy -c:s copy \
-y a.mkv
重點是 -i a.ssa -map 1 -c:s copy

MKV 轉成 mp4

如果要在 ipod 或智慧型手機上看,那就不需要太考慮品質,能用就好。
就用上面轉好的 mkv 檔,再轉一次。 如此,既可以用 mkv
保存高品質的影片,再轉成 mp4 的速度也比較快。
這是要注意字幕是圖片格式或是 srt/ass 文字式。

字幕是圖片格式

用 -filter_complex 直接燒錄 :
$ ffmpeg -i a.mkv \
-filter_complex '[0:v][0:s:1]overlay[v]' -map [v] -map 0:a \
-vpre ipod -ac 2 -ab 192k \
-y a.mp4

字幕是 srt 或 ass


  1. 先處理字幕檔 (前述)

  2. 用 -vf subtiles=a.srt 或 -vf ass=a.ass 把字幕燒進 mp4 中。 :
    $ ffmpeg -i a.mkv \
    -vpre ipod -ac 2 -ab 192k \
    -vf subtitles=a.srt \
    -y a.mp4
    

metadata

參考 ffmpeg
-metadata[:metadata_specifier] key=value (output,per-metadata) Set a
metadata key/value pair.
An optional metadata_specifier may be given to set metadata on streams
or chapters. See -map_metadata documentation for details.
This option overrides metadata set with -map_metadata. It is also
possible to delete metadata by using an empty value.
For example, for setting the title in the output file :
ffmpeg -i in.avi -metadata title="my title" out.flv
To set the language of the first audio stream :
ffmpeg -i INPUT -metadata:s:a:1 language=eng OUTPUT
例子: :
-metadata:s:1 title="日語" -metadata:s:2 title="國語" -metadata:s:3 title="中文"

參考資料


  1. FFmpeg wiki:
    x264EncodingGuide

  2. 直接看 help :
    $ ffmpeg --help
    $ x264 --fullhelp
    

2013年5月3日 星期五

太極拳進度20130503

玉女穿梭,第二、四式,第三動:右腳出去的時候,不是用搬的,而是右腳整個虛掉,由左腳湧泉帶動,旋到定位。轉左掤時,手不可拉回來,要飄下來到定位,拉回來,推手的空間都不見了。

今天的進度是「按」。這個真不好練,因爲,人的習慣就是會想要用力,上半身就會先動。

我的認知是:吐氣,落胯,胯向前平移,不可以向上撐起,整個上半身向下鬆。不要想着要把人打出去,只要平移就好。說的是很簡單,練起來就不是那麼一回事了。都是因爲習慣,下意識會想用力。所以太極拳難練,難練在要改這些習慣。

2013年4月26日 星期五

太極拳進度20130426

這禮拜就專心練習「左掤」第二動。
這時最後,我被叫出去改正的式子。原以爲已經打得不錯了,結果,才一動,就被指正,胯跑出去。

心得是,左胯要像門軸,不能向外跑。是裏面帶動外面,下面指揮上面,而不是上身先動。上身先動,胯就一定會跑出去。
後來終於感覺到,左邊的臀部是如何「鬆」下到湧泉。
才這麼一下,左腳好酸啊。

抄錄《道幾》的話:虛腳之換形移位,重心移動時,必須以自己重心交替於實腳湧泉之慣性動作餘勢,帶動虛腳之換形移位。虛腳絕對不可自動。

拳架後是單練「推手」、「大(扌履)」。

本週繼續「推戰車」,重點有以下幾點:

  1. 右胯不能先頂出去,這一點老是搞不定。莊教練乾脆叫我用單腳晃動,真的有一點找到感覺。
  2. 上身不要向前傾,這一點其實是上一點的問題。
  3. 不要哈腰。

我看莊教練接到的時候,整個上身就像是一個「樁」,隨著胯向下沉,就像他說的,直線拉好。

2013年4月12日 星期五

太極拳進度20130412

二炁陰陽盪逍遙,前手出氣,後手吸氣,很神奇吧,我是試不出來啦。先記住後慢慢練吧。
玉女穿梭,彎弓射虎的手要由夾脊帶動。
彎弓射虎定勢,45度半面向左。左腳上半步,重心落到左腳時,拳變掌。再一個白蛇吐信,左旋,右手掌變拳。
搬攔捶的時候,左手不要拿回來,是身體前進,左手在原地等著,蓋到右手。
「推戰車」,胯不要撐起來,平移就好。鬆下去,接到湧泉就平移,不要想太多,也不要想打出去。我觀察教練的胯,真的就只是平平的移動,很漂亮。
今天練的時候,發現自己的前面還是鬆不下,再練練「六合真氣任我盜」吧。

2013年4月10日 星期三

Tile windows 平鋪式視窗 - Pytyle 3

Tile windows 平鋪式視窗

有的時候,開了很多的視窗,想要看到所有視窗的內容,這個時候,「平鋪式視窗」就很有用了。

因為我用的是 archlinux + lxde,所以就找與 openbox 配合度好的 Pytyle 3 來試試看。

安裝

很簡單,下個指令就裝好了:

yaourt -S pytyle3-git

裝好之後,記得把配置檔 copy 到 ~/.config/pytyle3:

mkdir ~/.config/pytyle3

cp /etc/xdg/pytyle3/*py ~/.config/pytyle3

也就只有 keybind.py 和 config.py 這 2 個檔,可以開起來看看。

執行

在終端機中輸入:

pytyle3

預設的啟動鍵是 A-a,我試著想把它改成 W-a,但沒有成功。查看 ~/.config/pytyle3/keybind.py,可以知道有那些快速鍵,表列如下:

'A-a':       啟動平鋪(tile)
'A-u':       不再平鋪(untile)
'A-h':       減小主視窗 (decrease_master)
'A-l':       加大主視窗 (increase_master)
'A-j':       tile.cmd(prev_client)
'A-k':       tile.cmd(next_client)
'A-Shift-j': tile.cmd(switch_prev_client)
'A-Shift-k': (switch_next_client)
'A-comma':   (remove_master)
'A-period':  增加當前視窗為主視窗(add_master)
'A-Return':  設定當前視窗為主視窗(make_master)
'A-m':       切換到主視窗(focus_master),
'A-z':       切換水平或垂直排列(cycle),

'A-q':       除錯 (debug_state)
'A-Shift-q': 離開,

很好玩的「平鋪式視窗」。不想用的時候,就把 pytyle 關掉,如此就不必裝 dwm, awesome 之類的視窗管理器。

參考文件:

Pytyle on arch wiki

2013年3月29日 星期五

太極拳進度20130328

本週延續上週,還是「推戰車」。在練習之前,先複習了「鳥申」、「二炁陰陽盪逍遙」,特別又糾正「肘底捶」。
重點如下:
「盪逍遙」是軸線不要跑掉,手不要用力,不要用上身轉,肩不可動,用腳底帶動旋轉,注意下手。
「鳥申」的胯鬆下去,身體不要浮起。腳尖不要用力向上勾,而是要去找到炁向下,腳向上的頻率和感覺。
「肘底捶」第三動,手盪下來像熊經的手,不要「死板板」地旋。右手心對心窩,然後,手腳隨著胯送上。
「推戰車」最重要的是上身一定要正,鬆下去,力量接到湧泉後,身體隨著左胯向前平移,胯不可浮起,timing 很重要。不要想著要把對方打出去,這樣子身體就會僵硬,不鬆就是捱打的架子。

2013年3月22日 星期五

太極拳進度20130322

現在拳架越改越細,今天講的是,用腳底帶動,走直線,屁股不要先動。糾正了「倒攆猴」、「單鞭下式」、「退步跨虎、轉身擺蓮」這三式,加強練習「推手單練」。
倒攆猴,當重心向後移的時候,注意不能斜著走,這樣子屁股會凸出,轉的時候就無法將重心維持住,也就不能由腳底發動啦。
單鞭下式注意,膝蓋對腳尖,移位。當向下時,屁股不要凸出。手向後,身體往下鬆,否則,身體就會往前傾。這一式真的不好練。
總而言之,重點在於如鬆胯,由腳底帶動。
「推戰車」,練的是「勁」要能從腳底發出,想要發得出去,timing 很重要。不能等到對方的力量都來了之後,才想要移位,這是已經來不及了。而是當對方的力量來的時候,往下鬆,接到了就移位。我現在是鬆下後,看著後面遠遠的地方,平移向前,勁自然由腳底發出。

ffmpeg 使用心得

ffmpeg 使用心得

為了要將影片轉成 ipod touch 3代,可用的格式,特別學習 ffmpeg,試了好幾天,終於找出來滿意的方法,特此記錄下來,免得忘了。

轉檔時的指令

ffmpeg -i $1 -s 720x406 -vpre ipod -ac 2 -sn -y -vf subtitles=$1.srt $1.m4v

其中

-i $1 是要轉檔的檔名

-s 720x406 是轉檔後的解析度,406 = 720 * 720 / 1280,(原始檔的解析度為 1280x720)。這個一定要去計算,不然,在電視上看,畫面比例會不對,字幕可能出不來。

-vpre ipod 是為了 ipod 特別找出來的 preset,設定如後。

--ac 2 是轉成立體聲,不然 ipod touch 沒辦法播放。

--sn 不顯示原始檔中的字幕。因為,我要用另外的字幕檔。

--vf subtitles 為字幕檔。

preset設定

preset 可以放在 ~/.ffmpeg,檔名為 arg.ffpreset,例如,我設定了一個專門轉到 ipod touch 的 preset 檔,命名為 ipod.ffpreset。

strict=-2

vcodec=libx264
vprofile=baseline
level=30
maxrate=10000000
bufsize=10000000

#preset=fast
preset=slower

crf=19
bf=0
refs=1

ab=192k

調整字幕時間

這個很少用到,在 linux 中,就找到 aegisub 是可用的,那就拿來用了,沒有什麼特別的考慮。

提取 mkv 內嵌字幕

為了要把 mkv 中的字幕,轉成繁體。使用以下三道指令即可:

ffmpeg -i $1.mkv -vn -an -scodec copy $1.ssa
opencc -i $1.ssa -o o.ssa
ffmpeg -i $1 -s 720x406 -vpre ipod -ac 2 -sn -y -vf ass=$1.ssa $1.m4v

參考資料

ffmpeg help

Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Getting help:
    -h      -- print basic options
    -h long -- print more options
    -h full -- print all options (including all format and codec specific options, very long)
    See man ffmpeg for detailed description of the options.

Print help / information / capabilities:
-L                  show license
-h topic            show help
-? topic            show help
-help topic         show help
--help topic        show help
-version            show version
-formats            show available formats
-codecs             show available codecs
-decoders           show available decoders
-encoders           show available encoders
-bsfs               show available bit stream filters
-protocols          show available protocols
-filters            show available filters
-pix_fmts           show available pixel formats
-layouts            show standard channel layouts
-sample_fmts        show available audio sample formats

Global options (affect whole program instead of just one file:
-loglevel loglevel  set libav* logging level
-v loglevel         set libav* logging level
-report             generate a report
-max_alloc bytes    set maximum size of a single allocated block
-y                  overwrite output files
-n                  do not overwrite output files
-stats              print progress report during encoding
-bits_per_raw_sample number  set the number of bits per raw sample
-croptop size       Removed, use the crop filter instead
-cropbottom size    Removed, use the crop filter instead
-cropleft size      Removed, use the crop filter instead
-cropright size     Removed, use the crop filter instead
-padtop size        Removed, use the pad filter instead
-padbottom size     Removed, use the pad filter instead
-padleft size       Removed, use the pad filter instead
-padright size      Removed, use the pad filter instead
-padcolor color     Removed, use the pad filter instead
-vol volume         change audio volume (256=normal)

Per-file main options:
-f fmt              force format
-c codec            codec name
-codec codec        codec name
-pre preset         preset name
-map_metadata outfile[,metadata]:infile[,metadata]  set metadata information of outfile from infile
-t duration         record or transcode "duration" seconds of audio/video
-fs limit_size      set the limit file size in bytes
-ss time_off        set the start time offset
-timestamp time     set the recording timestamp ('now' to set the current time)
-metadata string=string  add metadata
-target type        specify target file type ("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd", "ntsc-svcd", ...)
-frames number      set the number of frames to record
-filter filter_list  set stream filterchain
-reinit_filter      reinit filtergraph on input parameter changes

Video options:
-vframes number     set the number of video frames to record
-r rate             set frame rate (Hz value, fraction or abbreviation)
-s size             set frame size (WxH or abbreviation)
-aspect aspect      set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
-bits_per_raw_sample number  set the number of bits per raw sample
-croptop size       Removed, use the crop filter instead
-cropbottom size    Removed, use the crop filter instead
-cropleft size      Removed, use the crop filter instead
-cropright size     Removed, use the crop filter instead
-padtop size        Removed, use the pad filter instead
-padbottom size     Removed, use the pad filter instead
-padleft size       Removed, use the pad filter instead
-padright size      Removed, use the pad filter instead
-padcolor color     Removed, use the pad filter instead
-vn                 disable video
-vcodec codec       force video codec ('copy' to copy stream)
-timecode hh:mm:ss[:;.]ff  set initial TimeCode value.
-pass n             select the pass number (1 to 3)
-vf filter list     video filters
-b bitrate          video bitrate (please use -b:v)
-dn                 disable data

Audio options:
-aframes number     set the number of audio frames to record
-aq quality         set audio quality (codec-specific)
-ar rate            set audio sampling rate (in Hz)
-ac channels        set number of audio channels
-an                 disable audio
-acodec codec       force audio codec ('copy' to copy stream)
-vol volume         change audio volume (256=normal)
-af filter list     audio filters

Subtitle options:
-s size             set frame size (WxH or abbreviation)
-sn                 disable subtitle
-scodec codec       force subtitle codec ('copy' to copy stream)
-stag fourcc/tag    force subtitle tag/fourcc
-fix_sub_duration   fix subtitles duration
-spre preset        set the subtitle options to the indicated preset

參考指令

假設video.avi有一個視頻軌、兩個音頻軌,取其中的視頻軌和第二個音頻軌加sub.ass做成video.mkv而不重新編碼:

ffmpeg -i video.avi -i sub.ass -map 0:0 -map 0:2 -map 1 -c:a copy -c:v copy -c:s copy video.mkv

如果要重新編碼(字幕合成到視頻圖像):

ffmpeg -i video.avi -map 0:0 -map 0:2 -c:a copy -c:v <視頻編碼庫,比如libx264> -vf ass=sub.ass video.mkv

2013年3月8日 星期五

太極拳進度20130308

掤:先練「潑水」。手是由後腳輕輕的送上,肩不可動。
左右分腳:重點在胯,留在原位,不要踢腳,身體纔不會浮起。
摟膝拗步:身體不要先轉,發勁時,遇到阻力,往實腳的湧泉鬆下,手不要折到,不要「貪」。
發勁這玩意還真不好練,碰到阻力就想去「抗」,鬆不下去。看來還要花一點時間。
回家的時候,一路上都看到中華對日本的電視轉播。
到了九局上,又被日本跑回一分,變成了 3 比 3。九局下,中華隊沒有得分,進入延長賽。十局上,又被日本得了 1 分,現在是 3:4,中華隊進攻。
聽到歡呼聲,應該是第七棒張建銘擊出右外野安打,一人出局,一、二壘有人。
很多年沒有看到臺灣為棒球加油的盛況,希望臺灣的棒球能夠復活。
聽到哀嚎聲了,第八棒陳鏞基擊出內野滾地球,造成雙殺,三人出局。
可惜了。

2013年2月8日 星期五

太極拳進度20130208

龍年將過,明天就是大年夜了,今天來學拳的人果然比較少,我想大家都回去過年了,祝大家新年快樂。

今天,真的是大豐收!

早一點到,看到莊教練和同學在談天,就靠過去聽聽,得到了重要的資訊:

一是練拳四件事:虛實交清楚,直線要抓好,足心有東西,下面先動。直線就是百會到足心。

二是太極拳要 「平整均勻」,很常聽到的一句話,莊教練做了解釋,這裡簡單記錄下來:

平:胯要平,不要撐起來。後來,聊天時又提到,吳老師曾說過:胯要像武大郎挑擔。

整:一動無有不動,腳停手停。

均:前後左右上下對稱。

勻:速度不可忽快忽慢。

練拳時,莊教練特別說明「進步搬攔捶」,右腳套步時,重心落下變實腳,同時,左手左腳攔到位。

雙人對練時,練的是發勁。重點如下:

意念不要在手上,放在夾脊。當有力量來時,夾脊有感時,放掉。

兩個肩、兩個胯要保持一個平面。手是沒有用的,要圓肘,又不可意念太重,把肘放下即可。

手搭上去時,要輕,所謂「冬至衣服夏至毛」,只是用來破壞對手的軸線,當他的力量來了,借力,平移,發出。真的也不會太難。要用湧泉打對方身上的一點,如頭頂、肩、胯、湧泉。

摟膝拗步,實腳的胯,不要向後抽,把它固定好,否則會發不出去。

上次的重點還沒記錄下來,這次補記如下:

熊經,練的是聽勁,要聽空氣在手心的感覺,感覺空氣的流動。

單鞭,前兩動的手是旋動,左手向下旋,右手吊手也是旋出去,不是推出去。

擠,變按手時,肘不動,微微圓肘。手分開是因為重心由前腳移到後腳時,背後的兩條筋把它帶開。按時,手不動,重心向前,不要頓一下。

玉女穿梭,左腳在右腳尖的外側,不要跑到裡面,不然待會兒會轉不動。

陰陽反覆摺疊式,練的是聽勁,軸心要保持。軸心也就是上述「直線要抓好」的直線。

2013年1月21日 星期一

conky 與 conkywx 配置

conky 主要的功能是在桌面上顯示系統資訊,當然也可以顯示其他有趣的資訊。先安裝吧:

$ yaourt -S conky conkywx

說明文件在這裡

安裝後,就要設定配置檔。google 一下,滿坑滿谷的 screenshot 和 config,只要有想象力,時間,在加上一些耐性,一定可以作出符合自己需要的桌面。

預設的配置檔是放在 $HOME/.conkyrc。在 /etc/conky/conky.conf 這裡有個範例,不過,應該不會有人不改就套用吧。

我是把配置檔放在 ~/.conkyrc,方便未來備份。配置檔很長,放在本文的最後。

conkywx是用來顯示天氣狀況。至少需要兩個檔案:

  • ~/.config/conkywx/conkywx.conf
  • ~/.config/conkywx/template.sh

在 .conkyrc 中用下面的方法連接過去。

template0 "/usr/bin/conkywx"
template1 "/home/mario/.config/conkywx/conkywx.conf"
template2 "/home/mario/.config/conkywx/wx-wu-font-slim-template.sh"

${execpi 7200 ${template0} -c ${template1} -t ${template2}}

conkywx.conf 中設定以下 2 個參數

  • use_xml=0
  • Location=46696

就可以看到松山機場的天氣狀況。其他的地方如下:

conkywx station id

TAIWAN 27-DEC-01
TAIPEI TAOYUAN RCTP 46686 25 04N 121 13E 33 X T 6 TW

MAZU RCFG 46689 26 10N 119 55E 91 X T 7 TW

SUNGSHAN/TAIPEI RCSS 46696 25 04N 121 32E 6 X T 6 TW

TAOYUAN AB RCGM 46697 25 04N 121 13E 45 X 7 TW

DONGSHI RCNO 46730 23 16N 119 40E 45 X 7 TW

MAKUNG AB RCQC 46734 23 34N 119 37E 31 X 7 TW

CHINMEM/SHATOU RCBS 46736 24 25N 118 22E 9 X T 6 TW

PA KUEI/BAKUAI RCUK 46738 24 55N 121 17E 141 X 7 TW

KAOHSIUNG INTL RCKH 46740 22 34N 120 20E 9 X T 6 TW

TAINAN TW-AFB RCNN 46743 22 56N 120 12E 19 X 7 TW

KANGSHAN TW-AFB RCAY 46745 22 46N 120 16E 10 X 7 TW

CHIAYI TW-AFB RCKU 46746 23 28N 120 22E 25 X 7 TW

DONGGANG RCMJ 46747 22 28N 120 25E 8 X 7 TW

PINGTUNG SOUTH RCDC 46750 22 40N 120 28E 24 X 7 TW

TAICHUNG TW-AFB RCLG 46751 24 10N 120 39E 112 X 7 TW

HENGCHUN RCKW 46752 21 55N 120 49E 13 X T 7 TW

HSINCHU TW-AFB RCPO 46756 24 49N 120 55E 8 X 7 TW

PINGTUNG N AFB RCSQ 46758 22 41N 120 28E 29 X 7 TW

CHIHHANG TW-AFB RCQS 46760 22 48N 121 10E 37 X 7 TW

LAN YU RCLY 46762 22 01N 121 32E 325 X T 6 TW

HUALIEN AB RCYU 46763 24 01N 121 37E 16 X 7 TW

ILAN RCMS 46764 24 45N 121 46E 9 X 7 TW

WUCHIA OBSERVATO RCMQ 46770 24 16N 120 37E 5 X 7 TW

CHIA TUNG RCFS 46772 22 25N 120 32E 20 X 7 TW

DONGSHA/PRATAS RCLM 46810 20 40N 116 43E 6 X 7 TW

以下是我的 template 檔,和 .conkyrc 的寫法很接近,只是多了一些新的變數:

${voffset 10}${font DroidSans:bold:size=14}天氣  ${font}${alignc}[SN]  [LU]  ${hr 2}${font}
${voffset 15}${goto 35}${font ConkyWeather:size=64}[PIF]${font}
${voffset -70}${goto 120}${font DejaVu Sans Mono:style=Bold:size=20}[PT]${font}
${goto 120}[CT]
${goto 120}Feels like: [FL]
${goto 120}${color3}UV: [UV] - [UVT]
${voffset 5}${goto 25}[D2D]${goto 75}[D3D]${goto 125}[D4D]${goto 175}[D5D]
${voffset 1}${goto 25}${font ConkyWeather:size=30}[D2F]${goto 75}[D3F]${goto 120}[D4F]${goto 175}[D5F]${font}
${voffset 3}${goto 25}[D2T]${goto 75}[D3T]${goto 125}[D4T]${goto 175}[D5T]${font}
${voffset 3}${goto 35}[D2P]${goto 85}[D3P]${goto 135}[D4P]${goto 185}[D5P]${font}${color}

上面的 [SN]、[LU]、[PT] 等等,就要看這個說明

以下是我的 .conkyrc 檔:

# .conkyrc by fabsh <fabsh@lamerk.org>
# Based on ideas and code from the CunchBang Linux forums at http://crunchbanglinux.org
# v. 1.0

# Use Xft?
use_xft yes
xftfont DroidSans:size=12
#xftfont DejaVu Sans:size=12
xftalpha 0.8
text_buffer_size 2048

# Update interval in seconds
update_interval 1

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

own_window yes
#own_window_transparent yes
#own_window_type override
#own_window_type desktop
#own_window_type normal #use this if you want a nice shadow to appear around conky

# If own_window is yes, these window manager hints may be used #設置conky為沒有邊框等等。
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

##################################
# 半透明
# yaourt -S compton-git
##################################
#own_window_class Conky
own_window yes
#設置conky的窗口屬性 desktop/NORMAL
own_window_type normal      #use this if you want a nice shadow to appear around conky
#設置conky的默認背景色
own_window_colour 222222
#很重要,只有啟用argb才能透明,但是如果窗口屬性如果設置為override,可能無法生效
own_window_argb_visual yes
#設置透明的alpha值0-255,0為透明,255不透明
own_window_argb_value 10
#如果啟用own_window_transparent,窗口完全透明,alpha值不起作用
own_window_transparent no   #yes
##################################

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Minimum size of text area
#minimum_size 180 0     # 重啟才有效
maximum_width 200

# Draw shades?
draw_shades no

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no

# Stippled borders?
stippled_borders 0

# border margins
border_margin 5

# border width
border_width 0

# Default colors and also border colors
default_color white
#default_shade_color black
#default_outline_color grey
#own_window_colour grey
#color red,green,yellow,blue,magenta,cyan,black,white.
color1 FA9E10

# 相對於螢幕,Text alignment, other possible values are commented
alignment top_right
#alignment top_left
#alignment top_middle
#alignment bottom_left
#alignment bottom_right

# Gap between borders of screen and text
# same thing as passing -x at command line
border_inner_margin 15
gap_x 30
gap_y 30

# Subtract file system buffers from used memory?
no_buffers yes

# set to yes if you want all text to be in uppercase
uppercase no

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2

# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 1

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes

# Add spaces to keep things from moving about? This only affects certain objects.
use_spacer none

short_units yes

#########################
# 天氣: conkywx 要用的設定檔
#########################
template0 "/usr/bin/conkywx"
template1 "/home/mario/.config/conkywx/conkywx.conf"
template2 "/home/mario/.config/conkywx/wx-wu-font-slim-template.sh"

TEXT
###################################
# SYSTEM
###################################
${font DroidSans:bold:size=16}${color1}SYSTEM ${hr 2}${font}${color}
#${alignc 24}${font Arial Black:size=14}${nodename}${font}
#${alignc -8}HP Pavilion dv2500nr
#${voffset 2}${font Arial Black:style=Bold:size=12}#!${font} CrunchBang Linux ${alignr}08.10.01
${font OpenLogos:size=14}u${font} Kernel: ${alignr}${kernel}
${font StyleBats:size=14}q${font} Uptime: ${alignr}${uptime}
#${font StyleBats:size=14}A${font} CPU : ${font} ${alignr}${cpubar cpu0 8,60}

${font DroidSans:bold:size=16}CPU: ${font}${hwmon 0 temp 1}°C $alignr${freq_g 1}GHz   ${cpugraph cpu0 8,60}
${font StyleBats:size=14}A${font} CPU1: ${cpu cpu1}% ${alignr}${cpubar cpu1 8,80}
${font StyleBats:size=14}A${font} CPU2: ${cpu cpu2}% ${alignr}${cpubar cpu2 8,80}
${font StyleBats:size=14}A${font} CPU3: ${cpu cpu3}% ${alignr}${cpubar cpu3 8,80}
${font StyleBats:size=14}A${font} CPU4: ${cpu cpu4}% ${alignr}${cpubar cpu4 8,80}
${font StyleBats:size=14}g${font} RAM: $mem/$memmax ${alignr}$memperc% ${membar 8,40}
${font StyleBats:size=14}j${font} SWAP: $swapperc% ${alignr}${swapbar 8,80}

${font DroidSans:bold:size=14}NAME          ${goto 100}CPU%            ${goto 150}${alignr}MEM%${font}
${top name 1} ${goto 100}${top cpu 1}    ${goto 160}${alignr}${top mem 1}
${top name 2} ${goto 100}${top cpu 2}    ${goto 160}${alignr}${top mem 2}
${top name 3} ${goto 100}${top cpu 3}    ${goto 160}${alignr}${top mem 3}
${top name 4} ${goto 100}${top cpu 4}    ${goto 160}${alignr}${top mem 4}
${top name 5} ${goto 100}${top cpu 5}    ${goto 160}${alignr}${top mem 5}
#${font Webdings:size=14}~${font} Battery: ${battery_percent BAT0}% ${alignr}${battery_bar 8,60 BAT0}

##################################
# DATE
##################################
${font DroidSans:bold:size=16}${color1}DATE ${hr 2}${font}${color}
${voffset 3}${font DroidSans:size=18}${alignc}${time %A, %d %B %Y}${font}
${voffset 10}${font DroidSans:bold:size=24}${alignc}${time %H:%M}${font}
##################################
#WEATHER ${hr 2}
##################################
${execpi 7200 ${template0} -c ${template1} -t ${template2}}

##################################
# HD
##################################
${voffset -4}${font DroidSans:bold:size=16}${color1}HD ${hr 2}${font}${color}
${voffset 4}${font Pie charts for maps:size=14}7${font}Root: ${alignr}${fs_used /}/${fs_size /}   ${fs_bar 8,60 /}

##################################
# NETWORK
##################################
${font DroidSans:bold:size=16}${color1}NETWORK ${font}${alignr}${addrs ppp0}${color}
${voffset 0}${font PizzaDude Bullets:size=14}O${font} Up: ${upspeed eth0}${alignr}${upspeedgraph eth0 8,60 black black}
${voffset 4}${font PizzaDude Bullets:size=14}U${font} Down: ${downspeed eth0}${alignr}${downspeedgraph eth0 8,60 black black}
${voffset 4}${font PizzaDude Bullets:size=14}N${font} Upload: ${alignr}${totalup eth0}
${voffset 4}${font PizzaDude Bullets:size=14}T${font} Download: ${alignr}${totaldown eth0}
##################################
# MPD
##################################
${if_mpd_playing}
${font DroidSans:bold:size=16}${color1}MPD${font} ${alignr}${mpd_vol}  ${mpd_bar 2,100}  ${mpd_length}${color}
${voffset 4}${mpd_album}
${voffset 4}${mpd_artist}
${voffset 4}${mpd_title}
${endif}

顏色有 red,green,yellow,blue,magenta,cyan,black,white。

也可以設定數值,如下

# 夢幻的橘色
color1 FA9E10

2013年1月19日 星期六

k10temp: unreliable CPU thermal sensor

boot 時,發現 k10temp 的錯誤訊息:

$ dmesg | grep k10temp
k10temp 0000:00:18.3: unreliable CPU thermal sensor; monitoring disabled

查到 Archlinux Wiki 提到:

K10Temp Module

Some K10 processors have issues with their temperature sensor. From the kernel documentation (linux-/Documentation/hwmon/k10temp):

All these processors have a sensor, but on those for Socket F or AM2+, the sensor may return inconsistent values (erratum 319). The driver will refuse to load on these revisions unless you specify the force=1 module parameter.

Due to technical reasons, the driver can detect only the mainboard's socket type, not the processor's actual capabilities. Therefore, if you are using an AM3 processor on an AM2+ mainboard, you can safely use the force=1 parameter.

On affected machines the module will report "unreliable CPU thermal sensor; monitoring disabled". If you still want to use the module you can:

  # rmmod k10temp

  # modprobe k10temp force=1

Confirm with Lm_sensors#Testing your lm_sensors that the sensor is in fact valid and reliable. If it is, you can edit /etc/modprobe.d/k10temp.conf and add:

  options k10temp force=1

This will allow the module to load at boot.

修改/新增 /etc/modprobe.d/k10temp.conf,重開機後,執行

$ sensors

會多看到以下的結果:

k10temp-pci-00c3
Adapter: PCI adapter
temp1:        +26.2°C  (high = +70.0°C)
                      (crit = +90.0°C, hyst = +88.0°C)

這樣算是 OK 吧。

2013年1月16日 星期三

終於把 wine picasa 3.9 裝上了

終於把 wine picasa 3.9 裝上了

參考How would I install Picasa 3.9

$ sudo pacman -S wine winetricks
$ cd ~/ && wget http://dl.google.com/picasa/picasa39-setup.exe
$ wine ~/picasa39-setup

Wine 會去安裝 Mono、Gecko,前者是為了.NET,後者是為了 html。
然後就開始安裝 picasa,把該裝的包都裝上。

接下來裝 Internet Explorer 6,這是為了能將照片上傳到 google+:

$ env WINEARCH=win32 WINEPREFIX=~/.tmp winetricks ie6

結果還是無法啟動 picasa 3.9,真讓人洩氣。安裝到最後,總是出現錯誤訊息。

google 了許久,終於找到這篇
就試著把 lib32-lcms 也裝上:

$ pacman -S lib32-lcms

哈哈哈,竟然就成功了,而且也可以把圖片上傳到 google+。

目前的問題是:picasa可以正常開啟,但是,無法顯示目錄名稱。不過,我相信一定可以找到方法解決的。

$ sudo pacman -S lib32-libpng

err:ntdll:RtlpWaitForCriticalSection

2013年1月4日 星期五

太極拳進度21030104

回到太極拳的學習,很快的就 1 年了。
莊教練問我,有沒有進步啊?我心裏頭自然有個答案:沒進步就浪費了這 1 年的時光。進步很多嗎?我實在是不夠認真,沒有把時間都放在太極拳上,專心的去練。
看在郭教練的眼裏,她是說:進步很多。我還是覺得:進步太慢,不夠認真。回頭再看看今年最重要的進步,我覺得是鬆腰胯,後腰真的有鬆的感覺,力量就可以下到湧泉。第二是,湧泉先動,帶動全身動。第三是,膝蓋對腳尖,移位很輕鬆,臀部不會凸。
今天的進度。金樑換柱,忘了要含胸,炁就下不去。
拳架要注意的事:金雞獨立、上步七星,都是腰胯送上去,鳥申多練練吧。進步栽捶,也是身法,不要蹲下去。
(左右)滑步、大(扌履),步隨身換。滑步,後腳送出去後,身體先到,而後併步。身採、挒肘靠、搭手,都是身法,手不自動。看教練的動作,真的很漂亮。