出力ファイル名とパスの指定。出力形式(拡張子)もここで指定する。
.264で raw MPEG-4
ストリーム。.MP4で映像のみのMP4(音声は後からMP4boxでmuxする)。.MKVならMatroska。MKVに慣れているならMKVでも良
いが、このガイドは.264で吐いて他の要素(音声など)は後からMuxする事を前提にしている。プレビューには.MP4が良い。
SAR は Sample Aspect Ratio の略。これを指定するとアナモルフィックビデオ~すなわち、サンプル解像度に関わらず正しいアスペクトレシオ(*映像の縦横比*)に引き延ばして再生できるようになる。SARはアスペクトレシオを指定するものではなく、引き延ばす係数の指定である事に注意。
例えばSAR 32:27 は720x480映像をアスペクトレシオ 16:9 で再生するためのものだ。32/27=1.185185... となるので、1.185185...x720 = 853.3くらい。従って再生は853x480となる。
アナモルフィック映像を扱った経験者は多いと思う。NTSC-DVDでは一般的に、ワイドスクリーン映像はNTSC 4:3の 720x480 に押しつぶしてある。
アナモルフィック素材を扱う方法にはいろいろなものがある。
1)640x360 にリサイズ(そして 16 の倍数である 352 にクロップ)。
2)852x480 にリサイズ(同じく 848 にクロップ)。
前者では大量のディテイルを失う事になる。後者では拡大による汚れが出る。アナモルフィックでは 720x480 または 704x480 でエンコードして、再生時に概ね 853x480 に引き延ばすタグをつけておく事ができる(playerによって異なる)。再生サイズは 853x480 でも、実際のデータ量は 720x480 または 704x480 だ。拡大するわけでは無いのでbitの節約になり、縮小では無いのでディテイルは維持できる。再生負荷もエンコード前に拡大するよりは低い。と言うように SARは理論上は良いものだが、AMV(*アニメ・ミュージック・ビデオ、原文はこれを想定しているが、概ね一般論として通じる*)を間違ったアスペクトレシオで編集すると、変な形にリサイズされてしまう事を忘れないように。ただし、編集ソフトにそのへんの面倒を見てくれるモードがあれば別です。
一般的な SAR:(*下表の内容はweb上の他の情報と矛盾します。『疑問点』参照*)
Source Resolution | Display Aspect Ratio |
Sample Aspect Ratio | 備考 |
---|---|---|---|
720x480 (NTSC) | 1.33(4:3) | 8:9 | スタンダード |
1.77(16:9) | 32:27 | ヨーロッパビスタ(1.66)とアメリカンビスタ(1.85)の中間比 | |
1.85 | 100:81 | アメリカンビスタ | |
2.35 | 69:44 | シネマスコープ | |
704x480 (NTSC Crop) | 1.33 | 10:11 | |
1.77 | 40:33 | ||
1.85 | 125:99 | ||
2.35 | 85:53 | ||
720x576 (PAL) | 1.33(4:3) | 16:15 | |
1.77(16:9) | 64:45 | ||
1.85 | 40:27 | ||
2.35 | 32:17 | ||
704x576 (PAL Crop) | 1.33(4:3) | 12:11 | |
1.77(16:9) | 16:11 | ||
1.85 | 50:33 | ||
2.35 | 102:53 |
例えば解像度が 704x480(720x480 NTSC の黒帯をクロップしたもの)で、アスペクトが 16:9 の映像なら、 --sar 40:33。
SARは MP4box でも指定できます(推奨)。MP4box ガイドも参照して下さい。
*原文にMP4box ガイド未発見。
*ageha MP4Boxの主要コマンド に
-par trackID=PAR というオプションがある。
--sar
Usage: --sar <numerator:denominator> (default=1:1) [1 - 255]
SAR
means Sample Aspect Ratio. Setting this allows anamorphic video to be
played back at the correct aspect ratio since the video is stretched on
playback. Note that SAR does not work by specifying the aspect ratio,
it works specifiying the factor to be stretched by. For example 32:27
is the SAR to make 720x480 video play back at 16:9 aspect ratio. This
is because 32/27=1.185185.... Therefore 1.185185...x720 = 853.3r. You
now have 853x480.
You will probably have encountered anamorphic
video before, it's widescreen material that is usually squashed into a
4:3 frame size for example 720x480 which is NTSC 4:3 for DVDs.
There are a number of ways you might have dealt with anamorphic material in the past, you might have resized to 640x360 (and cropped to 352 for mod16), or some people might have resized to 852x480 (848 for mod 16). With the first method you lose a lot of detail, the second wastes data because you are upsizing the image. Anamorphic allows you to encode it as 720x480 or 704x480 and set the tag for it to be stretched on playback. The result is a video that will be resized to approx 853x480 on playback (may depend on the player), but will only require the equivalent amount of data as a 720x480 or 704x480 encode. This way you save bits since you aren't encoding an upscaled image, and save quality because you aren't downscaling. The playback requirements are also lower than the upscaled encode. SAR is goon in theory, but editing AMVs at the wrong aspect ratio whilst bearing in mind that it will be resized may be tricky, unless your editing software has some sort of mode to help with this.
Here are some common SARs:
(表略)
If for instance I had a 704x480 video (720x480 NTSC after
cropping the
black bars) and is a 16:9 video, I would set --sar 40:33.
You may also set the SAR in MP4box (recommended). You can check out the
MP4box guide for muxing.
アスペクト比 part3 http://pc11.2ch.net/test/read.cgi/avi/1174473555/-100
32 :孫極右:2007/03/23(金) 22:00:24
>>26
720x480(無効領域なし)の16:9 - 32:27
720x480(無効領域あり)の16:9 - 40:33
704x480(無効領域Crop)の16:9 - 40:33
720x480(無効領域なし)の4:3 - 8:9
720x480(無効領域あり)の4:3 - 10:11
704x480(無効領域Crop)の4:3 - 10:11
例 DAR(Display Aspect Ratio)を4:3、画素数が720*480の場合、
par_x = DAR_x * hight = 4 * 480 = 1920
par_y = DAR_y * width = 3 * 720 = 2160
1920:2160→8:9
(4 * 480):(3 * 352)=20:11
これは以下2点とも整合します。
引用文中の式では横幅720と704で数字が変わりますが、無効領域(乱暴に言うとブラウン管用のマージン)の扱いに注意が必要と思われます。無効領域の有無の見分け方は不詳。
原文の表は下記に従ったものと思われます。
*x264のsvnソースコード内/doc/vui.txtより
SAR_x DAR_x * height
----- = --------------
SAR_y DAR_y * width
for example:
width x height = 704x576, DAR = 4:3 ==> SAR = 2304:2112 or 12:11
これに従う限り、横幅 720と704ではSARを変える必要があるのですが、これに続いて "素材がデジタル化されたアナログ信号の場合はこの式を使うな"。とも書いてあります。
Please note that if your material is a digitized analog signal, you shouldこのリンク先を読むとどうやらかなり広汎な、むしろ現在身の回りにあるほとんどの素材がこれに該当するようです。
not use this equation to calculate the SAR. Refer to the manual of your
digitizing equipment or this link instead.
A Quick Guide to Digital Video Resolution and Aspect Ratio Conversions
http://www.iki.fi/znark/video/conversion/
見れば解る通り、映像のフレームレートを指定する。例えば少数指定なら --fps 23.976、分数指定なら24000/1001。一見にているが、厳密には同じでは無い事に注意。これは後でファイルを結合する際に重要だ。分数の方が正確で、23.976 と 29.97 fps の指定はそれぞれ 24000/1001 と 30000/1001 が正しいとされている。
Quite self explanatory, this sets the framerate of the video. You can specify this as a floating point number, for example --fps 23.976 or a rational number such as 24000/1001. Note that these will produce similar, but not the same framerates. This will be important if you intend to join segments at any time. The rational number is more accurate and is considered the true way of specifying 23.976 and 29.97 fps, 24000/1001 and 30000/1001 respectively.
エンコードの開始フレームを指定。ファイル冒頭に要らない部分があった時に便利。AVIsynth のトリム機能に似ており、--framesと一緒に使うと良いだろう。
Seek tells x264 at what frame to begin encoding. This is useful if you want to skip the first part of a file for example if it has a bumper that you decide you don't want to encode. This is somewhat similar to the Trim function in AVIsynth and can be used with --frames.
エンコードするフレーム数を指定。--seek と一緒に使うとシーク開始点から--framesで指定したフレーム数をエンコードする。
--frames
Usage: --frames <integer>
This specifies the number of frames to encode, rather than encoding a whole video. You can use this with --seek to encode a certain part of a file for a certain amount of frames.
Annex A(*追加議定書A*)で定義されたProfile@Level を指定。
ハードウェアプレイヤが再生可能かどうかチェックするのはここで指定するLevel
だ。x264のデフォルトは最も高位のプロファイルで、Profile@Levelを知らない場合、変更は非推奨。レベルとプロファイルの一覧は下記リンク参照。
http://aflux.deltaanime.net/Zero1/MP4/x264_files/h264levels.png
*PSPやiPod向けでは必要と思われる。
--level
Usage: --level <string>
Level allows you to set the Profile@Level as defined by Annex A. It is this level which hardware players will check against to see if the file is playable. x264 automatically sets the highest profile and is not recommended you change it unless you know that your video falls within a certain Profile@Level, or you otherwise know what you are doing. You can find a graph of levels and the maximum supported values by clicking the thumbnail, be warned that it is very technical though.
http://aflux.deltaanime.net/Zero1/MP4/x264_files/h264levels.png
各フレームの統計を表示。一般には鈍足化するので不要。切っておく事を推奨。
*まるも製作所さんの日記に適用時の例アリ
07/07/19(木) x264 [17] --no-b-adapt:http://www.marumo.ne.jp/db2007_7.htm#19
基本的な読み方は、07/06/29(金) x264 [7] ログの読み方 - サマリー編にある。
Verbose prints the stats for each frame and is generally slower and not required. It is recommended to leave this turned off.
エンコード中に進行状況を表示。ETA(*予想終了時間、MASA.Hさんのコメント参照*)、エンコード済みフレーム数、残りフレーム数、エンコードの速度(fps)を表示するので非常に重要だ。
Shows a progress indicator while encoding. This is pretty much essential and shows you the ETA, frames encoded, frames left and frames per second being encoded.
PSNR算出を停止し、エンコード後にPSNRを表示しない。画質には影響しないので速度が少し早くなる。必要無ければ --no-psnr で切っておこう。
--no-psnr
Usage: --no-psnr
No PSNR disables the PSNR computation that is displayed after an encode. It does not affect quality and disabling it brings a little speed increase. Unless you want it enabled it would be good to use --no-psnr.
SSIMの計算を停止
スライスを使った併行エンコード。マルチ/マルチコアCPUがあれば速度向上。分散処理の手法と符号化の動作原理からスレッド分散には僅かな画質劣化があるが、少しリッチな設定をしてやれば抑えられる。しかも速度向上分は余る。各CPU/コアあたり1スレッドが適正なので、2コアなら --threads 2、2コア2CPUなら --threads 4。
*スレッド分散方式はこの記述の後(rev.607)で最大4から16に拡張され、分散処理の手法も変わり、画質劣化はより少なくなり、CPU数以上のスレッドを指定してもよくなった。反面、シーンカット検出がやや精度低下。詳細は下記参照。
ageha:07/01/05 threads=<1-16>:http://agehatype0.blog50.fc2.com/blog-entry-170.html
まるも製作所さん:07/07/21(土) x264 [19] スレッド実装:http://www.marumo.ne.jp/db2007_7.htm#21
1スレッドをエンコードに、1スレッドをAVISynth出力のデコードに割り当てる。双方にとってのベストで、画質劣化抜きの高速化になる(エンコードには1スレッドが割り当てられたままで”スライス”されないから)。しかし、速度向上は --threadsで得られるほどではなく30%ほど。
*rev.607のスレッド分散方式変更の影響は不詳。手許ではAviSynth 3.0のビルド未着手。
--threads-input
Usage: --threads <integer>
Parralell encoding using one thread for the encoding, and another thread for the decoding of the AVISynth output. The best of both worlds, faster encoding with no quality loss (since the encoding is still done on one thread and isn't "sliced"), however the speed increase is not as large as you would get with --threads. You might be able to free up 30% extra speed or so.
平行処理の効率を僅かに向上、反面、併行精度(?)が下がる。
*SMP (Symmetric Multiple Processor) - IT用語辞典 http://e-words.jp/w/SMP.html
CPU最適化のオフ。とても遅くなる。普通は使わない。デバッグやトラブルシューティング用。
*Power Mac G5(PPC 2.0GHz×2)とIntel iMac(Core Duo 1.83GHz)の速度比較:OS X ハッキング! (163) Intel Mac強化計画:--no-asm
Usage: --no-asm
No ASM disables all CPU optimisations. This makes things very slow, and is not required for general use, just debugging and/or troubleshooting.
エンコードしたビデオの上にマクロブロック・タイプとモーションベクトルをオーバーレイ表示。非常に遅く、ほとんどの人にとって意味の無い機能だろう。ほうっておくのがベスト。
*原文は確かrev.400番台準拠だったので一部改変してあります。
--visualize
Usage: --visualize
Visualise shows you the macroblocks and motion vectors over the encoded video. Currently x264 is not compiled with this, but it will be slow and next to useless for most people. This is best left off.
アクセス・ユニット・デリミタを使う。
これはフレームの開始点をマーキングするもので、MPEG-2 Transport streams (.ts) 形式での保存やストリーミングに使う。またどうやらPSP用の公式H.264エンコーダでも使うようだ。PSP用ならともかく、特にこれを使う理由は無い。と言うのは.tsはDVB(Digital TV)の放送向けだからだ。一般的にこれは複数の音声と映像チャンネルを含んでいる。なお、PSPも恐らくaud抜きで再生できると思う。
*DVBはEU方式だが、日本の地デジもMPEG-2 TSを使っているハズ。
Uses Access Unit Delimiters. It is used to mark frame start points, for streaming and storage in MPEG-2 Transport streams (.ts). They also seem to be used in official H.264 encodes for Sony's PSP. Aside from using --aud for the PSP (which probably works fine without it), there isn't much reason since .ts as intended for DVB (Digital TV) transmissions, which usually contains multiple audio and video channels.