A partire dal 27 marzo 2025, ti consigliamo di utilizzare android-latest-release
anziché aosp-main
per compilare e contribuire ad AOSP. Per ulteriori informazioni, vedi Modifiche ad AOSP.
Esportare le statistiche di codifica video
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
A partire da Android 13, i client di app possono richiedere al codificatore video di esportare le statistiche di codifica per ogni frame video codificato. Con
le statistiche ottenute dal codificatore video, le app possono ottimizzare le proprie attività di codifica video, come la codifica multipass e la preelaborazione dei frame prima della codifica.
Per esportare le statistiche di codifica video, i fornitori di SoC devono modificare il driver del codificatore video come descritto in Aggiornamenti al driver del codificatore video.
Dati delle statistiche sulla codifica video
Con Android 13, il codificatore video esporta i dati statistici come mostrato nella tabella seguente.
Nome delle statistiche del codificatore |
Descrizione |
QP blocco medio per frame
|
La media di tutti i QP di blocco nel frame video codificati nel flusso di bit
|
Tipo di immagine
|
Tipo I, P o B
|
Gli sviluppatori possono recuperare le informazioni statistiche per ogni frame utilizzando la classe sviluppatore
MediaFormat
.
Aggiornamenti al driver dell'encoder video
Per supportare l'esportazione delle statistiche di codifica video, i fornitori di SoC devono modificare il driver del codificatore video. Le seguenti chiavi vengono aggiunte alla base del codec 2.0 in Android 13:
KEY_VIDEO_QP_AVERAGE
descrive il QP medio per blocco per frame.
All'implementazione della chiave KEY_VIDEO_QP_AVERAGE
si applicano le seguenti regole:
L'encoder SoC deve arrotondare la media delle QP del blocco al numero intero più vicino prima di emettere in Codec 2.0.
Il valore medio viene calcolato solo da un piano di luma.
L'encoder SoC deve restituire INT_MAX
se tutti i blocchi nell'attuale
frame sono in modalità saltata. Questa condizione si verifica quando non vengono codificati coefficienti e non vengono codificate informazioni QP significative nel frame.
KEY_PICTURE_TYPE
descrive il tipo di immagine del frame codificato come PICTURE_TYPE_I
, PICTURE_TYPE_P
, PICTURE_TYPE_B
o PICTURE_TYPE_UNKNOWN
.
KEY_VIDEO_ENCODING_STATISTICS_LEVEL
descrive il livello di informazioni sulle statistiche di codifica emesse dall'encoder video, come segue:
Per un'implementazione di riferimento, consulta VideoEncodingStatisticsTest
.
Convalida
Esegui il test CTS VideoEncodingStatisticsTest
per verificare che la parte relativa al QP medio delle statistiche di codifica video funzioni correttamente: CTS esegue due codifiche dello stesso video di input, una con una maggiore velocità in bit e un'altra con una minore. CTS confronta quindi i due valori QP medi esportati dalle due codifiche. Se il QP medio dell'encoding con la velocità in bit inferiore è superiore al QP medio dell'encoding con la velocità in bit superiore, il CTS viene superato.
Per convalidare la disattivazione della funzionalità di esportazione delle statistiche di codifica video quando è attiva, utilizza la chiave VIDEO_ENCODING_STATISTICS_LEVEL_NONE
come segue:
format.setInteger(MediaFormat.KEY_VIDEO_ENCODING_STATISTICS_LEVEL, MediaFormat.VIDEO_ENCODING_STATISTICS_LEVEL_NONE);
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2025-07-27 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-07-27 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);"]]