Reachy Mini documentation

📡 Cài đặt GStreamer

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

📡 Cài đặt GStreamer

Hướng dẫn này sẽ giúp bạn cài đặt GStreamer để nhận các luồng video và âm thanh từ Reachy Mini của bạn. Xem kiến trúc phương tiện để hiểu cách các luồng được truy cập cục bộ hoặc từ xa tùy thuộc vào cấu hình.

Các Python wheels có sẵn cho các nền tảng Windows và macOS và đã được bao gồm trong các phụ thuộc của dự án. Mọi thứ nên hoạt động ngay lập tức. Chỉ người dùng Linux mới cần cài đặt thủ công.

🐧 Linux🍎 macOS🪟 Windows
⚠️ Cài đặt thủ công✅ Python wheels✅ Python wheels

🔧 Cài đặt GStreamer và các plugin webrtc

Bước 1: Cài đặt GStreamer

Đối với các hệ thống dựa trên Ubuntu/Debian:

Trong terminal của bạn, chạy:

sudo apt-get update
sudo apt-get install \
    libgstreamer-plugins-bad1.0-dev \
    libgstreamer-plugins-base1.0-dev \
    libgstreamer1.0-dev \
    libglib2.0-dev \
    libssl-dev \
    libgirepository1.0-dev \
    libcairo2-dev \
    libportaudio2 \
    libnice10 \
    gstreamer1.0-plugins-good \
    gstreamer1.0-alsa \
    gstreamer1.0-plugins-bad \
    gstreamer1.0-nice \
    python3-gi \
    python3-gi-cairo    

Chỉ dành cho Ubuntu 22.04: Phiên bản GStreamer mặc định quá cũ. Cần Gstreamer >=1.22. Bạn cần thêm một PPA để có GStreamer 1.24.x:

sudo add-apt-repository ppa:savoury1/multimedia
sudo apt update
sudo apt install \
    libgstreamer1.0-dev \
    libgstreamer-plugins-base1.0-dev \
    libgstreamer-plugins-good1.0-dev \
    libgstreamer-plugins-bad1.0-dev

Kiểm tra xem bạn đã có phiên bản chính xác chưa:

pkg-config --modversion gstreamer-1.0
# Should output 1.24.x or higher

Bước 2: Cài đặt Rust

Trên Linux, plugin WebRTC không được bật theo mặc định và cần được biên dịch thủ công từ mã nguồn Rust. Cài đặt Rust từ dòng lệnh bằng cách sử dụng rustup:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env

Bước 3: Xây dựng và cài đặt plugin WebRTC

Để xây dựng và cài đặt plugin WebRTC, hãy chạy các lệnh sau:

# Clone the GStreamer Rust plugins repository
git clone https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
cd gst-plugins-rs
# 0.14.5 ships a critical webrtcsink fix for a deadlock between
# remote description and ICE handling that manifested on the
# daemon as the historical "stuck at session" UX (the JS client
# spinning forever because libnice never reached `connected`).
# Older 0.14.x tags (0.14.1, 0.14.2, 0.14.3) do NOT carry this
# fix; see the upstream CHANGELOG. The daemon-side negotiation
# watchdog (`reachy_mini.media.media_server`) is the safety net,
# but pinning to a fixed plugin means that net should rarely fire.
git checkout 0.14.5

# Install the cargo-c build tool
cargo install cargo-c

# Create installation directory
sudo mkdir -p /opt/gst-plugins-rs
sudo chown $USER /opt/gst-plugins-rs

# Build and install the WebRTC plugin (this may take several minutes)
cargo cinstall -p gst-plugin-webrtc --prefix=/opt/gst-plugins-rs --release

# Add plugin path to your environment
echo 'export GST_PLUGIN_PATH=/opt/gst-plugins-rs/lib/x86_64-linux-gnu:$GST_PLUGIN_PATH' >> ~/.bashrc
source ~/.bashrc

💡 Lưu ý: Đối với các hệ thống ARM64 (như Raspberry Pi), hãy thay x86_64-linux-gnu bằng aarch64-linux-gnu trong lệnh export.

✅ Xác minh cài đặt

Cuối cùng, bạn có thể kiểm tra cài đặt GStreamer của mình như sau:

# install the optional tools
sudo apt install gstreamer1.0-tools

# Check version
gst-launch-1.0 --version

# Test basic functionalities
gst-launch-1.0 videotestsrc ! autovideosink

# Verify WebRTC plugin
gst-inspect-1.0 webrtcsrc

Bạn cũng nên có thể nhập các thư viện GStreamer trong môi trường Python:

python -c "import gi"

Xử lý sự cố & Kiểm thử đơn vị

Nếu bạn gặp sự cố với luồng, bạn có thể kiểm tra các thành phần riêng lẻ như sau.

Thử nghiệm 1: Tạo thủ công WebRTC Server Chạy pipeline GStreamer này trên robot để kiểm tra camera và bộ mã hóa:

gst-launch-1.0 webrtcsink run-signalling-server=true meta="meta,name=reachymini" name=ws libcamerasrc ! capsfilter caps=video/x-raw,width=1280,height=720,framerate=60/1,format=YUY2,colorimetry=bt709,interlace-mode=progressive ! queue !  v4l2h264enc extra-controls="controls,repeat_sequence_header=1" ! 'video/x-h264,level=(string)4' ! ws. alsasrc device=hw:4 ! queue ! audioconvert ! audioresample ! opusenc ! audio/x-opus, rate=48000, channels=2 ! ws.
Update on GitHub