FFmpeg libavcodec AAC Encoder Help 日本語訳 (Japanese)

外部ライブラリに頼らないFFmpegプロジェクトネイティブのオープンソースのAACエンコーダが2016年2月リリースのFFmpeg v3.0でついに実装された。
FFmpegから利用できる外部ライブラリのAACエンコーダにはいろいろあった。近年ではドイツのフラウンホーファー集積回路研究所がAndoridの開発者向けに公開していたAACコーデックライブラリFDKAACがよく聞かれる。
このFDKAACはARM搭載のAndorid向けということもあり、低負荷整数演算のみで作成されている。一方、音質を高めた浮動小数点数演算エンコーディングに対応した商用利用の許諾済みAACコーデックライブラリは同研究所から別名でリリースされている。こちらの古いバージョンがWinampに同梱されていた。
話を戻すとソースコードはFDKAACは同研究所独自のライセンスで公開されている。GPLとは互換性はあるものの自分以外の第3者への自由な再配布。つまりそのライセンスに同意し則らないと利用の許諾がされない。

2016年12月現在、私は使えるような品質ではないように思う。ステレオ96kbpsでは聴くに堪えない。128kbps未満の音質/ビットのパフォーマンスはかなり悪い。

あとlibavformatの範疇だろうけどタイムスケールの精度が悪い。CD音源を入力したなら44100サンプル毎秒なので44100分の1秒精度は欲しい。それなのに1000分の1秒精度にしている。つまりサンプル単位ではなく劣るミリ秒単位精度。

エンコーダディレイは1フレームちょうどの1024サンプル。ただそれを正しく示せていないためかデコーダが正しいサンプル数を取り出せていない。iTunes互換タグも書いてくれない。

やはりFFmpegにおいて音声は映像より優先度が低い。


レートコントロールファクター

-b:a <int bits per second>

ターゲットビットレートモード。これを指定すると自動的にビット配分に固定型(一定型)が選択されます。いわゆるCBR。聴覚品質の一定さよりもビットレートの一定さを優先するため、聴覚品質を重視したい素材の場合には向かない。ストリーミングサービスプロパイダで画一的にビットレートをコントロールしたい人や帯域幅が狭い場合でどうしても狙い通りのビットレートに収めたい場合のみ使用したい。指定の仕方はビット毎秒単位。ステレオ音声で合計256kbpsをターゲットにしたい場合は-b:a 256kとする

Set bit rate in bits/s. Setting this automatically activates constant bit rate (CBR) mode. If this option is unspecified it is set to 128kbps.

-q:a <float quality>

ターゲットクオリティモード。これを指定すると自動的にビット配分に変動型(可変型)が選択されます。いわゆるVBR。聴覚品質の一定さを優先する。その結果ビットレートは素材によって左右されるため予想できない。ファイルサイズもそれと同様である。まだ実験段階。本来であれば音楽作品など聴覚品質を重視したい素材の場合に向いている。

Set quality for variable bit rate (VBR) mode. This option is valid only using the ffmpeg command-line tool. For library interface users, use global_quality.

カットオフ周波数

-cutoff <int Frequency>

カットオフ周波数を強制的に指定します。入力した音声ファイルのうちどの周波数から上を取り除くかということです。ローパスフィルターLPFとも同義と思われる。高ビットレートの場合を除き低中ビットレート時にはエンコーダがきれいに聞こえるように動的(臨機応変)にカットオフ周波数を調整し決定します。これがどう作用するのか理解し、意図をもっている人が使うオプション。

Set cutoff frequency. If unspecified will allow the encoder to dynamically adjust the cutoff to improve clarity on low bitrates.

符号化ツール

-aac_coder <method>

AACエンコーダの符号化方法を指定するオプション。利用可能な値は以下の3通り。

Set AAC encoder coding method. Possible values:
‘twoloop’

ツーループ探索符号化方法

Two loop searching (TLS) method.

