feat: camera_server v2 — encodeur hw v4l2h264enc + fallback sw

- Suppression du bloc MJPEG (double pipeline impossible sur Pi Zero 2W,
  interdit par CLAUDE.md : Flask = health + settings uniquement)
- Encodeur par défaut : v4l2h264enc hardware (/dev/video11, bcm2835-codec)
  attend ~40% CPU vs 80-90% avec x264enc
- Fallback automatique vers x264enc si v4l2h264enc échoue au démarrage
- Correction pipeline split : shlex.split() remplace .split() (bug caps GStreamer)
- Lecture stderr gst-launch en temps réel (thread daemon)
- GstManager : restart propre via SIGTERM sur le process GStreamer
- Signal SIGTERM/SIGINT : arrêt propre du process GStreamer
- /settings POST : changement à chaud de jetson_host, bitrate, encoder, etc.
- CLAUDE.md : correction "pas de GPU" → VideoCore IV + pipelines hw/sw documentés

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-09 10:52:14 +02:00
parent 9221a1a2b9
commit e2ceeded8a
2 changed files with 226 additions and 149 deletions

View File

@ -1,25 +1,50 @@
# WireClaw — Pi Zero 2W
## Contexte
Composant vidéo du drone d'inspection WireClaw.
Caméra OV5647 (CSI) → GStreamer RTP H264 → Jetson
## Hardware
- Modèle : Raspberry Pi Zero 2W
- CPU : 4× ARM Cortex-A53 @1GHz
- GPU : VideoCore IV — encodeur H264 hardware disponible via v4l2h264enc (/dev/video11)
- RAM : 512MB
- OS : Raspberry Pi OS Bookworm Lite (64-bit)
- Caméra : OV5647 (module CSI standard Raspberry Pi)
- Boîtier : dissipateur thermique
- Charge CPU encodage : ~40% CPU (hw) vs ~80-90% (sw x264)
- Prérequis : gpu_mem=160 dans /boot/firmware/config.txt
## Stack
- OS : Raspberry Pi OS Bookworm Lite
- Caméra : OV5647, libcamerasrc (pas v4l2src)
- Encodage : x264enc tune=zerolatency bitrate=1000
- Transport : RTP H264 pt=96 UDP port 5600
- Caméra : libcamerasrc OBLIGATOIRE (Bookworm, pas v4l2src)
- Encodage : v4l2h264enc hardware (défaut) → x264enc software (fallback auto)
- omxh264enc : non disponible sur Bookworm 64-bit (OpenMAX supprimé)
- Transport : RTP H264 pt=96 UDP
- Flask : API légère port 5000 (health + settings uniquement, pas de MJPEG local)
## Réseau
- Dev Freebox : Pi Zero 192.168.1.132 → Jetson 192.168.1.84
- Hotspot WireClaw : Pi Zero DHCP → Jetson 10.42.0.1
- Dev Freebox : 192.168.1.132 → Jetson 192.168.1.84:5600
- Hotspot WireClaw : DHCP → Jetson 10.42.0.1:5600
## Pipeline émetteur validé
## Pipelines validés
### Hardware (v4l2h264enc) — défaut
gst-launch-1.0 libcamerasrc ! \
video/x-raw,width=640,height=480,format=NV12,framerate=15/1 ! \
v4l2convert ! \
v4l2h264enc video-bitrate=1000000 extra-controls="controls,repeat_sequence_header=1" ! \
video/x-h264,level=(string)3.2 ! \
h264parse ! \
rtph264pay config-interval=1 pt=96 ! \
udpsink host=192.168.1.84 port=5600
### Software (x264enc) — fallback
gst-launch-1.0 libcamerasrc ! \
video/x-raw,width=640,height=480,framerate=15/1 ! \
videoconvert ! x264enc tune=zerolatency bitrate=1000 ! \
rtph264pay config-interval=1 pt=96 ! \
udpsink host=192.168.1.84 port=5600
## Rôle dans WireClaw
- Émet uniquement le flux RTP vers le Jetson
- Pas de traitement local (YOLOv8 tourne sur le Jetson CUDA)
- Réglages caméra via POST /settings (proxyfié depuis FastAPI Jetson)
## Repo
git.syoul.fr/nicoboy/wireclaw-pizero