> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# إضافة تحديد فيديو لـ Kling

> استخدم نقطة النهاية Add Video Selection من Kling لإضافة عناصر التحديد في تحرير الفيديو متعدد العناصر، مما يتيح تعديلات موجهة والتحكم في المشهد عبر CometAPI.

استخدم نقطة النهاية هذه لتحديد منطقة الفيديو التي تريد من المحرر متعدد الوسائط أن يعمل عليها.

## كيفية عمل التحديد

* يأتي `session_id` من [تهيئة الفيديو للتحرير](./initialize-video-for-editing)
* استخدم الحساب نفسه و`session_id` المطابق تمامًا كما تم إرجاعه من التهيئة
* يحدد `frame_index` الإطار الذي تضع فيه النقاط
* `points` هي إحداثيات مطبعة بين `0` و`1`
* توثّق Kling ما يصل إلى 10 إطارات محددة وما يصل إلى 10 نقاط لكل إطار

## دورها في سير العمل

<Steps>
  <Step title="التهيئة أولاً">
    ابدأ بـ [تهيئة الفيديو للتحرير](./initialize-video-for-editing) للحصول على `session_id` صالح.
  </Step>

  <Step title="إضافة النقاط أو تحسينها">
    استدعِ نقطة النهاية هذه أثناء بناء المنطقة المراد تحريرها.
  </Step>

  <Step title="معاينة المنطقة">
    استخدم [معاينة منطقة الفيديو المحددة](./preview-selected-video-area) قبل الإرسال النهائي.
  </Step>
</Steps>

<Tip>
  للاطلاع على المرجع الكامل للمعلمات، راجع [وثائق Kling API](https://kling.ai/document-api/apiReference/model/multiElements).
</Tip>


## OpenAPI

````yaml api/openapi/video/kling/multimodal-video-editing/post-add-video-selection.openapi.json POST /kling/v1/videos/multi-elements/add-selection
openapi: 3.1.0
info:
  title: Add Video Selection API
  version: 1.0.0
  description: Add or refine selection points for a Kling multimodal editing session.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /kling/v1/videos/multi-elements/add-selection:
    post:
      summary: Add selection points to a Kling multimodal session
      description: >-
        Place normalized point coordinates on a chosen frame within the current
        session.
      operationId: add_video_selection
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - session_id
                - points
                - frame_index
              properties:
                session_id:
                  type: string
                  description: >-
                    Selection session id returned by init-selection. Follow-up
                    calls must use the same account and exact session id.
                frame_index:
                  type: integer
                  description: >-
                    Frame number


                    Supports adding up to 10 marked frames, meaning video
                    selections can be marked based on a maximum of 10 frames.

                    Only 1 frame can be marked at a time.
                points:
                  type: array
                  description: >-
                    Click coordinates, represented by x and y.

                    Value range: [0,1], expressed as a percentage; [0,1]
                    represents the top-left corner of the frame.

                    Supports adding multiple marked points simultaneously, with
                    a maximum of 10 points per frame.
                  items:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
              default:
                session_id: <session_id>
                points:
                  - x: 0.5
                    'y': 0.5
                frame_index: 1
            examples:
              Default:
                summary: Default
                value:
                  session_id: <session_id>
                  frame_index: 1
                  points:
                    - x: 0.5
                      'y': 0.5
      responses:
        '200':
          description: Selection updated.
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                properties:
                  code:
                    type: integer
                  message:
                    type: string
                  data:
                    type: object
                    additionalProperties: true
      x-codeSamples:
        - lang: Shell
          label: Default
          source: >
            curl
            https://api.cometapi.com/kling/v1/videos/multi-elements/add-selection
            \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                  "session_id": "<session_id>",
                  "frame_index": 1,
                  "points": [
                    {
                      "x": 0.5,
                      "y": 0.5
                    }
                  ]
                }'
        - lang: Python
          label: Default
          source: |
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/kling/v1/videos/multi-elements/add-selection",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                  "session_id": "<session_id>",
                  "frame_index": 1,
                  "points": [
                    {
                      "x": 0.5,
                      "y": 0.5
                    }
                  ]
                },
            )

            result = response.json()
            print(result.get("code"), result.get("data"))
        - lang: JavaScript
          label: Default
          source: >
            const response = await
            fetch("https://api.cometapi.com/kling/v1/videos/multi-elements/add-selection",
            {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                "session_id": "<session_id>",
                "frame_index": 1,
                "points": [
                  {
                    "x": 0.5,
                    "y": 0.5
                  }
                ]
              }),
            });


            const result = await response.json();

            console.log(result.code, result.data);
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````