Create custom profile

Tạo custom profile trước khi chọn nó trong upload. Trang này ví dụ tạo 1 profile có ID preview phục vụ nhu cầu preview video trước khi xuất bản; thay ID và các trường cấu hình theo nhu cầu. Xem các trường profile và Authentication .

Cân nhắc dung lượng: Khi được transcode, mỗi custom profile tạo thêm bản MP4 phái sinh và sử dụng thêm dung lượng lưu trữ, kể cả khi cùng độ cao với một standard profile. Ưu tiên dùng standard profile sẵn có nếu đáp ứng nhu cầu; để preview 360p, xem hướng dẫn dùng standard 360 . Chỉ tạo custom profile khi cần cấu hình riêng. Việc tạo cấu hình profile chưa tự tạo file; dung lượng tăng khi rendition được transcode và lưu.

Request

curl --request POST \
  'https://mps.mediacdn.vn/v1/namespaces/<namespace>/video_profiles' \
  --header 'X-Namespace-Authen: <namespace-secret-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "audio_bitrate_kbps": 128,
  "codec": "h264",
  "force_fps": true,
  "force_scale": true,
  "fps": 30,
  "height": 360,
  "id": "preview",
  "max_video_bitrate_kbps": 1200
}'

Video được ép về 30 FPS; force_scale=true cho phép upscale file gốc thấp hơn 360. Bitrate audio là 128 kbps và trần video là 1200 kbps; ví dụ không đặt bitrate video mục tiêu. Chiều rộng được tính từ file gốc (ví dụ file gốc 16:9 cho output 640×360).

Gợi ý max_video_bitrate_kbps

Các giá trị khởi điểm dưới đây theo bảng VBV maxrate mặc định của CPU transcoder MPS. Đây là trần bitrate video, không phải bitrate trung bình cam kết, không gồm audio và không phải HLS BANDWIDTH. Giá trị cấu hình profile sẽ được ưu tiên hơn mặc định. Điều chỉnh theo chất lượng file gốc, mức chuyển động và nhu cầu; không cần tạo custom profile chỉ để dùng một chất lượng standard.

Chất lượng height max_video_bitrate_kbps gợi ý
144p 144 300
240p 240 600
360p 360 1200
480p 480 1800
720p 720 3750
1080p 1080 6000

Response

HTTP 201:

{
  "status": true,
  "status_code": "S001",
  "description": "Successful",
  "data": {
    "audio_bitrate_kbps": 128,
    "codec": "h264",
    "force_fps": true,
    "force_scale": true,
    "fps": 30,
    "height": 360,
    "id": "preview",
    "max_video_bitrate_kbps": 1200,
    "status": "enabled",
    "profile_type": "custom",
    "transcode_type": "transcode"
  }
}

Upload và kích hoạt custom profile ngay

Sau khi POST tạo profile thành công, gửi ID preview trong video_profile_ids của legacy upload. ID profile hợp lệ tự yêu cầu transcode bất đồng bộ, không cần convert=1, kể cả khi các standard profile đang dùng on-the-fly; không có nghĩa MP4 hoàn tất ngay trong response upload.

curl --request POST 'https://mps.mediacdn.vn/_/upload' \
  --form 'secret_key=<namespace-secret-key>' \
  --form 'filename=videos/preview-example.mp4' \
  --form 'file=@/path/to/video.mp4' \
  --form 'video_profile_ids=preview'

Chỉ chọn ID đã có và enabled. Khi rendition sẵn sàng, lấy URL trong mp4_qualities của Get public info . Custom profile không tự được thêm vào HLS master/mobile; muốn đưa vào HLS cần cấu hình delivery phù hợp.

Sử dụng và lỗi

Gửi video_profile_ids=preview trong legacy upload mà không cần convert, hoặc chọn ID này trong transcode job . Rendition preview xuất hiện trong mp4_qualities khi sẵn sàng; tạo profile không tự thêm nó vào HLS delivery.

400 cho cấu hình sai; 401/403 cho xác thực/quyền/whitelist; 404 cho namespace thiếu; 409 (E409) cho ID đã có; 500 khi lưu thất bại. Dùng GET để kiểm tra trước khi tạo, không tạo lại khi nhận 409.

Muốn đưa custom profile vào HLS, xem Manage delivery .