Skip to content

Commit 3a01f59

Browse files
committed
Add environment configuration and entrypoint script for video processing
- Create .env.example for API credentials and device configuration - Update Dockerfile to copy entrypoint script - Implement entrypoint.sh to manage camera settings based on robot type - Modify docker-compose.yml to include environment variables for robot type and devices - Enhance supervisord.conf with improved logging and restart policies
1 parent 7a272d8 commit 3a01f59

File tree

6 files changed

+68
-13
lines changed

6 files changed

+68
-13
lines changed

.env.example

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# OpenMind API Credentials
2+
OM_API_KEY_ID=your_api_key_id
3+
OM_API_KEY=your_api_key
4+
5+
# Robot Configuration
6+
# Set ROBOT_TYPE to "go2" to automatically enable front camera streaming
7+
# Options: "default", "go2"
8+
ROBOT_TYPE=default
9+
10+
# Camera and Microphone Devices
11+
CAMERA_INDEX=/dev/video0
12+
MICROPHONE_INDEX=default_mic_aec
13+
14+
# Advanced: Manual override for front camera (auto-detected from ROBOT_TYPE if not set)
15+
# Uncomment to manually control front camera regardless of ROBOT_TYPE
16+
# ENABLE_FRONT_CAMERA=true

Dockerfile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,8 @@ RUN python3 -m pip install --ignore-installed pip setuptools wheel packaging \
9999
ENV VIRTUAL_ENV=/app/om1_video_processor/.venv
100100
ENV PATH="/app/om1_video_processor/.venv/bin:${PATH}"
101101

102-
RUN echo '#!/bin/bash' > /entrypoint.sh && \
103-
echo 'set -e' >> /entrypoint.sh && \
104-
echo 'echo ">> Using baked Python virtualenv at $VIRTUAL_ENV"' >> /entrypoint.sh && \
105-
echo 'echo ">> Starting supervisord..."' >> /entrypoint.sh && \
106-
echo 'exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf' >> /entrypoint.sh && \
107-
chmod +x /entrypoint.sh
102+
COPY entrypoint.sh /entrypoint.sh
103+
RUN chmod +x /entrypoint.sh
108104

