mux-video

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Mux Video Platform

Mux 视频平台

Comprehensive guide to building video applications with Mux, the developer-first video infrastructure platform. This skill covers video streaming, live streaming, player integrations, analytics with Mux Data, and AI-powered workflows. Whether you are building a video-on-demand platform, live streaming application, or integrating video into an existing product, this documentation provides the patterns and code examples needed to ship quickly.
这是一份面向开发者的视频基础设施平台Mux的综合应用构建指南。本指南涵盖视频点播、直播、播放器集成、Mux Data分析以及AI驱动的工作流。无论你是要搭建视频点播平台、直播应用,还是在现有产品中集成视频功能,这份文档都能提供快速上线所需的设计模式和代码示例。

Key Capabilities

核心功能

  • Video Hosting and Streaming: Upload, transcode, and deliver video content globally via adaptive bitrate streaming (HLS)
  • Live Streaming: Real-time video broadcasting with RTMP/SRT ingest, low-latency options, and automatic recording
  • Mux Player: Drop-in video player components for web (React, vanilla JS), iOS, and Android with built-in analytics
  • Mux Data: Quality of experience analytics, engagement metrics, and real-time monitoring
  • Content Security: Signed playback URLs, DRM protection (Widevine/FairPlay), and domain restrictions
  • AI Workflows: Automatic chapter generation, video summarization, content moderation, and audio dubbing

  • 视频托管与流媒体传输:通过自适应比特率流媒体(HLS)在全球范围内上传、转码并分发视频内容
  • 直播流:支持RTMP/SRT推流的实时视频广播,提供低延迟选项和自动录制功能
  • Mux Player:适用于Web(React、原生JS)、iOS和Android的即插即用视频播放器组件,内置分析功能
  • Mux Data:体验质量分析、参与度指标和实时监控
  • 内容安全:带签名的播放URL、DRM保护(Widevine/FairPlay)和域名限制
  • AI工作流:自动章节生成、视频摘要、内容审核和音频配音

Quick Start

快速开始

Get streaming in five minutes:
  1. Create an API Access Token in the Mux Dashboard with Video Read and Write permissions
  2. Create a video asset from a URL:
bash
curl https://api.mux.com/video/v1/assets \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{ "input": [{ "url": "https://muxed.s3.amazonaws.com/leds.mp4" }], "playback_policy": ["public"] }' \
  -u ${MUX_TOKEN_ID}:${MUX_TOKEN_SECRET}
  1. Play the video using the returned playback ID:
html
<script src="https://cdn.jsdelivr.net/npm/@mux/mux-player"></script>
<mux-player playback-id="YOUR_PLAYBACK_ID"></mux-player>
See examples/quickstart-stream-video.md for the complete walkthrough with SDK examples in Node.js, Python, Ruby, Go, and PHP.

五分钟内开启流媒体服务:
  1. Mux控制台中创建一个具备视频读写权限的API访问令牌
  2. 通过URL创建视频资源:
bash
curl https://api.mux.com/video/v1/assets \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{ "input": [{ "url": "https://muxed.s3.amazonaws.com/leds.mp4" }], "playback_policy": ["public"] }' \
  -u ${MUX_TOKEN_ID}:${MUX_TOKEN_SECRET}
  1. 使用返回的播放ID播放视频:
html
<script src="https://cdn.jsdelivr.net/npm/@mux/mux-player"></script>
<mux-player playback-id="YOUR_PLAYBACK_ID"></mux-player>
查看examples/quickstart-stream-video.md获取完整教程,包含Node.js、Python、Ruby、Go和PHP的SDK示例。

Reference Documentation

参考文档

Core Concepts

核心概念

Foundational knowledge for working with Mux APIs and infrastructure.
FileDescription
reference/mux-fundamentals.mdOrganizations, environments, assets, playback IDs, and API structure
reference/api-authentication.mdAccess tokens, permissions, and secure API request patterns
reference/webhooks.mdWebhook events, signature verification, and event handling
reference/content-security-policy.mdCSP configuration for Mux Player and streaming domains
使用Mux API和基础设施的基础知识。
文件描述
reference/mux-fundamentals.md组织、环境、资源、播放ID和API结构
reference/api-authentication.md访问令牌、权限和安全API请求模式
reference/webhooks.mdWebhook事件、签名验证和事件处理
reference/content-security-policy.mdMux Player和流域名的CSP配置

Mux Player

Mux Player

