ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
ส่งออกสถิติการเข้ารหัสวิดีโอ
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ตั้งแต่ Android 13 เป็นต้นไป ลูกค้าแอปจะขอให้โปรแกรมเปลี่ยนไฟล์วิดีโอส่งออกสถิติการเข้ารหัสสำหรับเฟรมวิดีโอที่เข้ารหัสแต่ละเฟรมได้ สถิติที่ได้จากผู้เข้ารหัสวิดีโอจะช่วยให้แอปเพิ่มประสิทธิภาพงานการเข้ารหัสวิดีโอได้ เช่น การเข้ารหัสหลายรอบและการประมวลผลเฟรมก่อนการเข้ารหัส
หากต้องการส่งออกสถิติการเข้ารหัสวิดีโอ ผู้ให้บริการ SoC จะต้องเปลี่ยนโปรแกรมควบคุมการเข้ารหัสวิดีโอตามที่อธิบายไว้ในการอัปเดตโปรแกรมควบคุมการเข้ารหัสวิดีโอ
ข้อมูลสถิติการเข้ารหัสวิดีโอ
เมื่อใช้ Android 13 ตัวแปลงรหัสวิดีโอจะส่งออกข้อมูลสถิติตามที่แสดงในตารางต่อไปนี้
ชื่อสถิติของตัวเข้ารหัส |
คำอธิบาย |
QP เฉลี่ยของบล็อกต่อเฟรม
|
ค่าเฉลี่ยของ QP ของบล็อกทั้งหมดในเฟรมวิดีโอที่เข้ารหัสเป็นสตรีมบิต
|
ประเภทรูปภาพ
|
พิมพ์ I หรือ P หรือ B
|
นักพัฒนาแอปสามารถเรียกข้อมูลสถิติของแต่ละเฟรมได้โดยใช้คลาสนักพัฒนาแอป MediaFormat
การอัปเดตไดรเวอร์โปรแกรมเปลี่ยนไฟล์วิดีโอ
หากต้องการรองรับการส่งออกสถิติการเข้ารหัสวิดีโอ ผู้ให้บริการ SoC จะต้องเปลี่ยนไดรเวอร์โปรแกรมเปลี่ยนไฟล์วิดีโอ ระบบจะเพิ่มคีย์ต่อไปนี้ในฐานข้อมูล Codec 2.0 ใน Android 13
KEY_VIDEO_QP_AVERAGE
อธิบาย QP เฉลี่ยของบล็อกต่อเฟรม
กฎต่อไปนี้มีผลกับการใช้คีย์ KEY_VIDEO_QP_AVERAGE
โปรแกรมเปลี่ยนไฟล์ SoC ต้องปัดเศษค่าเฉลี่ยของ QP ของบล็อกเป็นจำนวนเต็มใกล้ที่สุดก่อนส่งไปยังตัวแปลงรหัส 2.0
ระบบจะคํานวณค่าเฉลี่ยจากระนาบ Luma เท่านั้น
ตัวเข้ารหัส SoC ต้องแสดงผล INT_MAX
หากบล็อกทั้งหมดในเฟรมปัจจุบันอยู่ในโหมดข้าม เงื่อนไขนี้เกิดขึ้นเมื่อไม่มีการเข้ารหัสค่าสัมประสิทธิ์และไม่มีการเข้ารหัสข้อมูล QP ที่สําคัญในเฟรม
KEY_PICTURE_TYPE
อธิบายประเภทรูปภาพของเฟรมที่เข้ารหัสเป็น PICTURE_TYPE_I
,
PICTURE_TYPE_P
,
PICTURE_TYPE_B
หรือ PICTURE_TYPE_UNKNOWN
KEY_VIDEO_ENCODING_STATISTICS_LEVEL
อธิบายระดับข้อมูลสถิติการเข้ารหัสที่ส่งออกจากโปรแกรมเปลี่ยนไฟล์วิดีโอ ดังนี้
ดูการใช้งานอ้างอิงได้ที่ VideoEncodingStatisticsTest
การตรวจสอบความถูกต้อง
เรียกใช้การทดสอบ VideoEncodingStatisticsTest
ของ CTS เพื่อตรวจสอบว่าส่วน QP เฉลี่ยของสถิติการเข้ารหัสวิดีโอทำงานได้อย่างถูกต้อง โดย CTS จะทำการแปลงวิดีโออินพุตเดียวกัน 2 ครั้ง โดย 1 รายการมีอัตราบิตสูงกว่าและอีกรายการมีอัตราบิตต่ำกว่า จากนั้น CTS จะเปรียบเทียบค่า QP เฉลี่ยที่ส่งออก 2 ค่าจากการเข้ารหัส 2 รายการ หาก 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-07-27 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-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);"]]