serve-mp4

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2020 License: Apache-2.0

README

Serves a directory of video files as MP4 over HTTP

Goal: enable playing a local list of multilingual video files on a ChromeCast via Caddy.

ChromeCast

Requires ffmpeg/ffprobe to be installed. To install, run ./support/build-ffmpeg.sh.

By default, it will prefer French audio tracks over others.

go get -u -v github.com/maruel/serve-mp4/cmd/...
serve-mp4 -help
serve-mp4 -root /mnt/foo/bar

Then setup as a systemd service:

./setup.sh /mnt/foo/bar localhost:7999

Fronting with Caddy

Use a Caddyfile to proxy the server over HTTPS, assuming example.com points to your IP address, then disallow any external access:

example.com {
  log / /var/log/caddy/web.log "{when} {status} {remote} {method} {latency} {size} {uri} {>Referer} {>User-Agent}" {
    rotate {
      size 100 # Rotate after 100 MB
      age  120 # Keep log files for 120 days
      keep 100 # Keep at most 100 log files
    }
  }
  errors {
    log /var/log/caddy/web.err {
      size 100 # Rotate after 100 MB
      age  120 # Keep log files for 120 days
      keep 100 # Keep at most 100 log files
    }
  }

  # Only allow local network.
  ipfilter / {
    rule allow
    ip 192.168.1.1
  }

  # If you want to server a base directory.
  root /var/www/html

  # Proxy to serve-mp4.
  proxy / localhost:7999 {
    transparent
  }
}

Probing

probe-mp4 leverages text/template to allow printing data from vid.Info.

Print the duration of a video:

probe-mp4 -fmt "{{.Duration}}" foo.avi

Print the duration of every videos along codec data:

find . -type f -exec probe-mp4 -fmt "{{.Src}}: {{.Duration}} {{.VideoCodec}}/{{.AudioCodec}}/{{.AudioLang}}" {} \;

Directories

Path Synopsis
cmd
probe-mp4
prove-mp4 probes a file.
prove-mp4 probes a file.
serve-mp4
serve-mp4 serves a directory of video files over HTTP and transcodes on the fly.
serve-mp4 serves a directory of video files over HTTP and transcodes on the fly.
vid
Package vid identifies and transcodes video files via ffprobe and ffmpeg.
Package vid identifies and transcodes video files via ffprobe and ffmpeg.
ffmpeg
Package ffmpeg contains ffmpeg specific types.
Package ffmpeg contains ffmpeg specific types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL