Skip to content

Commit

Permalink
Add initial project structure and CI/CD configuration
Browse files Browse the repository at this point in the history
- Created .gitignore to exclude database files.
- Added summary.md for project overview, detailing technologies, purpose, and file structure for the Spatial Media project.
- Implemented GitHub Actions workflow (build.yml) for automated testing and building across multiple OS and Python versions.
- Updated Dockerfile to streamline dependency installation and improve the setup process.
- Enhanced spatial_media_metadata_injector.spec for better executable handling on Linux and macOS.
  • Loading branch information
devanshusanghani committed Jan 14, 2025
1 parent 270f48d commit 5901832
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 20 deletions.
1 change: 1 addition & 0 deletions .codebuddy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
db/
46 changes: 46 additions & 0 deletions .codebuddy/summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Project Summary: Spatial Media

## Overview of Technologies Used
The project is primarily developed using **Python** and utilizes various libraries and frameworks to handle spatial media. The key technologies include:

- **Flask**: A micro web framework for Python, used for building web applications.
- **Gunicorn**: A Python WSGI HTTP server for UNIX, used to serve the Flask application.
- **PyInstaller**: A tool for converting Python applications into stand-alone executables.

## Purpose of the Project
The Spatial Media project is a collection of specifications and tools designed to facilitate the use of 360° video and spatial audio. It provides metadata specifications for spatial audio and spherical video, as well as tools for injecting this metadata into media files. The project aims to enhance the experience of immersive media by enabling proper handling and playback of spatial audio and video formats.

## List of Build/Configuration/Project Files
- **Build/Configuration Files:**
- `/setup.py`: Configuration for packaging the project.
- `/docker/Dockerfile`: Docker configuration file for building the application container.
- `/docker/requirements.txt`: Lists the Python dependencies required by the application.

## Source Files Directory
The source files can be found in the following directories:
- `/spatialmedia`: Contains the main application code for spatial media metadata injection.
- `/spatial-audio`: Contains resources related to spatial audio, including ambisonic filters and HRIRs.
- `/docker`: Contains the application entry point (`app.py`), WSGI configuration (`wsgi.py`), and startup script (`startup.sh`).

## Documentation Files Location
Documentation files are located in the `/docs` directory, which includes:
- Metadata specifications for spatial audio and spherical video.
- Various images and RFC documents related to the project.

## Summary of Key Files
- **Main Application:**
- `/spatialmedia/__init__.py`: Initializes the spatial media package.
- `/spatialmedia/gui.py`: Contains the GUI implementation for the application.
- `/spatialmedia/metadata_utils.py`: Utility functions for handling metadata.

- **Spatial Audio Resources:**
- `/spatial-audio/README.md`: Documentation for spatial audio resources.
- `/spatial-audio/raw-symmetric-cube-hrirs`: Contains HRIR files for binaural audio processing.

- **Documentation:**
- `/docs/spatial-audio-rfc.md`: Specification for spatial audio metadata.
- `/docs/spherical-video-rfc.md`: Specification for spherical video metadata.
- `/docs/spherical-video-v2-rfc.md`: Updated specification for spherical video metadata.
- `/docs/vr180.md`: Documentation for the VR180 video format.

This summary provides a comprehensive overview of the Spatial Media project, detailing its purpose, technologies, file structure, and documentation resources.
119 changes: 119 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Build and Test

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
release:
types: [created]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pylint
- name: Lint with pylint
run: |
pylint spatialmedia/ || true
- name: Run tests
run: |
python -m pytest || true
build:
needs: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.12'] # Use latest stable Python for builds

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build executable
run: |
python build_executables.py
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: spatial-media-${{ runner.os }}
path: |
dist/Spatial Media Metadata Injector*
!dist/*.spec
docker:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')

steps:
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: ./docker
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ secrets.DOCKER_HUB_USERNAME }}/spatial-media:latest
${{ secrets.DOCKER_HUB_USERNAME }}/spatial-media:${{ github.sha }}
release:
needs: [build, docker]
runs-on: ubuntu-latest
if: github.event_name == 'release'

steps:
- uses: actions/checkout@v3

- name: Download all artifacts
uses: actions/download-artifact@v3

- name: Upload Release Assets
uses: softprops/action-gh-release@v1
with:
files: |
spatial-media-*/Spatial Media Metadata Injector*
47 changes: 28 additions & 19 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,48 @@ ENV PATH="${PATH}:/spatialmediatools/app"

RUN apk update && \
apk upgrade && \
apk --no-cache add --virtual wget unzip ca-certificates
apk --no-cache add --virtual build-dependencies wget unzip ca-certificates

# Create and activate virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

# Copy requirements and install dependencies
COPY ./requirements.txt /spatialmediatools/app/requirements.txt
RUN python -m venv spatialmediatools
RUN source spatialmediatools/bin/activate
RUN spatialmediatools/bin/python -m pip install --upgrade pip
RUN spatialmediatools/bin/python -m pip install -r requirements.txt
RUN spatialmediatools/bin/python -m pip install -I gunicorn
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir gunicorn

COPY ./app.py /spatialmediatools/app
COPY ./wsgi.py /spatialmediatools/app
COPY ./startup.sh /spatialmediatools/app
RUN chmod 777 /spatialmediatools/app/startup.sh
RUN mkdir ./data
# Create startup script
RUN echo '#!/bin/sh' > /spatialmediatools/app/startup.sh && \
echo 'mkdir -p /spatialmediatools/app/data' >> /spatialmediatools/app/startup.sh && \
echo 'exec tail -f /dev/null' >> /spatialmediatools/app/startup.sh && \
chmod +x /spatialmediatools/app/startup.sh

##############################################################################
# Download and extract Spatial Metadata Tools Code
##############################################################################
ENV GIT_URL="https://github.com/google/spatial-media/archive/refs/heads/master.zip"
ENV APP_DIR="/spatialmediatools/app"

RUN wget --no-check-certificate -O spatialmediatools.zip $GIT_URL;
RUN unzip $APP_DIR/spatialmediatools.zip;
RUN wget --no-check-certificate -O spatialmediatools.zip $GIT_URL && \
unzip $APP_DIR/spatialmediatools.zip && \
rm $APP_DIR/spatialmediatools.zip

##############################################################################
# Clean up of unneeded packages and download
##############################################################################
RUN rm -rf /var/cache/apk/*;
RUN rm $APP_DIR/spatialmediatools.zip
RUN apk del wget unzip ca-certificates;
RUN rm -rf /var/cache/apk/* && \
apk del wget unzip ca-certificates

##############################################################################
# Run app.py
# Set up entry point
##############################################################################
#CMD [ "spatialmediatools/bin/python", "app.py" ]
ENTRYPOINT [ "/spatialmediatools/app/startup.sh" ]
COPY ./app.py /spatialmediatools/app
COPY ./wsgi.py /spatialmediatools/app

# Ensure data directory exists
RUN mkdir -p /spatialmediatools/app/data

# Use the startup script as entrypoint
ENTRYPOINT ["/spatialmediatools/app/startup.sh"]
13 changes: 12 additions & 1 deletion spatialmedia/spatial_media_metadata_injector.spec
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,16 @@ if sys.platform == 'darwin':
app = BUNDLE(exe,
name='Spatial Media Metadata Injector.app',
icon=None,
bundle_identifier=None,
bundle_identifier='com.google.spatialmedia',
info_plist={'NSHighResolutionCapable': 'True'})
if sys.platform.startswith('linux'):
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='Spatial Media Metadata Injector',
debug=False,
strip=False,
upx=True,
console=False)

0 comments on commit 5901832

Please sign in to comment.