Drop-in video player components with built-in analytics and adaptive controls.
FileDescription
reference/mux-player-overview.mdPlatform support (web, iOS, Android), installation, and core features
reference/player-setup-integration.mdHTML, React, iframe embed, and native mobile integration
reference/player-customization.mdTheming, CSS variables, custom controls, and branding
reference/player-advanced-features.mdChromecast, AirPlay, DVR mode, picture-in-picture, and quality selection
reference/playback-security.mdSigned URLs, JWT token generation, and playback restrictions
reference/playback-modifiers-resolution.mdResolution capping, bandwidth hints, and playback URL parameters
内置分析和自适应控制的即插即用视频播放器组件。
文件描述
reference/mux-player-overview.md平台支持(Web、iOS、Android)、安装和核心功能
reference/player-setup-integration.mdHTML、React、iframe嵌入和原生移动端集成
reference/player-customization.md主题、CSS变量、自定义控件和品牌化
reference/player-advanced-features.mdChromecast、AirPlay、DVR模式、画中画和画质选择
reference/playback-security.md签名URL、JWT令牌生成和播放限制
reference/playback-modifiers-resolution.md分辨率限制、带宽提示和播放URL参数

Video Upload and Asset Management

视频上传与资源管理

Methods for getting video content into Mux and configuring assets.
FileDescription
reference/upload-methods.mdURL ingestion, direct uploads, and resumable upload protocols
reference/mux-uploader.mdDrop-in upload components for web with progress and error handling
reference/mobile-upload-sdks.mdiOS and Android upload SDKs for native applications
reference/asset-configuration.mdVideo quality tiers, MP4 support, master access, and encoding settings
reference/text-tracks-and-audio.mdCaptions, subtitles, audio tracks, and language configuration
将视频内容上传至Mux并配置资源的方法。
文件描述
reference/upload-methods.mdURL导入、直接上传和可恢复上传协议
reference/mux-uploader.md适用于Web的即插即用上上传组件,支持进度和错误处理
reference/mobile-upload-sdks.md适用于iOS和Android的原生应用上传SDK
reference/asset-configuration.md视频画质等级、MP4支持、主访问权限和编码设置
reference/text-tracks-and-audio.md字幕、副标题、音轨和语言配置

Live Streaming

直播流

Real-time video broadcasting with global ingest and low-latency delivery.
FileDescription
reference/live-streaming-getting-started.mdCreating live streams, stream keys, and basic broadcasting
reference/live-stream-configuration.mdLatency modes, reconnect windows, and recording settings
reference/streaming-protocols-encoder-setup.mdRTMP, RTMPS, SRT protocols and encoder configuration
reference/live-stream-features.mdSimulcasting, live clipping, DVR mode, and embedded captions
reference/live-stream-troubleshooting.mdCommon issues, debugging, and encoder compatibility
支持全球推流和低延迟分发的实时视频广播。
文件描述
reference/live-streaming-getting-started.md创建直播流、流密钥和基础广播设置
reference/live-stream-configuration.md延迟模式、重连窗口和录制设置
reference/streaming-protocols-encoder-setup.mdRTMP、RTMPS、SRT协议和编码器配置
reference/live-stream-features.md多平台同步直播、直播剪辑、DVR模式和嵌入式字幕
reference/live-stream-troubleshooting.md常见问题、调试和编码器兼容性

Mux Data and Analytics

Mux Data与分析

Quality of experience metrics, engagement tracking, and performance monitoring.
FileDescription
reference/metrics-overview.mdViews, watch time, QoE scores, and metric definitions
reference/dashboards-and-filtering.mdDashboard navigation, filters, and data exploration
reference/custom-metadata-and-dimensions.mdCustom dimensions, video metadata, and viewer identification
reference/data-exports.mdCSV exports, S3 delivery, and raw data access
reference/alerts-and-monitoring.mdAlert configuration, thresholds, and notification channels
reference/privacy-and-configuration.mdData retention, GDPR compliance, and privacy settings
体验质量指标、参与度跟踪和性能监控。
文件描述
reference/metrics-overview.md观看次数、观看时长、QoE分数和指标定义
reference/dashboards-and-filtering.md控制台导航、筛选器和数据探索
reference/custom-metadata-and-dimensions.md自定义维度、视频元数据和观众识别
reference/data-exports.mdCSV导出、S3交付和原始数据访问
reference/alerts-and-monitoring.md警报配置、阈值和通知渠道
reference/privacy-and-configuration.md数据保留、GDPR合规和隐私设置

Player Monitoring Integrations

播放器监控集成

