-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RSDK-8274, RSDK-8624, RSDK-8647, RSDK-8687] Video Storage and Save/Fetch DoCommand #7
Changes from all commits
ad7c9b4
6d80dad
893d866
4d08c13
c882b9b
7fa5f79
2ab2177
759fd7a
bc0f91c
e2d1bb2
aab2f56
a3625b4
57315de
cd1342f
dc0f851
407b660
6b7f6fe
b903538
4920daf
9d5513d
e3e6ae2
a365090
9e898d1
7c56445
0a62bf1
bc44c46
2b8312d
215a839
7fde866
7154f76
dcf6e60
cc978c0
e302fd8
15dfd27
ac3aa96
12995ca
cd905fd
11a7e33
a81f392
0bdb4db
9a05b3e
e3e2023
b6cb04f
477f1a6
982ce07
dd098b3
d3335f8
3f4c883
558ea94
71194ee
d4010d2
5e9a3ce
065b157
fcdf787
d2b40fc
e2aeb08
d9e52ac
58392d0
39c871c
fae564e
ca23a8d
f5881e3
30762d9
a5654e8
d752970
aaea5ec
e5a1c4c
0422835
3322c46
ce73a77
2db1577
63b4f06
0129fed
991dbf5
1173352
5029eb0
8093d04
df64d71
94f4c19
2577335
76a6de3
87e20e7
3f8b4e5
16993f5
fcab4f4
29848c7
796015a
0c6129a
c702035
3fb3924
9640348
52ba17e
b19551d
9e48e06
a48bc1b
a8fc69a
e114a23
77ad5f2
546a31c
71bdb77
e42f2e8
f649b48
c74b5a6
b6e545e
4d95d8a
85ab51e
69c0db5
a7a174a
ac31aa2
ab9f2d5
4e8d545
e7909ee
d171597
6b98fa0
0706a70
d67ae6f
e20b90d
011210a
8230a5d
d54a527
204f579
1dd46bf
c67818e
b3416e5
a5b998a
cae1464
14efd1c
7ad11db
3380049
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
vs: | ||
image_amd64: ghcr.io/viamrobotics/antique2:amd64-cache | ||
image_arm64: ghcr.io/viamrobotics/antique2:arm64-cache | ||
image_arm: ghcr.io/viamrobotics/antique2:armhf-cache | ||
minimum_date: 2023-10-26T20:00:00.0Z | ||
update_interval: 168h0m0s | ||
user: testbot | ||
group: testbot | ||
persistent: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.mp4 filter=lfs diff=lfs merge=lfs -text |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: run linter on each commit | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '**/**.go' | ||
- 'Makefile' | ||
- '.github/workflows/lint.yml' | ||
pull_request: | ||
paths: | ||
- '**/**.go' | ||
- 'Makefile' | ||
- '.github/workflows/lint.yml' | ||
|
||
jobs: | ||
quality-checks: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.21 | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y libx264-dev | ||
|
||
- name: Run linter | ||
run: make lint |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*video-store | ||
FFmpeg | ||
.env | ||
*.DS_Store | ||
bin |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
SOURCE_OS ?= $(shell uname -s | tr '[:upper:]' '[:lower:]') | ||
SOURCE_ARCH ?= $(shell uname -m) | ||
TARGET_OS ?= $(SOURCE_OS) | ||
TARGET_ARCH ?= $(SOURCE_ARCH) | ||
normalize_arch = $(if $(filter aarch64,$(1)),arm64,$(if $(filter x86_64,$(1)),amd64,$(1))) | ||
SOURCE_ARCH := $(call normalize_arch,$(SOURCE_ARCH)) | ||
TARGET_ARCH := $(call normalize_arch,$(TARGET_ARCH)) | ||
|
||
BIN_OUTPUT_PATH = bin/$(TARGET_OS)-$(TARGET_ARCH) | ||
TOOL_BIN = bin/gotools/$(shell uname -s)-$(shell uname -m) | ||
|
||
FFMPEG_TAG ?= n6.1 | ||
FFMPEG_VERSION ?= $(shell pwd)/FFmpeg/$(FFMPEG_TAG) | ||
FFMPEG_VERSION_PLATFORM ?= $(FFMPEG_VERSION)/$(TARGET_OS)-$(TARGET_ARCH) | ||
FFMPEG_BUILD ?= $(FFMPEG_VERSION_PLATFORM)/build | ||
FFMPEG_OPTS ?= --prefix=$(FFMPEG_BUILD) \ | ||
--disable-shared \ | ||
--disable-programs \ | ||
--disable-doc \ | ||
--disable-everything \ | ||
--enable-static \ | ||
--enable-libx264 \ | ||
--enable-gpl \ | ||
--enable-encoder=libx264 \ | ||
--enable-muxer=segment \ | ||
--enable-muxer=mp4 \ | ||
--enable-demuxer=segment \ | ||
--enable-demuxer=concat \ | ||
--enable-demuxer=mov \ | ||
--enable-demuxer=mp4 \ | ||
--enable-parser=h264 \ | ||
--enable-protocol=file \ | ||
--enable-protocol=concat \ | ||
--enable-protocol=crypto \ | ||
--enable-bsf=h264_mp4toannexb | ||
|
||
CGO_LDFLAGS := "-L$(FFMPEG_BUILD)/lib -lavcodec -lavutil -lavformat -l:libjpeg.a /usr/lib/aarch64-linux-gnu/libx264.a -lz" | ||
CGO_CFLAGS := -I$(FFMPEG_BUILD)/include | ||
GOFLAGS := -buildvcs=false | ||
export PKG_CONFIG_PATH=$(FFMPEG_BUILD)/lib/pkgconfig | ||
|
||
.PHONY: lint tool-install test clean | ||
|
||
$(BIN_OUTPUT_PATH)/video-store: *.go cam/*.go $(FFMPEG_BUILD) | ||
go mod tidy | ||
CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_CFLAGS=$(CGO_CFLAGS) go build -o $(BIN_OUTPUT_PATH)/video-store main.go | ||
|
||
$(FFMPEG_VERSION_PLATFORM): | ||
git clone https://github.com/FFmpeg/FFmpeg.git --depth 1 --branch $(FFMPEG_TAG) $(FFMPEG_VERSION_PLATFORM) | ||
|
||
$(FFMPEG_BUILD): $(FFMPEG_VERSION_PLATFORM) | ||
# Only need nasm to build assembly kernels for amd64 targets. | ||
ifeq ($(SOURCE_OS),linux) | ||
ifeq ($(SOURCE_ARCH),amd64) | ||
which nasm || (sudo apt update && sudo apt install -y nasm) | ||
endif | ||
endif | ||
cd $(FFMPEG_VERSION_PLATFORM) && ./configure $(FFMPEG_OPTS) && $(MAKE) -j$(NPROC) && $(MAKE) install | ||
|
||
tool-install: | ||
GOBIN=`pwd`/$(TOOL_BIN) go install \ | ||
github.com/edaniels/golinters/cmd/combined \ | ||
github.com/golangci/golangci-lint/cmd/golangci-lint \ | ||
github.com/rhysd/actionlint/cmd/actionlint | ||
|
||
lint: tool-install $(FFMPEG_BUILD) | ||
go mod tidy | ||
CGO_CFLAGS=$(CGO_CFLAGS) GOFLAGS=$(GOFLAGS) $(TOOL_BIN)/golangci-lint run -v --fix --config=./etc/.golangci.yaml | ||
|
||
|
||
test: $(BIN_OUTPUT_PATH)/video-store | ||
git lfs pull | ||
go test -v ./tests/ | ||
|
||
clean: | ||
rm -rf $(BIN_OUTPUT_PATH) | ||
rm -rf FFmpeg | ||
git clean -fxd |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# Video Storage | ||
The `video-store` module brings security camera functionality to your smart machine! The module consumes a source [Camera](https://docs.viam.com/components/camera/) and saves the output as video files on disk. You can then upload video slices to the cloud using the [save](#save) command, or request the video bytes directly using the [fetch](#fetch) command. | ||
|
||
> **Note:** This component is a work in progress and is not yet fully implemented. | ||
|
||
## Configure your `video-store` component | ||
|
||
Fill in the attributes as applicable to the component, according to the template below. | ||
|
||
```json | ||
{ | ||
"name": <video_store_component_name>, | ||
"namespace": "rdk", | ||
"type": "camera", | ||
"model": "viam:video:storage", | ||
"attributes": { | ||
"camera": <camera_component_name>, [required] | ||
"sync": <data_manager_service_name>, [required] | ||
"storage": { [required] | ||
"segment_seconds": <length_of_video_segments>, [optional] | ||
"size_gb": <total_storage_max_size>, [required] | ||
"storage_path": <custom_path_to_store_video_files>, [optional] | ||
"upload_path": <custom_path_to_upload_video_files>, [optional] | ||
}, | ||
"video": { [optional] | ||
"format": <video_format>, [optional] | ||
"codec": <video_codec>, [optional] | ||
"bitrate": <bits_pers_second>, [optional] | ||
"preset": <video_preset>, [optional] | ||
}, | ||
"cam_props": { [required] | ||
"width": <pixel_width>, [required] | ||
"height": <pixel_height>, [required] | ||
"framerate": <frames_per_second>, [required] | ||
}, | ||
}, | ||
"depends_on": [ | ||
<camera_component_name>, [required] | ||
<data_manager_service_name> [required] | ||
] | ||
} | ||
``` | ||
|
||
Make sure to configure a [Data Manager Service](https://docs.viam.com/services/data/cloud-sync/) to uplaod video files to the cloud. | ||
|
||
```json | ||
{ | ||
"name": <data_manager_service_name>, | ||
"namespace": "rdk", | ||
"type": "data_manager", | ||
"attributes": { | ||
"tags": [], | ||
"additional_sync_paths": [ | ||
<custom_path_to_upload_video_files> | ||
], | ||
"capture_disabled": true, | ||
"sync_interval_mins": <sync_interval_minutes>, | ||
"capture_dir": "" | ||
} | ||
} | ||
``` | ||
|
||
## Do Commands | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to document do commands? Is it so that someone could integrate with this module in their own app if they wanted to? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think we need to document DoCommands in the README since the module is pretty much worthless without save/fetch interface. |
||
|
||
### `save` | ||
|
||
#### Save Request | ||
```json | ||
{ | ||
"command": "save", | ||
"from": <start_timestamp>, [required] | ||
"to": <end_timestamp>, [required] | ||
"metadata": <arbitrary_metadata_string> [optional] | ||
} | ||
``` | ||
|
||
#### Save Response | ||
```json | ||
{ | ||
"command": "save", | ||
"filename": <filename_to_be_uploaded> | ||
} | ||
``` | ||
|
||
### `fetch` | ||
|
||
#### Fetch Request | ||
```json | ||
{ | ||
"command": "fetch", | ||
"from": <start_timestamp>, [required] | ||
"to": <end_timestamp> [required] | ||
} | ||
``` | ||
|
||
#### Fetch Response | ||
```json | ||
{ | ||
"command": "fetch", | ||
"video": <video_bytes> | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessarily an actionable change, but what archs are we targeting for this module? Noticing that there is amd here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scope included inux/arm64, linux/amd64, and darwin/arm64 in the meta.json we're on the hook for.