Skip to content
This repository has been archived by the owner on May 29, 2023. It is now read-only.

yoursunny/NDNts-video-server

Repository files navigation

NDNts Adaptive Video Server

This repository is deprecated in favor of NDNts-video/server.


NDNts adaptive video server is the server component for NDNts Adaptive Video web application. This project is built with NDNts, Named Data Networking libraries for the modern web.

NDNts logo

Installation

You should install this program in an unprivileged account.

  1. Install Node.js 18.x:

    # see https://github.com/nvm-sh/nvm
    nvm install 18
  2. Clone this repository.

  3. Install local dependencies:

    corepack pnpm install
  4. Generate a key and obtain a certificate for prefix registration.

    • You may use @ndn/keychain-cli package.
    • The signing key should be stored in a NDNts KeyChain, not in ndn-cxx KeyChain.
    • Enter KeyChain location and certificate name in .env.
  5. Install FFmpeg and Shaka Packager (only needed for encoding):

    sudo apt install ffmpeg
    curl -fsfL https://github.com/google/shaka-packager/releases/download/v2.6.1/packager-linux-x64 | \
      sudo install /dev/stdin /usr/local/bin/shaka-packager

    Alternatively, you can specify USE_DOCKER=1 environ when invoking encode.sh script to use Docker images of these programs. You can additionally specify DOCKER_LIMITS="--cpus 0.5 --memory 512MB" environ to set CPU and RAM limits.

Usage

VIDEO_FILE=$HOME/sample.mp4
VIDEO_TEMP=/tmp/video-sample
VIDEO_PREFIX=/yoursunny/video/sample

# encode, package, and prepare a local video as DataTape
nice ./encode.sh $VIDEO_FILE $VIDEO_TEMP vp9
corepack pnpm -s start prepare --prefix $VIDEO_PREFIX --path $VIDEO_TEMP > video.dtar

# import packets from DataTape
corepack pnpm -s start import < video.dtar

# list stored packets
corepack pnpm -s start list --prefix $PREFIX

# export packets to DataTape
corepack pnpm -s start export --prefix $PREFIX > video.dtar

# delete packets by prefix
corepack pnpm -s start delete --prefix $PREFIX

# start the producer
# modify .env REPO_PREFIXES to include prefixes of imported packets
corepack pnpm -s start serve

You can run the producer as a service using pm2. A sample ecosystem.config.js is provided.

NDNts repo is based on LevelDB, which is non-thread-safe. Thus, you can only run one command at a time, and you must stop the producer before running other commands.