Integrating Mux Data with third-party video players.
FileDescription
reference/web-player-integrations.mdVideo.js, HLS.js, Shaka Player, JW Player, and Bitmovin
reference/mobile-player-integrations.mdAVPlayer (iOS), ExoPlayer (Android), and native SDKs
reference/smart-tv-device-integrations.mdRoku, Fire TV, Apple TV, and smart TV platforms
reference/custom-player-integrations.mdBuilding custom player integrations with Mux Data SDK
将Mux Data与第三方视频播放器集成。
文件描述
reference/web-player-integrations.mdVideo.js、HLS.js、Shaka Player、JW Player和Bitmovin
reference/mobile-player-integrations.mdAVPlayer(iOS)、ExoPlayer(Android)和原生SDK
reference/smart-tv-device-integrations.mdRoku、Fire TV、Apple TV和智能电视平台
reference/custom-player-integrations.md使用Mux Data SDK构建自定义播放器集成

Video Features and Tools

视频功能与工具

Additional video capabilities beyond basic playback.
FileDescription
reference/video-clipping.mdCreating clips from assets, URL-based clipping, and clip management
reference/images-and-thumbnails.mdThumbnail generation, animated GIFs, and timeline previews
reference/custom-domains-and-security.mdCNAME setup, SSL certificates, and branded delivery domains
reference/social-sharing-and-special-features.mdOG tags, Twitter cards, and social media optimization
基础播放之外的额外视频功能。
文件描述
reference/video-clipping.md从资源创建剪辑、基于URL的剪辑和剪辑管理
reference/images-and-thumbnails.md缩略图生成、动态GIF和时间轴预览
reference/custom-domains-and-security.mdCNAME设置、SSL证书和品牌化分发域名
reference/social-sharing-and-special-features.mdOG标签、Twitter卡片和社交媒体优化

Framework Integrations

框架集成

Platform-specific guides for popular web and mobile frameworks.
FileDescription
reference/web-framework-integrations.mdNext.js, Remix, SvelteKit, Nuxt, and other web frameworks
reference/react-native-getting-started.mdSetting up Mux in React Native applications
reference/react-native-video-features.mdVideo playback, uploads, and analytics in React Native
reference/react-native-ui-patterns.mdCommon UI patterns for video apps (feeds, stories, full-screen)
reference/react-native-advanced-topics.mdPerformance optimization, offline playback, and background audio
针对热门Web和移动框架的平台专属指南。
文件描述
reference/web-framework-integrations.mdNext.js、Remix、SvelteKit、Nuxt和其他Web框架
reference/react-native-getting-started.md在React Native应用中设置Mux
reference/react-native-video-features.mdReact Native中的视频播放、上传和分析
reference/react-native-ui-patterns.md视频应用的常见UI模式(信息流、故事、全屏)
reference/react-native-advanced-topics.md性能优化、离线播放和后台音频

CMS Integrations and SDKs

CMS集成与SDK

Connecting Mux with content management systems and backend services.
FileDescription
reference/cms-integrations.mdSanity, Contentful, WordPress, Strapi, and other CMS platforms
reference/server-side-sdks.mdNode.js, Python, Ruby, PHP, Go, Java, and .NET SDKs
reference/mcp-server.mdMux MCP server for AI assistant integrations
将Mux与内容管理系统和后端服务连接。
文件描述
reference/cms-integrations.mdSanity、Contentful、WordPress、Strapi和其他CMS平台
reference/server-side-sdks.mdNode.js、Python、Ruby、PHP、Go、Java和.NET SDK
reference/mcp-server.md用于AI助手集成的Mux MCP服务器

Pricing and Cost Management

定价与成本管理

Understanding and optimizing Mux costs.
FileDescription
reference/pricing-overview.mdPricing model, billable metrics, and cost calculations
reference/cost-optimization.mdStrategies for reducing encoding, storage, and delivery costs

了解并优化Mux成本。
文件描述
reference/pricing-overview.md定价模型、计费指标和成本计算
reference/cost-optimization.md降低编码、存储和分发成本的策略

Examples

示例

Getting Started

入门指南

FileDescription
examples/quickstart-stream-video.mdComplete guide to uploading and playing your first video
examples/webhook-signature-verification.mdVerifying webhook signatures in Node.js, Python, and Ruby
文件描述
examples/quickstart-stream-video.md上传并播放首个视频的完整指南
examples/webhook-signature-verification.md在Node.js、Python和Ruby中验证Webhook签名

Player Integration

播放器集成

FileDescription
examples/mux-player-web-setup.mdSetting up Mux Player in HTML, React, and Vue applications
examples/signed-url-playback.mdGenerating and using signed playback URLs with JWTs
examples/drm-protected-playback.mdConfiguring DRM-protected content with Widevine and FairPlay
文件描述
examples/mux-player-web-setup.md在HTML、React和Vue应用中设置Mux Player
examples/signed-url-playback.md生成并使用带JWT的签名播放URL
examples/drm-protected-playback.md配置带Widevine和FairPlay的DRM保护内容

Video Upload

视频上传