109105
ENTRYPOINT ["/entrypoint.sh"]
106+

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@ This tool uses the OM1 modules to create an intelligent video streaming pipeline
4343
export OM_API_KEY="your_api_key"
4444
```
4545

46-
3. (Optional) Configure camera and microphone devices:
46+
3. (Optional) Configure robot type and devices:
4747
```bash
48+
export ROBOT_TYPE="go2" # Set to "go2" to enable front camera
4849
export CAMERA_INDEX="/dev/video0" # Default camera device
4950
export MICROPHONE_INDEX="default_mic_aec" # Default microphone device
5051
```
5152

53+
> [!NOTE]
54+
> When `ROBOT_TYPE=go2`, the front camera stream is automatically enabled. You can also manually control this with `ENABLE_FRONT_CAMERA=true`.
55+
5256
> [!NOTE]
5357
> Please refer to the [OpenMind Avatar documentation](https://github.com/OpenMind/OM1-avatar) for the audio and video device configuration details.
5458

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ services:
1313
runtime: nvidia
1414
shm_size: "8g"
1515
environment:
16+
- ROBOT_TYPE=${ROBOT_TYPE:-g1}
1617
- CAMERA_INDEX=${CAMERA_INDEX:-/dev/video0}
1718
- MICROPHONE_INDEX=${MICROPHONE_INDEX:-default_mic_aec}
1819
- MIC_RNNOISE_MODEL_PATH=${MIC_RNNOISE_MODEL_PATH:-/app/om1_video_processor/models/rnnoise.rnnn}

entrypoint.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo ">> Using baked Python virtualenv at $VIRTUAL_ENV"
5+
6+
# Auto-enable front camera for go2 robot type
7+
if [ "${ROBOT_TYPE}" = "go2" ] && [ -z "${ENABLE_FRONT_CAMERA}" ]; then
8+
export ENABLE_FRONT_CAMERA=true
9+
echo ">> ROBOT_TYPE=go2 detected, enabling front camera"
10+
elif [ -z "${ENABLE_FRONT_CAMERA}" ]; then
11+
export ENABLE_FRONT_CAMERA=false
12+
fi
13+
14+
echo ">> Front camera enabled: ${ENABLE_FRONT_CAMERA}"
15+
echo ">> Starting supervisord..."
16+
17+
# Start supervisord
18+
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf

video_processor/supervisord.conf

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ chmod=0700
55
[supervisord]
66
nodaemon=true
77
user=root
8+
loglevel=info
9+
logfile=/dev/stdout
10+
logfile_maxbytes=0
11+
pidfile=/var/run/supervisord.pid
812

913
[supervisorctl]
1014
serverurl=unix:///var/run/supervisor.sock
@@ -15,6 +19,8 @@ supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
1519
[program:mediamtx]
1620
command=mediamtx /mediamtx.yml
1721
autorestart=true
22+
autorestart=unexpected
23+
exitcodes=0
1824
startsecs=5
1925
stdout_logfile=/dev/stdout
2026
stdout_logfile_maxbytes=0
@@ -24,8 +30,10 @@ priority=100
2430

2531
[program:top_camera_local]
2632
command=uv run om_face_recog_stream --device %(ENV_CAMERA_INDEX)s --draw-boxes --draw-names --show-fps --no-window --gallery %(ENV_GALLERY_DIR)s --embeds-dir %(ENV_EMBEDS_DIR)s --http-host 0.0.0.0 --http-port 6793
27-
autorestart=true
33+
autorestart=unexpected
34+
exitcodes=0
2835
startsecs=10
36+
startretries=999999999
2937
stdout_logfile=/dev/stdout
3038
stdout_logfile_maxbytes=0
3139
stderr_logfile=/dev/stderr
@@ -34,8 +42,10 @@ priority=200
3442

3543
[program:top_camera_cloud]
3644
command=ffmpeg -rtsp_transport tcp -i rtsp://localhost:8554/top_camera -c copy -f rtsp -rtsp_transport tcp rtsp://api-video-ingest.openmind.org:8554/top_camera/%(ENV_OM_API_KEY_ID)s?api_key=%(ENV_OM_API_KEY)s
37-
autorestart=true
45+
autorestart=unexpected
46+
exitcodes=0
3847
startsecs=15
48+
startretries=999999999
3949
stdout_logfile=/dev/stdout
4050
stdout_logfile_maxbytes=0
4151
stderr_logfile=/dev/stderr
@@ -44,8 +54,11 @@ priority=300
4454

4555
[program:front_camera_cloud]
4656
command=ffmpeg -rtsp_transport tcp -i rtsp://localhost:8554/front_camera -c copy -f rtsp -rtsp_transport tcp rtsp://api-video-ingest.openmind.org:8554/front_camera/%(ENV_OM_API_KEY_ID)s?api_key=%(ENV_OM_API_KEY)s
47-
autorestart=true
57+
autostart=%(ENV_ENABLE_FRONT_CAMERA)s
58+
autorestart=unexpected
59+
exitcodes=0
4860
startsecs=15
61+
startretries=999999999
4962
stdout_logfile=/dev/stdout
5063
stdout_logfile_maxbytes=0
5164
stderr_logfile=/dev/stderr
@@ -54,8 +67,10 @@ priority=310
5467

5568
[program:down_camera_cloud]
5669
command=ffmpeg -rtsp_transport tcp -i rtsp://localhost:8554/down_camera -c copy -f rtsp -rtsp_transport tcp rtsp://api-video-ingest.openmind.org:8554/down_camera/%(ENV_OM_API_KEY_ID)s?api_key=%(ENV_OM_API_KEY)s
57-
autorestart=true
70+
autorestart=unexpected
71+
exitcodes=0
5872
startsecs=15
73+
startretries=999999999
5974
stdout_logfile=/dev/stdout
6075
stdout_logfile_maxbytes=0
6176
stderr_logfile=/dev/stderr
@@ -64,8 +79,10 @@ priority=320
6479

6580
[program:mic_local]
6681
command=ffmpeg -f pulse -fragment_size 480 -i %(ENV_MICROPHONE_INDEX)s -af "arnndn=m=%(ENV_MIC_RNNOISE_MODEL_PATH)s,aresample=async=1:first_pts=0" -map 0:a -c:a libopus -b:a 128k -ar 48000 -ac 2 -application lowdelay -frame_duration 10 -compression_level 0 -packet_loss 0 -f rtsp -rtsp_transport tcp rtsp://localhost:8554/audio
67-
autorestart=true
82+
autorestart=unexpected
83+
exitcodes=0
6884
startsecs=10
85+
startretries=999999999
6986
stdout_logfile=/dev/stdout
7087
stdout_logfile_maxbytes=0
7188
stderr_logfile=/dev/stderr
@@ -74,8 +91,10 @@ priority=250
7491

7592
[program:mic_cloud]
7693
command=ffmpeg -rtsp_transport tcp -i rtsp://localhost:8554/audio -c copy -f rtsp -rtsp_transport tcp rtsp://api-video-ingest.openmind.org:8554/audio/%(ENV_OM_API_KEY_ID)s?api_key=%(ENV_OM_API_KEY)s
77-
autorestart=true
94+
autorestart=unexpected
95+
exitcodes=0
7896
startsecs=20
97+
startretries=999999999
7998
stdout_logfile=/dev/stdout
8099
stdout_logfile_maxbytes=0
81100
stderr_logfile=/dev/stderr

0 commit comments

Comments
 (0)