2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
動画エンコード統計情報のエクスポート
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android 13 以降では、アプリ クライアントは動画エンコーダに、エンコードされた動画フレームごとにエンコード統計情報をエクスポートするようリクエストできます。動画エンコーダから取得した統計情報により、アプリは、マルチパス エンコードやエンコード前のフレーム前処理などの動画エンコード タスクを最適化できます。
動画エンコード統計情報をエクスポートするには、SoC ベンダーは動画エンコーダ ドライバの更新の説明に沿って、動画エンコーダ ドライバを変更する必要があります。
動画エンコード統計情報のデータ
Android 13 では、次の表に示すように、動画エンコーダによって統計データがエクスポートされます。
エンコーダ統計情報の名前 |
説明 |
1 フレームあたりの平均ブロック QP |
ビットストリームにエンコードされた動画フレーム内のすべてのブロック QP の平均 |
画像のタイプ |
タイプ I、P、または B |
デベロッパーは、MediaFormat
デベロッパー クラスを使用して、各フレームの統計情報を取得できます。
動画エンコーダ ドライバの更新
動画エンコード統計情報のエクスポートをサポートするには、SoC ベンダーは動画エンコーダ ドライバを変更する必要があります。Android 13 の Codec 2.0 ベースでは、以下のキーが追加されました。
リファレンス実装については、VideoEncodingStatisticsTest
をご覧ください。
検証
VideoEncodingStatisticsTest
CTS テストを実行し、動画エンコード統計情報の平均 QP 部分が正しく動作することを検証します。CTS では、同じ入力動画に対して 2 つのエンコード(1 つは高いビットレート、もう 1 つは低いビットレート)を実行します。次に、CTS で 2 つのエンコードからエクスポートされた 2 つの平均 QP 値を比較します。低いビットレートのエンコードの平均 QP が、高いビットレートのエンコードの平均 QP よりも大きい場合、CTS で合格します。
動画エンコード統計情報のエクスポート機能が有効な場合に、この機能をオフにすることを検証するには、次のように VIDEO_ENCODING_STATISTICS_LEVEL_NONE
キーを使用します。
format.setInteger(MediaFormat.KEY_VIDEO_ENCODING_STATISTICS_LEVEL, MediaFormat.VIDEO_ENCODING_STATISTICS_LEVEL_NONE);
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-03-05 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-03-05 UTC。"],[],[],null,["# Export video encoding statistics\n\nStarting with Android 13, app clients can request the\nvideo encoder to export encoding statistics for each encoded video frame. With\nthe statistics obtained from the video encoder, apps can optimize their video\nencoding tasks such as multipass encoding and frame preprocessing prior to\nencoding.\n\nTo export video encoding statistics, SoC vendors must change the video encoder\ndriver as described in [Updates to the video encoder driver](#updates-encoder).\n\nVideo encoding statistics data\n------------------------------\n\nWith Android 13, the video encoder exports statistics\ndata as shown in the following table.\n\n| Name of encoder statistics | Description |\n|----------------------------|-------------------------------------------------------------------------------------|\n| Average block QP per frame | The average of all block QPs in the video frame that are encoded into the bitstream |\n| Picture type | Type I or P or B |\n\nDevelopers can retrieve statistics information for each frame by using the\n[`MediaFormat`](https://developer.android.com/reference/android/media/MediaFormat)\ndeveloper class.\n\nUpdates to the video encoder driver\n-----------------------------------\n\nTo support the export of video encoding statistics, SoC vendors must change the\nvideo encoder driver. The following keys are added in the Codec 2.0 base in\nAndroid 13:\n\n- [`KEY_VIDEO_QP_AVERAGE`](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/media/java/android/media/MediaFormat.java;drc=5ad6db77423479d027abb791ad3c02da39513a2c;l=1154) describes the per-frame\n average block QP.\n\n The following rules apply to the implementation of the `KEY_VIDEO_QP_AVERAGE`\n key:\n - The SoC encoder must round the average of the block QPs to the nearest\n integer before emitting to Codec 2.0.\n\n - The average value is computed only from a luma plane.\n\n - The SoC encoder must return `INT_MAX` if all the blocks in the current\n frame are in the skipped mode. This condition occurs when no coefficients are\n encoded and no significant QP info is encoded in the frame.\n\n- [`KEY_PICTURE_TYPE`](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/media/java/android/media/MediaFormat.java;drc=5ad6db77423479d027abb791ad3c02da39513a2c;l=1163)\n describes the picture type of the encoded frame as [`PICTURE_TYPE_I`](https://developer.android.com/reference/android/media/MediaFormat#PICTURE_TYPE_I),\n [`PICTURE_TYPE_P`](https://developer.android.com/reference/android/media/MediaFormat#PICTURE_TYPE_P),\n [`PICTURE_TYPE_B`](https://developer.android.com/reference/android/media/MediaFormat#PICTURE_TYPE_B),\n or [`PICTURE_TYPE_UNKNOWN`](https://developer.android.com/reference/android/media/MediaFormat#PICTURE_TYPE_UNKNOWN).\n\n- [`KEY_VIDEO_ENCODING_STATISTICS_LEVEL`](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/media/java/android/media/MediaFormat.java;drc=5ad6db77423479d027abb791ad3c02da39513a2c;l=1122) describes the level of\n encoding statistics information emitted from video encoder, as follows:\n\n - When the encoder generates no information about encoding statistics,\n this key is set to [`VIDEO_ENCODING_STATISTICS_LEVEL_NONE`](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/media/java/android/media/MediaFormat.java;drc=5ad6db77423479d027abb791ad3c02da39513a2c;l=1129).\n\n - When the encoder generates `KEY_VIDEO_QP_AVERAGE` and `KEY_PICTURE_TYPE`\n for each frame, this key is set to [`VIDEO_ENCODING_STATISTICS_LEVEL_1`](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/media/java/android/media/MediaFormat.java;drc=5ad6db77423479d027abb791ad3c02da39513a2c;l=1136).\n\nSee [`VideoEncodingStatisticsTest`](https://cs.android.com/android/platform/superproject/+/android-latest-release:cts/tests/tests/media/codec/src/android/media/codec/cts/VideoEncodingStatisticsTest.java;drc=77bafd18279c8d6dad49fd74dac2e369fdc6ba69;l=56)\nfor a reference implementation.\n\nValidation\n----------\n\nRun the [`VideoEncodingStatisticsTest`](https://cs.android.com/android/platform/superproject/+/android-latest-release:cts/tests/tests/media/codec/src/android/media/codec/cts/VideoEncodingStatisticsTest.java;drc=77bafd18279c8d6dad49fd74dac2e369fdc6ba69;l=56)\nCTS test to validate that the average QP part of the video encoding statistics\nworks correctly: CTS runs two encodings of the same input video, one with a\nhigher bitrate, and another with a lower bitrate. CTS then compares the two\nexported average QP values from the two encodings. If the average QP from the encoding\nwith the lower bitrate is higher than the average QP from the encoding with the\nhigher bitrate, CTS passes.\n\nTo validate turning off the exporting video encoding statistics feature when\nenabled, use the `VIDEO_ENCODING_STATISTICS_LEVEL_NONE` key as follows: \n\n format.setInteger(MediaFormat.KEY_VIDEO_ENCODING_STATISTICS_LEVEL, MediaFormat.VIDEO_ENCODING_STATISTICS_LEVEL_NONE);"]]