Skip to content

Serves transcoded MP4's for ChromeCast and ChromeOS

License

Notifications You must be signed in to change notification settings

maruel/serve-mp4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 install github.com/maruel/serve-mp4/cmd/...@latest
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}}" {} \;

About

Serves transcoded MP4's for ChromeCast and ChromeOS

Resources

License

Stars

Watchers

Forks

Packages

No packages published