RTSP シミュレーター
アップロードした動画ファイルをループする RTSP ソースとしてストリーミングし、カメラなしで推論パイプラインをテストします。
RTSP Simulator は、アップロードした動画ファイルをライブ RTSP ストリームに変換するエッジコンテナサービスです。物理カメラを設置する前にデバイス上で推論パイプラインを構築・テストしたり、既知のクリップを Workflow に対して再生したりするのに使用できます。
アップロードする .mp4 ファイルを Web インターフェースまたは REST API からアップロードするか、Deployment Manager から動画を選択します。サービスはそれを RTSP 互換形式にトランスコードし、停止するまでその結果を連続ループで配信します。
接続詳細
置き換えてください <device-ip> を、Deployment Manager のデバイスページに表示される IP アドレスに置き換えます。
RTSP ストリーム
rtsp://<device-ip>:8554/stream
Web UI、REST API、Swagger ドキュメント
http://<device-ip>:8080
8080
HTTP
Web UI、REST API、Swagger ドキュメントは /docs
8554
RTSP (TCP)
映像ストリームの出力。UDP 転送は無効で、UDP を優先するクライアントは TCP インターリーブにダウングレードされます。
複数のクライアントが同時にストリームを読み取ることができます。
動画形式
Web UI、CLI、API は .mp4 ファイルのみを受け付けます。アップロードは自動的にトランスコードされるため、ストリームはどの RTSP クライアントでも動作します:
コーデック: H.264、Baseline プロファイル
ピクセル形式: yuv420p
音声: 除去、映像のみ
最大ファイルサイズ: デフォルトで 5 GB
Roboflow 動画の使用
デバイスをローカルネットワークから到達できない場合は、Deployment Manager から動画を設定します。デバイスが動画をダウンロードして配信します。
カードには動画名、RTSP URL、およびダウンロードとストリーム状態が表示されます。Roboflow 動画が設定されている間は、ローカルの Web UI と CLI の操作はロックされます。ローカルアップロードに戻すには、「Local upload」を選択して保存します。
Web インターフェースの使用
開く http://<device-ip>:8080 をブラウザで開きます。
デプロイでシミュレートされたストリームを使うには、カメラと同じようにデバイス上のストリームソースとして追加します。参照: ストリームの追加.
CLI の使用
ヘッドレスまたは SSH のみでアクセスする場合、 rtsp-cli ツールはデバイス上で対話型のターミナルインターフェースを提供します。
Web UI を使わずに動画を取り込むには、まず入力ディレクトリにコピーし、その後 CLI を起動して I.
I
取り込み
/data/input/ から動画を選択して変換する /data/input/
P
再生
RTSP ストリーミングを開始
S
停止
ストリーミングを停止して変換済みファイルを削除
D
削除
動画ファイルを削除
C
設定
ストリーム設定を調整(ビットレート、バッファ、遅延)
R
更新
ステータス表示を更新
Q
終了
CLI を終了
ストリームのテスト
任意の RTSP プレーヤーで接続し、ストリームが生きていることを確認します。
このストリームは TCP のみで提供されるため、ffplay に最初に UDP を試させるのではなく、TCP 転送を強制してください。
HTTP API
すべてのエンドポイントは JSON を返します。対話型 Swagger ドキュメントは http://<device-ip>:8080/docsで提供されます。参照: サービス デバイス上サービス API に共通するルールについて。
一般的な流れ
/stop は元のファイルと変換済みファイルの両方も削除してディスク領域を解放するため、次の /play.
アップロード
のみ .mp4 が受け付けられ、アップロード開始前にアクティブなストリームは停止されます。オプションの 設定 部分は、トランスコード時に適用される変換設定の JSON 文字列です。変換済みファイルに組み込まれるため、後から変更するには再アップロードが必要です。
Uploads a video and converts it to the RTSP streaming format. Only .mp4 is accepted. An active stream is stopped before the upload begins.
The optional settings part is a JSON string of conversion settings, applied during transcoding. Because they are baked into the converted file, changing them later requires re-uploading.
Video file to upload. Must be .mp4.
Optional JSON string holding an UploadSettings object. It is a string part rather than a nested object because the service parses it with json.loads before validating, so the UploadSettings schema below documents the shape rather than being referenced here.
{"target_fps": 30, "crf_quality": 23, "max_width": 1920}Upload and conversion succeeded
No file selected, unsupported extension, invalid upload settings, or the file is not a readable video
File exceeds MAX_FILE_SIZE (5 GB by default)
Request failed validation
Conversion failed
Not enough free disk space for the upload
POST /upload HTTP/1.1
Host: device-ip:8080
Content-Type: multipart/form-data
Accept: */*
Content-Length: 93
{
"file": "binary",
"settings": "{\"target_fps\": 30, \"crf_quality\": 23, \"max_width\": 1920}"
}{
"success": true,
"message": "Video uploaded successfully",
"video": {
"filename": "factory_line.mp4",
"size": 125000000,
"size_mb": 119.21,
"extension": ".mp4"
}
}ストリーミング
Starts publishing the converted video to the RTSP server, looping until stopped. Uses the current stream settings.
Streaming started
RTSP stream URL as the service sees it, always naming localhost, on the port set by RTSP_PORT (8554 by default). Consumers off the device must substitute the device address; read rtsp_port from /info rather than assuming 8554.
Already streaming, or no video has been uploaded
The stream failed to start
POST /play HTTP/1.1
Host: device-ip:8080
Accept: */*
{
"success": true,
"message": "Streaming started",
"rtsp_url": "rtsp://localhost:8554/stream"
}Stops the stream and deletes both the original and converted files to free disk space. Uploading again is required before the next /play.
Streaming stopped and files deleted
Not currently streaming
Stop failed
POST /stop HTTP/1.1
Host: device-ip:8080
Accept: */*
{
"success": true,
"message": "text"
}/delete は、ストリームが実行中でなくても動画ファイルを削除し、実行中の場合はまず停止します。
Deletes the original and converted video files, stopping the stream first if it is running. Unlike /stop, this succeeds whether or not a stream is active.
Files deleted
No video files found to delete
Delete failed
POST /delete HTTP/1.1
Host: device-ip:8080
Accept: */*
{
"success": true,
"message": "text"
}ステータス
streaming は components.mediamtx.healthy (ストリーミングサーバー)と components.ffmpeg_process.running (トランスコードおよび公開プロセス)が両方とも true のとき true になります。 components.stream のエントリはそれをゲートしません: components.stream.source_ready は起動時に一時的に false になることがありますが、 streaming はすでに true を読み取っていることがあり、それは正常です。内訳は、失敗したストリームを特定する最速の方法です: components を確認して、再起動する前にどの部分に異常があるかを見てください。
Returns whether the stream is live, plus the health of each component, which is the fastest way to localize a failure.
streaming is true when components.mediamtx.healthy and components.ffmpeg_process.running are both true; the components.stream entry does not gate it. components.stream.source_ready can be false briefly during startup, which is normal.
Current status
RTSP stream URL as the service sees it, always naming localhost, on the port set by RTSP_PORT (8554 by default). Null when not streaming. Consumers off the device must substitute the device address; read rtsp_port from /info rather than assuming 8554.
GET /status HTTP/1.1
Host: device-ip:8080
Accept: */*
Current status
{
"streaming": true,
"rtsp_url": "rtsp://localhost:8554/stream",
"video": {
"filename": "sample.mp4",
"size": 1048576,
"size_mb": 1,
"extension": ".mp4"
},
"components": {
"mediamtx": {
"healthy": true,
"error": null
},
"ffmpeg_process": {
"exists": true,
"pid": 1234,
"running": true,
"exit_code": null
},
"stream": {
"api_available": true,
"source_ready": true,
"readers": 1,
"error": null
}
}
}/info 空きディスク容量や最大アップロードサイズを含む、サービスが現在実行している制限を報告します。大きなファイルを送る前に確認する価値があります。
Returns disk space, the upload size limit, accepted extensions, and the RTSP port.
System information
Maximum upload size in bytes, set by MAX_FILE_SIZE
Accepted file extensions. Only .mp4 today.
Port the RTSP stream is served on, set by RTSP_PORT
GET /info HTTP/1.1
Host: device-ip:8080
Accept: */*
System information
{
"disk_space": {
"total": 1,
"used": 1,
"free": 1,
"free_gb": 1
},
"max_file_size": 1,
"max_file_size_gb": 1,
"allowed_extensions": [
"text"
],
"rtsp_port": 1
}ストリーム設定エンドポイント
再生設定はアップロード設定とは異なり、ストリーミング時に適用され、再アップロードせずにセッション間で変更できます。更新は次の /playで有効になり、現在実行中のストリームには反映されません。
Returns the current playback settings.
Current settings
Playback settings, changeable between streaming sessions without re-uploading.
Maximum bitrate in kbps
5000Buffer size in KB
3000Maximum delay in milliseconds
500GET /stream-settings HTTP/1.1
Host: device-ip:8080
Accept: */*
Current settings
{
"max_bitrate_kbps": 5000,
"buffer_size_kb": 3000,
"max_delay_ms": 500
}Persists new playback settings. They apply to the next streaming session, not the one currently running.
Playback settings, changeable between streaming sessions without re-uploading.
Maximum bitrate in kbps
5000Buffer size in KB
3000Maximum delay in milliseconds
500Settings saved
Request failed validation
Failed to persist settings
POST /stream-settings HTTP/1.1
Host: device-ip:8080
Content-Type: application/json
Accept: */*
Content-Length: 66
{
"max_bitrate_kbps": 5000,
"buffer_size_kb": 3000,
"max_delay_ms": 500
}{
"success": true,
"message": "text"
}設定
環境変数
デバイスの Configuration タブにあるサービスで設定します。参照: デバイス構成を更新.
MAX_FILE_SIZE
5368709120
最大アップロードサイズ(バイト、5 GB)
RTSP_PORT
8554
RTSP サーバーポート
WEB_PORT
8080
Web UI と API のポート
LOG_LEVEL
INFO
ログの詳細度: DEBUG, INFO, WARNING、または ERROR
アップロード設定
これらは変換時に適用されるため、変更するには動画を再アップロードする必要があります。
target_fps
元の
ターゲットフレームレート、1~120。元の
crf_quality
23
品質レベル、0~51(18 は高、23 は中、28 は低)
max_width
元の
縮小時の最大幅、320~7680。元の
ストリーム設定
これらは再生時に適用され、CLI の config メニューまたは /stream-settings エンドポイントからストリーミング セッション間で変更できます。
max_bitrate_kbps
5000
最大ビットレート(kbps、100~100,000)
buffer_size_kb
3000
バッファサイズ(KB、100~50,000)
max_delay_ms
500
最大遅延(ミリ秒、50~5,000)
最終更新
役に立ちましたか?