Skip to content

Latest commit

 

History

History
163 lines (113 loc) · 5.25 KB

README.md

File metadata and controls

163 lines (113 loc) · 5.25 KB

Shotit-media

License Coverage GitHub Workflow Status GitHub release Docker Docker Image Size

Media broker for serving video preview for shotit

This server uses a "video scene cutter" which automatically detect timestamp boundaries of a shot, and then trim the shot out without leaking / exposing other frames that belongs to previous / next scenes.

Background of this project

When search result from shotit returns a TV & film, episode and a timecode, it can generate a video preview for the scene at that time code.

Query image:

Search result: Shelter, episode 1, timecode: 00:00:51.83

Video Preview at time 00:00:51.83

Fixed offset without shotit-media Auto detect with shotit-media
00:50.93 (-0.9) to 00:53.93 (+2.1) 00:49.22 to 00:51.30 (dynamic)

By using first / last frames from the fixed offset preview, user may be able to use that to search again and reveal previous/next scene of the original video. By repeating this process, users may eventually read the whole video until the rate limit/search quota used up.

With the video preview generated by auto detect method, searching any frame form the preview would only results the same video preview. This prevents leaking the previous/next scene.

How does it work

To be completed

Getting Started

> git clone https://github.com/shotit/shotit-media.git
>
> cd shotit-media
>
> # Copy .env.example to .env
> touch .env.example .env
>
> # Launch shotit-media server as well as its dependent services
> docker-compose up -d

Since some of the following endpoints are secured by the TRACE_API_SECRET environment variable, please put x-trace-secret in HTTP header when sending requests.

Verify status

GET http://127.0.0.1:3000/ -> OK

List files

# Need x-trace-secret header
GET http://127.0.0.1:3000/list/

Video URL

# Need x-trace-secret header
GET http://127.0.0.1:3000/file/tv_film_title/episode_number.mp4

For this URL endpoint, use HTTP Method PUT, DELETE to upload and delete files.

Video Preview URL

GET http://127.0.0.1:3000/video/tv_film_title/episode_number.mp4?t=87

You can use the &size= param to specify preview size (l: 640, m: 320, s: 160)

GET http://127.0.0.1:3000/video/tv_film_title/episode_number.mp4?t=87&size=l

You can use the &mute param to generate a muted video (like GIF)

GET http://127.0.0.1:3000/video/tv_film_title/episode_number.mp4?t=87&size=l&mute

Image Preview URL

GET http://127.0.0.1:3000/image/tv_film_title/episode_number.mp4?t=87

You can use the &size= param to specify preview size (l: 640, m: 320, s: 160)

GET http://127.0.0.1:3000/image/tv_film_title/episode_number.mp4?t=87&size=l

Environment variables

VIDEO_PATH=         # e.g. /mnt/data/imdb/
SERVER_PORT=        # e.g. 3001
SERVER_ADDR=        # e.g. 127.0.0.1 or 0.0.0.0
TRACE_MEDIA_SALT=   # define any random string, or leave blank to disable secure token
TRACE_API_SECRET=   # same as TRACE_API_SECRET in shotit-api's .env, or leave blank to disable auth(Not recommended)
AWS_BUCKET=         # e.g. shotit-media
AWS_ENDPOINT_URL=   # e.g. http://127.0.0.1:9000
AWS_REGION=         # e.g. us-east-1
AWS_ACCESS_KEY=     # e.g. minioadmin
AWS_SECRET_KEY=     # e.g. minioadmin

Local Development Guide

git clone https://github.com/shotit/shotit-media.git
cd shotit-media
yarn install

Configuration

  • Copy .env.example to .env
  • Edit .env as appropriate for your setup, as is for the first time.

Dependent Services

  • minio
  • etcd

Comment out the media service at docker-compose.yml, then:

docker-compose up -d

Start Development

You can use pm2 to run shotit-media server in background in cluster mode.

Use below commands to start / restart / stop server.

yarn start
yarn stop
yarn reload
yarn restart
yarn delete
yarn logs

To change the number of nodejs instances, edit ecosystem.config.json