https://github.com/markkimsal/video-thumbnailer
Network enabled API endpoint for ffmpeg. Turn a video into a thumbnail.
https://github.com/markkimsal/video-thumbnailer
api docker docker-compose ffmpeg php screenshot thumbnails video video-thumbnailer
Last synced: 8 months ago
JSON representation
Network enabled API endpoint for ffmpeg. Turn a video into a thumbnail.
- Host: GitHub
- URL: https://github.com/markkimsal/video-thumbnailer
- Owner: markkimsal
- Created: 2020-05-08T17:20:57.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-04-21T13:08:47.000Z (about 4 years ago)
- Last Synced: 2025-05-06T03:59:23.123Z (about 1 year ago)
- Topics: api, docker, docker-compose, ffmpeg, php, screenshot, thumbnails, video, video-thumbnailer
- Language: PHP
- Homepage:
- Size: 1.23 MB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Video Thumbnailer
===
Deploy with `docker-compose` or however you want.
URL parameters are:
* url: The publically available video file
* s: the second into the video that the screenshot should be taken (defaults to 2)
* fmt: format of the image, either png, jpg, or jpeg (defaults to jpg)
Response
===
The response will be the binary output of the screenshot image. The image is currently not scaled.
Headers returned include:
* Content-Disposition: attachment; filename="{unique id.png}"
* Content-Type: [ image/png | image/jpeg ]
* Content-Length: [ integer num bytes ]
Example
===
Run the image
```
docker run --rm -d -p 9999:8080 markkimsal/video-thumbnailer:2.0.0
```
Test the service:
```
curl -O -J -X GET "http://127.0.0.1:9999/index.php?url=https://github.com/markkimsal/video-thumbnailer/raw/master/fixtures/ISS-live-stream-earth-from-space-2020-05-08.mp4&s=3.8"
```
This will download the file and use the header from `Content-disposition: attachment;filename=""` to save the file locally.
The filename is a ULID.
Caching
===
Public cache-control headers are sent along with an expires for 1 month. Adjust the nginx-vhost.conf file to suit your needs and rebuild with docker-compose.
Security
===
This is essentially an open proxy, so secure it with:
* firewall rules
* reverse proxy
* docker swarm networks
* k8s
You can restrict the video downloading to a list of known hosts via the `DOMAINS` environment variable.
```
#docker-compose.yml
environment:
- DOMAINS=github.com,igotaprinter.com
```
If the requested video's host does not match something in the list, it will be rejected with `'422 Unprocesible Entity'`.
Matching is done with the `host` component of php's `parse_url()` function.