2014-01-22

x264の方が画質が良いらしいので使ってみる

QuickTime7で最初から使えるAppleのH.264コーデックはフリーのx264の方が性能が良いらしいので実際に使ってみました。

Mac版 QuickTime用のx264コーデックのバイナリは下記URLから入手出来ます。
http://developer.berlios.de/projects/x264qtcodec/

また、動画ファイルの詳細を調べる為にMediaInfoというソフトウェアを使用します。
http://mediaarea.net/ja/MediaInfo/Download/Mac_OS
Free GUI版 0.7.66を使用しています。

QT用x264はインストーラを使ってインストール後、書き出し時の圧縮の種類でH.264(x264)を選択することで使用することが出来ます。

オプション設定はAppleのH.264と画面は同じですが、オプション設定のボタンが追加されていました。
x264の詳細設定
画面は同じですが微妙に初期値が異なっています。

x264独自のオプション項目
オプション項目はわからない場合はそのままにしておく。専門的な知識がないと無理っぽい。細かい事を書くだけの知識がないのでこれ以上は・・・


設定だけ見てもどんな変化があるかわからないので、いろいろと設定を変えてエンコードしてみます。
エンコードに関して、下記はそれぞれ表記した設定で固定。
・FPS:29.97(指定)
・キーフレーム:自動
・フレーム並べ替え:ON
・データレート:自動
・サイズ:NTSC 720×480 16:9
・音声:AAC 44.1KHz 2chステレオ 128kbps

実際にエンコードしたときのファイルサイズを確かめたいので今回音声は関係ありませんが音声ありでエンコードしています。
また、元ファイルはインターレース表示ですが、エンコーディングすると強制的にインターレースを解除されます。

エンコード結果のプロファイルとレベルに関してはWikipedia参照。
http://ja.wikipedia.org/wiki/H264

●変換元の映像ファイル

Format                                   : YUV
Codec ID                                 : 2vuy
Duration                                 : 1mn 30s
Bit rate mode                            : Constant
Bit rate                                 : 168 Mbps
Width                                    : 720 pixels
Height                                   : 486 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Constant
Frame rate                               : 29.970 fps
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:2
Scan type                                : Interlaced
Scan order                               : Top Field First
Scan order, stored/displayed inverted    : Yes
Compression mode                         : Lossless
Bits/(Pixel*Frame)                       : 16.000
Stream size                              : 1.76 GiB
Color primaries                          : BT.601 NTSC
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.601

①Apple H.264 品質:中、エンコーディング:複数回実行

Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L3.0
Format settings, CABAC                   : No
Format settings, ReFrames                : 2 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1mn 30s
Bit rate                                 : 686 Kbps
Width                                    : 704 pixels
Original width                           : 720 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 16:9
Original display aspect ratio            : 3:2
Frame rate mode                          : Constant
Frame rate                               : 29.970 fps
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.068
Stream size                              : 7.37 MiB (84%)
Color primaries                          : BT.601 NTSC
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.601

②Apple H.264 品質:高、エンコーディング:複数回実行

Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L3.0
Format settings, CABAC                   : No
Format settings, ReFrames                : 2 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1mn 30s
Bit rate                                 : 1 788 Kbps
Width                                    : 704 pixels
Original width                           : 720 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 16:9
Original display aspect ratio            : 3:2
Frame rate mode                          : Constant
Frame rate                               : 29.970 fps
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.177
Stream size                              : 19.2 MiB (93%)
Color primaries                          : BT.601 NTSC
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.601

③Apple H.264 品質:最高、エンコーディング:複数回実行

Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L3.1
Format settings, CABAC                   : No
Format settings, ReFrames                : 2 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1mn 30s
Bit rate                                 : 6 458 Kbps
Width                                    : 704 pixels
Original width                           : 720 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 16:9
Original display aspect ratio            : 3:2
Frame rate mode                          : Constant
Frame rate                               : 29.970 fps
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.638
Stream size                              : 69.4 MiB (98%)
Color primaries                          : BT.601 NTSC
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.601

