-
Notifications
You must be signed in to change notification settings - Fork 65
Running Thumbd on Heroku
Deploying and running Thumbd on Heroku is simple, however, currently in its stock form, video thumbnailing fails due to an internal ImageMagick error. To get video thumbnailing working on Heroku, you need to use custom buildpack to have an external ffmpeg
binary. The guide below would cover the basics of deploying on Heroku as well as setting up custom buildpack.
- Start by creating a new app and setting following env variables that are required by Thumbd
AWS_KEY: [your aws key]
AWS_REGION: [aws region]
AWS_SECRET: [aws secret]
BUCKET: [bucket name]
SQS_QUEUE: [sqs queue name]
Note that for SQS_QUEUE
you only need to set the actual queue name without any numeric prefix.
- Set the following env variable required for using multiple buildpacks
BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
- Create a file
.buildpacks
in the project root with following content
https://github.com/shunjikonishi/heroku-buildpack-ffmpeg
https://github.com/heroku/heroku-buildpack-nodejs.git
When deploying, Heroku will fetch the buildpacks configured in .buildpacks
file and have it available to the app.
- Now you can use 'custom' strategy in Thumbd to specify
ffmpeg
conversion command to generate video thumbnail. Here is an example command that you can specify instrategy
field in the thumbnailing request to Thumbd
"ffmpeg -itsoffset -0 -i %(localPaths[0])s -vcodec mjpeg -vframes 1 -y -filter:v crop=%(width)s:%(height)s %(convertedPath)s"
An example request for video thumbnailing should look something like this:
{
"original": "/path/to/object/video1.mp4",
"prefix": "/path/to/object/video1",
"descriptions": [
{
"suffix": "medium",
"width": 150,
"height": 150,
"strategy": "ffmpeg -itsoffset -0 -i %(localPaths[0])s -vcodec mjpeg -vframes 1 -y -filter:v crop=%(width)s:%(height)s %(convertedPath)s"
}
]
}
Note that this solution requires the client to check for the media type of the object beforehand to identify if its a video and use custom strategy as above. Images can still use other standard Thumbd strategies.