Media3 Transformer is actively under development and we are looking to hear from you! We welcome your feedback, feature requests and bug reports in the
issue tracker. Follow the
ExoPlayer blog for the latest updates.
การแก้ไขเนื้อหาหลายรายการ
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เมื่อใช้ Transformer คุณจะรวมเนื้อหาสื่อ
หลายรายการเข้าด้วยกันได้ เช่น วิดีโอ
รูปภาพ และไฟล์เสียงเพื่อสร้าง Composition
การส่งออกการเรียบเรียง
วิธีใช้การเปลี่ยนรูปแบบ
(เช่น เอฟเฟกต์หรือการตัดแต่ง) ใน MediaItem
คุณควรสร้างองค์ประกอบ
EditedMediaItem
เพื่อแสดงเนื้อหาที่มีการเปลี่ยนรูปแบบ
จากนั้นสามารถเรียงต่อกันออบเจ็กต์ EditedMediaItem
รายการเข้าด้วยกันเพื่อสร้าง
EditedMediaItemSequence
ตัวอย่างเช่น คุณสามารถสร้าง EditedMediaItemSequence
ที่มีการแก้ไข 2 รายการ
วิดีโอ รายการใน EditedMediaItemSequence
จะเรียงลำดับตามกันและ
ไม่ซ้อนทับกันตามเวลา
Composition
เป็นชุดค่าผสมของ EditedMediaItemSequence
อย่างน้อย 1 รายการ
ออบเจ็กต์ วัตถุทั้ง EditedMediaItemSequence
รายการใน Composition
ผสมกัน
ทำให้คุณรวมเนื้อหาวิดีโอและเสียงไว้ด้วยกันได้
คุณส่งออกออบเจ็กต์ Composition
รายการได้โดยใช้ Transformer
ต่อไปนี้คือตัวอย่างการสร้างและส่งออกชิ้นงานวิดีโอที่ประกอบด้วย
วิดีโอคลิปที่ตัดต่อแล้วซ้อนทับกับแทร็กเสียง:
Kotlin
val transformer = ... // Set up Transformer instance
val video1 = EditedMediaItem.Builder(
MediaItem.fromUri(video1Uri))
.build()
val video2 = EditedMediaItem.Builder(
MediaItem.fromUri(video2Uri))
.build()
val videoSequence = EditedMediaItemSequence(
video1, video2)
val backgroundAudio = EditedMediaItem.Builder(
MediaItem.fromUri(audioUri))
.build()
val backgroundAudioSequence = EditedMediaItemSequence(
ImmutableList.of(backgroundAudio),
/* isLooping= */ true) // Loop audio track through duration of videoSequence
val composition = Composition.Builder(
videoSequence,
backgroundAudioSequence)
.build()
val filePath = ... // Provide file path to save Composition
transformer.start(composition, filePath)
Java
Transformer transformer = ... // Set up Transformer instance
EditedMediaItem video1 = new EditedMediaItem.Builder(
MediaItem.fromUri(video1Uri))
.build();
EditedMediaItem video2 = new EditedMediaItem.Builder(
MediaItem.fromUri(video2Uri))
.build();
EditedMediaItemSequence videoSequence = new EditedMediaItemSequence(
video1, video2);
EditedMediaItem backgroundAudio = new EditedMediaItem.Builder(
MediaItem.fromUri(audioUri))
.build();
EditedMediaItemSequence backgroundAudioSequence = new EditedMediaItemSequence(
ImmutableList.of(backgroundAudio),
/* isLooping= */ true); // Loop audio track through duration of videoSequence
String filePath = ... // Provide file path to save Composition
Composition composition = new Composition.Builder(
videoSequence,
backgroundAudioSequence)
.build();
transformer.start(composition, filePath);
ตัวอย่าง Use Case ที่รองรับ
นี่เป็นรายการกรณีการใช้งานโดยสังเขปที่ Transformer API
รองรับการเรียบเรียงเพลง:
- การรวมเนื้อหาเสียง รูปภาพ และวิดีโอตามลำดับ อย่างไรก็ตาม รายการทั้งหมด
ในลำดับต้องมีแทร็กเดียวกัน ตัวอย่างเช่น คุณไม่สามารถมีลำดับ
ที่มีไฟล์เสียงเท่านั้น ตามด้วยไฟล์วิดีโอ
- การเพิ่มเสียงที่เล่นอยู่เบื้องหลังลงในเนื้อหาวิดีโอ
- การเพิ่มเอฟเฟกต์ในการเรียบเรียง
- การแมปโทนสี HDR ที่ป้อนเป็น SDR เพื่อสร้างเอาต์พุต SDR ที่มีคุณภาพของภาพที่ดียิ่งขึ้น
ข้อจำกัดปัจจุบัน
ลำดับในการเรียบเรียงต้องเป็นไปตามเงื่อนไขที่ระบุไว้ใน
Transformer.start()
นอกจากนี้ ระบบยังไม่รองรับการดำเนินการต่อไปนี้เมื่อทำงานร่วมกับ
การเรียบเรียง:
- เริ่มเล่น
EditedMediaItemSequence
ด้วยออฟเซ็ต
- แทร็กเสียงหรือแทร็กวิดีโอครอสเฟด
คำขอฟีเจอร์
หากคุณมีคำขอฟีเจอร์สำหรับ Transformer API โปรดแจ้งปัญหาใน
ที่เก็บ Media3 GitHub
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ 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,["# Multi-asset editing\n\nUsing Transformer, you can combine multiple media assets, such as videos,\nimages, and audio files to create a `Composition`.\n\nExporting a Composition\n-----------------------\n\nTo apply [transformations](/media/media3/transformer/transformations)\n(such as effects or trimming edits) to a `MediaItem`, you should create an\n[`EditedMediaItem`](/reference/androidx/media3/transformer/EditedMediaItem)\nto represent the asset that has the transformations applied to it.\n\n`EditedMediaItem` objects can then be concatenated together to create an\n[`EditedMediaItemSequence`](/reference/androidx/media3/transformer/EditedMediaItemSequence).\nFor example, you can create an `EditedMediaItemSequence` with two edited\nvideos. Items inside an `EditedMediaItemSequence` are ordered sequentially and\ndon't overlap in time.\n\nA `Composition` is the combination of one or more `EditedMediaItemSequence`\nobjects. All `EditedMediaItemSequence` objects in the `Composition` are mixed\ntogether, allowing you to combine video and audio assets.\n\n`Composition` objects can be exported using Transformer.\n\nHere is an example of creating and exporting a video asset that consists of two\nedited video clips, overlaid with an audio track: \n\n### Kotlin\n\n```kotlin\nval transformer = ... // Set up Transformer instance\n\nval video1 = EditedMediaItem.Builder(\n MediaItem.fromUri(video1Uri))\n .build()\n\nval video2 = EditedMediaItem.Builder(\n MediaItem.fromUri(video2Uri))\n .build()\n\nval videoSequence = EditedMediaItemSequence(\n video1, video2)\n\nval backgroundAudio = EditedMediaItem.Builder(\n MediaItem.fromUri(audioUri))\n .build()\n\nval backgroundAudioSequence = EditedMediaItemSequence(\n ImmutableList.of(backgroundAudio),\n /* isLooping= */ true) // Loop audio track through duration of videoSequence\n\nval composition = Composition.Builder(\n videoSequence,\n backgroundAudioSequence)\n .build()\n\nval filePath = ... // Provide file path to save Composition\n\ntransformer.start(composition, filePath)\n```\n\n### Java\n\n```java\nTransformer transformer = ... // Set up Transformer instance\n\nEditedMediaItem video1 = new EditedMediaItem.Builder(\n MediaItem.fromUri(video1Uri))\n .build();\n\nEditedMediaItem video2 = new EditedMediaItem.Builder(\n MediaItem.fromUri(video2Uri))\n .build();\n\nEditedMediaItemSequence videoSequence = new EditedMediaItemSequence(\n video1, video2);\n\nEditedMediaItem backgroundAudio = new EditedMediaItem.Builder(\n MediaItem.fromUri(audioUri))\n .build();\n\nEditedMediaItemSequence backgroundAudioSequence = new EditedMediaItemSequence(\n ImmutableList.of(backgroundAudio),\n /* isLooping= */ true); // Loop audio track through duration of videoSequence\n\nString filePath = ... // Provide file path to save Composition\n\nComposition composition = new Composition.Builder(\n videoSequence,\n backgroundAudioSequence)\n .build();\n\ntransformer.start(composition, filePath);\n```\n\n\u003cbr /\u003e\n\nExamples of supported use cases\n-------------------------------\n\nThis is a non-exhaustive list of use cases that the Transformer API\nsupports with Compositions:\n\n- Sequentially combining audio, image, and video assets. However, all items in a sequence must have the same tracks. For example, you cannot have a sequence that contains an audio only file, followed by a video file.\n- Adding background audio to a video asset.\n- Adding effects to a Composition.\n- Tone mapping HDR input to SDR to generate better visual quality SDR output.\n\nCurrent limitations\n-------------------\n\nSequences within a Composition must meet the conditions outlined in\n[`Transformer.start()`](/reference/androidx/media3/transformer/Transformer#start(androidx.media3.transformer.Composition,java.lang.String)).\nFurthermore, the following operations are not yet supported when working with\nCompositions:\n\n- Starting playback of an `EditedMediaItemSequence` with an offset.\n- Crossfading video or audio tracks\n\nFeature requests\n----------------\n\nIf you have any feature requests for the Transformer API, file an issue on the\n[Media3 GitHub repository](https://github.com/androidx/media/issues)."]]