| Crates.io | shiguredo_srt |
| lib.rs | shiguredo_srt |
| version | 2026.1.0-canary.0 |
| created_at | 2026-01-23 04:43:31.475063+00 |
| updated_at | 2026-01-23 07:54:04.153827+00 |
| description | SRT (Secure Reliable Transport) library |
| homepage | https://github.com/shiguredo/srt-rs |
| repository | https://github.com/shiguredo/srt-rs |
| max_upload_size | |
| id | 2063454 |
| size | 444,234 |
We will not respond to PRs or issues that have not been discussed on Discord. Also, Discord is only available in Japanese.
Please read https://github.com/shiguredo/oss before use.
利用前に https://github.com/shiguredo/oss をお読みください。
Rust で実装された Sans I/O な SRT (Secure Reliable Transport) プロトコルライブラリです。
SRT Listener (受信側) の例です。
cargo run -p srt-listener -- --port 9000
cargo run -p srt-listener -- --port 9000 --passphrase secret
cargo run -p srt-listener -- --host 127.0.0.1 --port 9000
Listener は Caller の接続確立(Connected)から切断までに受信したデータを、
切断時にカレントディレクトリへ srt_<timestamp>.ts として保存します。
オプション:
-h, --host <HOST>: バインドアドレス (デフォルト: 0.0.0.0)-p, --port <PORT>: リッスンポート--passphrase <PASSPHRASE>: 暗号化パスフレーズ--mp4: 切断時に受信した MPEG2-TS を MP4 に変換し、カレントディレクトリへ srt_<timestamp>.mp4 として保存します。(H.264 + AAC のみ対応。変換に失敗した場合も srt_<timestamp>.ts は保存されます)。SRT Caller (送信側) の例です。
cargo run -p srt-caller -- --host 127.0.0.1 --port 9000
cargo run -p srt-caller -- --host 127.0.0.1 --port 9000 --passphrase secret
cat input.ts | cargo run -p srt-caller -- --host 127.0.0.1 --port 9000
オプション:
-h, --host <HOST>: 接続先アドレス-p, --port <PORT>: 接続先ポート--passphrase <PASSPHRASE>: 暗号化パスフレーズ# ターミナル 1: Listener 起動
cargo run -p srt-listener -- --port 9000
# ターミナル 2: Caller からデータ送信
echo 'Hello, SRT!' | cargo run -p srt-caller -- --host 127.0.0.1 --port 9000
# Listener 起動
cargo run -p srt-listener -- --port 9000
# FFmpeg から送信
ffmpeg -re -i input.mp4 -c copy -f mpegts "srt://127.0.0.1:9000?mode=caller"
# FFmpeg で受信
ffmpeg -i "srt://0.0.0.0:9000?mode=listener" -c copy output.ts
# Caller から送信
cat input.ts | cargo run -p srt-caller -- --host 127.0.0.1 --port 9000
Listener を起動:
cargo run -p srt-listener -- --port 9000
OBS の設定:
srt://127.0.0.1:9000?mode=callerSRT 仕様 (draft-sharabayko-srt) では、Keepalive、ACKACK、Shutdown などの制御パケットはデータ部を持たない (0 バイト) と定義されている。
libsrt は全パケットを「ヘッダ部 + データ部」の 2 つの iovec で writev 送信する設計だが、データ部が 0 バイトの場合 writev が正しく動作しない環境がある。そのため、データ部が 0 バイトのパケットに 4 バイトのゼロパディングを追加している。
// libsrt/srtcore/packet.cpp より
case UMSG_KEEPALIVE:
// control info field should be none
// but "writev" does not allow this
m_PacketVector[PV_DATA].set((void*)&m_extra_pad, 4);
break;
Wireshark の SRT dissector も libsrt に合わせて実装されているため、仕様通りの 16 バイトパケットを送ると "Malformed Packet" と表示される。
libsrt および Wireshark との相互運用性のため、同様の 4 バイトゼロパディングを追加する。
対象パケット:
このライブラリはライブストリーミング専用のため、以下の機能は対象外です。
このライブラリが準拠している仕様です。
Apache License 2.0
Copyright 2026-2026, Shiguredo Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.