FileDescription
examples/direct-upload-with-webhooks.mdClient-side uploads with server webhook handling
examples/video-with-captions-and-metadata.mdUploading videos with subtitle tracks and custom metadata
文件描述
examples/direct-upload-with-webhooks.md客户端上传搭配服务器Webhook处理
examples/video-with-captions-and-metadata.md上传带字幕轨道和自定义元数据的视频

Live Streaming

直播流

FileDescription
examples/live-streaming-complete-setup.mdEnd-to-end live streaming implementation
examples/live-captions-and-simulcasting.mdAdding live captions and streaming to multiple platforms
文件描述
examples/live-streaming-complete-setup.md端到端直播流实现
examples/live-captions-and-simulcasting.md添加直播字幕并推流至多个平台

Analytics

分析

FileDescription
examples/custom-analytics-integration.mdAdvanced Mux Data integration with custom dimensions
examples/web-player-integration-example.mdIntegrating Mux Data with Video.js and HLS.js
examples/mobile-player-integration-example.mdiOS and Android analytics SDK integration
文件描述
examples/custom-analytics-integration.md带自定义维度的高级Mux Data集成
examples/web-player-integration-example.md将Mux Data与Video.js和HLS.js集成
examples/mobile-player-integration-example.mdiOS和Android分析SDK集成

Video Features

视频功能

FileDescription
examples/video-clipping-workflows.mdCreating clips for social sharing and highlights
examples/thumbnail-and-preview-integration.mdDynamic thumbnails and timeline hover previews
文件描述
examples/video-clipping-workflows.md为社交分享和精彩片段创建剪辑
examples/thumbnail-and-preview-integration.md动态缩略图和时间轴悬停预览

React Native

React Native

FileDescription
examples/react-native-stories-app.mdBuilding an Instagram-style stories feature
examples/react-native-video-upload-workflow.mdComplete upload flow with progress and background handling
文件描述
examples/react-native-stories-app.md构建Instagram风格的故事功能
examples/react-native-video-upload-workflow.md带进度和后台处理的完整上传流程

CMS Integration

CMS集成

FileDescription
examples/cms-setup-sanity.mdIntegrating Mux with Sanity CMS
文件描述
examples/cms-setup-sanity.md将Mux与Sanity CMS集成

AI Workflows

AI工作流

FileDescription
examples/ai-video-workflows.mdAutomatic chapters, summarization, and tagging with @mux/ai
examples/content-moderation-strategies.mdAI-powered content moderation for user-generated video
examples/video-synchronization.mdSyncing video playback across multiple viewers

文件描述
examples/ai-video-workflows.md使用@mux/ai实现自动章节、摘要和标签
examples/content-moderation-strategies.md针对用户生成视频的AI驱动内容审核
examples/video-synchronization.md在多个观众间同步视频播放

Important Notes

重要说明

API Authentication

API认证

All Mux API requests require authentication using a Token ID and Token Secret. API requests must be made from a server environment - the API does not support CORS and credentials should never be exposed in client-side code.
所有Mux API请求都需要使用Token ID和Token Secret进行认证。API请求必须在服务器环境中发起——API不支持CORS,且凭据绝不能暴露在客户端代码中。

Playback IDs vs Asset IDs

播放ID vs 资源ID

  • Asset IDs are used to manage content via the API (
    api.mux.com
    )
  • Playback IDs are used to stream content to viewers (
    stream.mux.com
    )
  • An asset can have multiple playback IDs with different policies (public vs signed)
  • 资源ID用于通过API(
    api.mux.com
    )管理内容
  • 播放ID用于向观众分发内容(
    stream.mux.com
  • 一个资源可以有多个播放ID,对应不同的策略(公开 vs 签名)

Webhooks vs Polling

Webhook vs 轮询

Always prefer webhooks over polling to track asset status. Webhooks provide real-time notifications when assets are ready, live streams change state, or uploads complete. Configure webhooks per environment in the Mux Dashboard.
跟踪资源状态时,始终优先使用Webhook而非轮询。Webhook会在资源准备就绪、直播流状态变化或上传完成时提供实时通知。在Mux控制台中按环境配置Webhook。

Video Quality Tiers

视频画质等级

Mux offers different video quality tiers (basic, plus, premium) that affect encoding quality and pricing. Choose the appropriate tier based on your content type and quality requirements.
Mux提供不同的视频画质等级(基础版、增强版、高级版),会影响编码质量和定价。根据内容类型和画质需求选择合适的等级。

Stream Key Security

流密钥安全

Live stream keys should be treated as secrets. Anyone with the stream key can broadcast to your live stream. Reset keys immediately if compromised.
直播流密钥应视为机密信息。任何人获取流密钥后都可以向你的直播流推流。一旦泄露,请立即重置密钥。