デフォルト。この符号化方法はまず周波数帯域閾値に応じて量子化係数を設定し、その次に量子化係数を特定の数で足したり引いたりして最適な量子化係数の組み合わせを見つけようと試みます。

aac_is、aac_ms、aac_pnsが有効かどうかに基づいて調整されます。

This method first sets quantizers depending on band thresholds and then tries to find an optimal combination by adding or subtracting a specific value from all quantizers and adjusting some individual quantizer a little. Will tune itself based on whether aac_is, aac_ms and aac_pns are enabled. This is the default choice for a coder.
‘anmr’
Average noise to mask ratio (ANMR) trellis-based solution.

これは(今のところ)品質の良くないストリームを生成する実験的な符号化方法です。(今のところ)デフォルトのツーループ符号化方法に比べ品質安定性に劣り、符号加速度も劣る。しかしポテンシャルは有している。また(今のところ)aac_isやaac_pnsに対応していません。(今のところ)推奨はされません。

This is an experimental coder which currently produces a lower quality, is more unstable and is slower than the default twoloop coder but has potential. Currently has no support for the aac_is or aac_pns options. Not currently recommended.
‘fast’

量子化係数一定法。

Constant quantizer method.

この符号化方法はすべての周波数帯域に対し同じ一定の量子化係数で符号化します。これは全符号化方法で最も高速です。裏返せばビットレートのコントロール手段はありません。またaac_isやaac_pnsに対応していません。人間の音響心理の特性を生かさない符号化方法であるため推奨はされません。

This method sets a constant quantizer for all bands. This is the fastest of all the methods and has no rate control or support for aac_is or aac_pns. Not recommended.

デバグオプション

-aac_ms [0|1]

ミッドサイド符号化を有効にする。これを指定しないデフォルトではautoとなっており、ミッドサイド符号化を有効にしたほうが有益な周波数帯域に自動的に使用される。

このオプションを指定することでミッドサイド符号化を全周波数帯域での使用を強制したり(デバグに便利)、逆に全周波数帯域で使用を不可にできる。

Sets mid/side coding mode. The default value of "auto" will automatically use M/S with bands which will benefit from such coding. Can be forced for all bands using the value "enable", which is mainly useful for debugging or disabled using "disable".

-aac_is [0|1]

ステレオ符号化ツール使用法の強度(インテンシティステレオコーディング)を設定します。デフォルトで有効。デフォルトでは似たような2つのステレオバンドに対し有益であると判断した場合、ステレオ符号化ツールの強度は自動的に切り替わる。デバグのために強制無効化ができる。

Sets intensity stereo coding tool usage. By default, it’s enabled and will automatically toggle IS for similar pairs of stereo bands if it’s benefitial. Can be disabled for debugging by setting the value to "disable".

-aac_pns [0|1]

PNS(認識可能ノイズ置換)の使用を設定します。デフォルトで有効。デコードの際に低エントロピーな高周波数帯域を、認識できないホワイトノイズ(シャーって聞こえる音)に置換する。デバグのために強制無効化ができる。

Uses perceptual noise substitution to replace low entropy high frequency bands with imperceivable white noise during the decoding process. By default, it’s enabled, but can be disabled for debugging purposes by using "disable".

-aac_tns [0|1]

エンコードの際に量子化ノイズを隠し、デコードの際にそれを戻す高周波数帯域にかかるマルチタップFIR(有限インパルス応答)フィルタの使用を有効にします。デフォルトで有効。

広範囲の不快なアーティファクトを減少させるだけでなく、高周波数帯域のエントロピーを減少させます。中低周波数帯域により多くのビットを振り分けることを可能にする。 デバグのために強制無効化ができる。

Enables the use of a multitap FIR filter which spans through the high frequency bands to hide quantization noise during the encoding process and is reverted by the decoder. As well as decreasing unpleasant artifacts in the high range this also reduces the entropy in the high bands and allows for more bits to be used by the mid-low bands. By default it’s enabled but can be disabled for debugging by setting the option to "disable".