④x264 品質:中、エンコーディング:複数回実行

Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L5.1
Format settings, CABAC                   : No
Format settings, ReFrames                : 2 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1mn 30s
Bit rate                                 : 742 Kbps
Width                                    : 704 pixels
Original width                           : 720 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 16:9
Original display aspect ratio            : 3:2
Frame rate mode                          : Constant
Frame rate                               : 29.970 fps
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.073
Stream size                              : 7.97 MiB (85%)
Writing library                          : x264 core 54
Encoding settings                        : cabac=0 / ref=1 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=5 / brdo=0 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / chroma_qp_offset=0 / slices=4 / nr=0 / decimate=1 / mbaff=0 / bframes=2 / b_pyramid=0 / b_adapt=1 / b_bias=0 / direct=1 / wpredb=0 / bime=0 / keyint=150 / keyint_min=25 / scenecut=40 / rc=cqp / qp=26 / ip_ratio=1.40 / pb_ratio=1.30

⑤x264 品質:高、エンコーディング:複数回実行

Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L5.1
Format settings, CABAC                   : No
Format settings, ReFrames                : 2 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1mn 30s
Bit rate                                 : 5 343 Kbps
Width                                    : 704 pixels
Original width                           : 720 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 16:9
Original display aspect ratio            : 3:2
Frame rate mode                          : Constant
Frame rate                               : 29.970 fps
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.528
Stream size                              : 57.4 MiB (98%)
Writing library                          : x264 core 54
Encoding settings                        : cabac=0 / ref=1 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=5 / brdo=0 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / chroma_qp_offset=0 / slices=4 / nr=0 / decimate=1 / mbaff=0 / bframes=2 / b_pyramid=0 / b_adapt=1 / b_bias=0 / direct=1 / wpredb=0 / bime=0 / keyint=150 / keyint_min=25 / scenecut=40 / rc=cqp / qp=13 / ip_ratio=1.40 / pb_ratio=1.30

⑥x264 品質:最高、エンコーディング:複数回実行

Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High 4:4:4@L5.1
Format settings, CABAC                   : No
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1mn 30s
Bit rate                                 : 35.9 Mbps
Width                                    : 704 pixels
Original width                           : 720 pixels
Height                                   : 480 pixels
Original height                          : 4294966 916 pixels
Display aspect ratio                     : 16:9
Original display aspect ratio            : 0.000
Frame rate mode                          : Constant
Frame rate                               : 29.970 fps
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Interlaced
Bits/(Pixel*Frame)                       : 3.542
Stream size                              : 385 MiB (100%)
Writing library                          : x264 core 54
Encoding settings                        : cabac=0 / ref=1 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=5 / brdo=0 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / chroma_qp_offset=0 / slices=4 / nr=0 / decimate=1 / mbaff=0 / bframes=2 / b_pyramid=0 / b_adapt=1 / b_bias=0 / direct=1 / wpredb=0 / bime=0 / keyint=150 / keyint_min=25 / scenecut=40 / rc=cqp / qp=0

設定値はさっぱりわかりませんが、
QuickTime標準のH.264エンコーダはプロファイルがMainのみで、レベルが3.0〜3.1の間で処理していますが、x264エンコーダはプロファイルはMainとHigh(品質:最高)でレベルが5.1になっているので、基本設定を同じにしてもx264エンコーダの方が綺麗な画質で書き出してくれるようです。

③と⑤の動画を流して見たり、同じフレームの静止画像を拡大して比べても違いがわかりません。③のビットレートは6458Kbpsで、⑤が5345Kbpsなので、エンコードした映像をこの解像度で視聴する上では元映像の品質からして③と⑥はデータ量が過剰ではないかと思います。
かといって②・④と⑤を比べると、②・④の映像は線に隣接する色との境目で色がおかしい所もあるため、動きが大きいシーンだと線のシャギーが目立つような気がします。
という事は⑤の設定でエンコードすれば十分な品質で保存できるという事になります。
映像にもよりますが、30分のアニメ(CMカットして23分50秒くらい)で1GB前後のファイルになる計算です。
 初めてエンコードしたアニメなんかは画面サイズだけ合わせてとりあえず最高設定で書き出したものは3GB超えていたので自分にしては進歩したかと。

映像中の文字に関しては元映像がインターレースなので読みやすさの向上は考えていません。ほとんど変化ないし、アニメなんで気にしない。

x264エンコーダの方が画質が良いというのは本当だったのでこれからはこっちを使って書き出す事にします。

っていうか、やればやるほどいろいろ気になって全然ダビングの書き出し作業が進まないので、この辺で妥協して時間が空いたら更に追求していかないといつになっても終わりません。

0 件のコメント:

コメントを投稿