Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.
/ trace.moe-media Public archive

Media server for serving video preview for trace.moe

License

Notifications You must be signed in to change notification settings

soruly/trace.moe-media

Repository files navigation

trace.moe-media

License Discord

Media server for serving video preview for trace.moe

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.

This media server is now integrated into trace.moe-api. This is no longer needed for serving media preview.

Background of this project

When search result from trace.moe returns an anime, 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 trace.moe-media Auto detect with trace.moe-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

docker run -it --rm -v /path/to/video/=/mnt/ -p 3000:3000 ghcr.io/soruly/trace.moe-media:latest

List files

http://127.0.0.1:3000/list/

Video URL

http://127.0.0.1:3000/file/foo/bar.mp4

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

To secure this endpoint, define the TRACE_API_SECRET environment variable, and put x-trace-secret in HTTP header when sending requests.

Video Preview URL

http://127.0.0.1:3000/video/foo/bar.mp4?t=87

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

http://127.0.0.1:3000/video/foo/bar.mp4?t=87&size=l

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

http://127.0.0.1:3000/video/foo/bar.mp4?t=87&size=l&mute

Image Preview URL

http://127.0.0.1:3000/image/foo/bar.mp4?t=87

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

http://127.0.0.1:3000/image/foo/bar.mp4?t=87&size=l

Environment variables

VIDEO_PATH=         # e.g. /mnt/data/anilist/
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 trace.moe api's .env, or leave blank to disable auth

Local Development

Git clone this repository, npm install, copy .env.example to .env, Edit .env as you need, then start server

node server.js

You also can use pm2 to run this in background in cluster mode.

Use below commands to start / restart / stop server.

npm run start
npm run stop
npm run reload
npm run restart
npm run delete

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