-aac_ltp [0|1]

ロングタームプリディクションエクステンション(長期予測拡張)を有効にする。これはフレームのあらゆる周波数帯域において一定のハーモニックピークを拡張することで人間の声やソロピアノ音楽といった周波数帯域幅が非常に小さい(狭い)シチュエーションにおいて符号化効率を向上させます。このオプションはAAC-LCプロファイルの際に黙示(暗に有効指定される=必ず使用)される。また次のaac_predとは互換性がなく排他の関係で、同時に利用することはできない。サンプリングレートを減らすためには-arオプションを使用します。

Enables the use of the long term prediction extension which increases coding efficiency in very low bandwidth situations such as encoding of voice or solo piano music by extending constant harmonic peaks in bands throughout frames. This option is implied by profile:a aac_low and is incompatible with aac_pred. Use in conjunction with -ar to decrease the samplerate.

-aac_pred [0|1]

(この部分はまったくわかってないのでGoogle翻訳そのものです。原文参照)

送信されたスペクトル係数が、現在の係数から以前の「予測された」係数を差し引いたものに置き換えられる部分でより古典的な予測法を使用する。

理論上は低中ビットレートにおける品質を向上させます。 実際には時々です。このオプションはAAC-MAINプロファイルを黙示し、AAC-LCプロファイルでは使用できません。上述の通りaac_ltpと互換性がなく、同時に利用できません。

Enables the use of a more traditional style of prediction where the spectral coefficients transmitted are replaced by the difference of the current coefficients minus the previous "predicted" coefficients. In theory and sometimes in practice this can improve quality for low to mid bitrate audio. This option implies the aac_main profile and is incompatible with aac_ltp.

プロファイル指定

-profile:a <profile name>

プロファイルを設定する。利用可能な値は以下の4通り。

Sets the encoding profile, possible values:
‘aac_low’

AAC-LCプロファイル。これがデフォルトのため無指定の場合このAAC-LCプロファイルが選択される。意味は低負荷、低複雑性といったところ。2017年現在、最も普及しているプロファイルで、最も再生互換性が高く、最もまともな品質をもたらす。

The default, AAC "Low-complexity" profile. Is the most compatible and produces decent quality.
‘mpeg2_aac_low’

AAC-LC(MPEG-2)プロファイル。PNSを無効化した-profile:a aac_low -aac_pns 0と同等。PNSはMPEG4の仕様によって導入されたのでMPEG2の時代にはPNSは使用できない。特に意図がない限りこれを選択する必要はない。

Equivalent to -profile:a aac_low -aac_pns 0. PNS was introduced with the MPEG4 specifications.
‘aac_ltp’

AAC-LTPプロファイル。ロングタームプリディクションプロファイル。aac_ltpオプションが使用されると自動的にこのプロファイルになります。逆にこのプロファイルを指定すると自動的にaac_ltpオプションが有効になります。MPEG4で導入された。

Long term prediction profile, is enabled by and will enable the aac_ltp option. Introduced in MPEG4.
‘aac_main’

AAC-MAINプロファイル。メインプロファイル。メインということもあってこちらが本当の主要プロファイルである。が、電池持ち(低負荷)が優先されたiPodやウォークマン、携帯電話、スマートフォン、デジタルオーディオプレイヤーがそろってLCプロファイルのみのサポートを掲げたためメインプロファイルの認知度や再生互換性は低い。aac_predオプションが使用されると自動的にこのプロファイルになります。逆にこのプロファイルを指定すると自動的にaac_predオプションが有効になります。MPEG2で導入された。

Main-type prediction profile, is enabled by and will enable the aac_pred option. Introduced in MPEG2.

プロファイルの指定がない場合デフォルトでAAC-LCプロファイルが選択されます。

If this option is unspecified it is set to ‘aac_low’.

コメント

非公開コメント