Using other external libraries or binaries is possible with Lambda, however you will be limited by the max size of a Lambda function.
One way to achieve what you want, without using libav (as libav doesn't statically link very well), is to compile ffmpeg with static enabled and then shared disabled. You will need to compile and build this binary or any other dependencies on an Amazon Linux machine first.
./configure --enable-static --disable-shared
Once you've compiled ffmpeg, you can run a make, then copy the compiled ffmpeg binary into your Lambda function.
At this point you can use something like the following to generate thumbnails from your videos, or transcode.
process.env['PATH'] = process.env['PATH'] + ':' + process.env['LAMBDA_TASK_ROOT']
var ffmpeg = require('ffmpeg')
exports.ffmpeg = function(event, context) {
new ffmpeg('./thumb.MP4', function (err, video) {
if (!err) {
video.fnExtractFrameToJPG('/tmp', {
every_n_frames: 20,
file_name : 'image_frame_%t_%s'
}, function (error, files) {
if (!error)
console.log('Frames: ' + files);
context.done();
});
} else {
console.log('Error: ' + err);
}
});
}
The important part of this is to make sure you add the task root path to your environment path, so that the ffmpeg NodeJS module can locate the binary. You could also install the fluent-ffmpeg NodeJS module and take advantage of the FFMPEG_PATH environment variable as well.
As for other Native Libraries, like OpenCV. You can try to statically compile all dependencies, and then when you run an NPM install of the Module in question, it will build the Native Module using the statically linked libraries. This removes any dynamic dependency requirements for the modules. However keep in mind that not all Modules will statically link, and not all dependencies will compile statically.
To recap, when compiling any binaries or dependencies, make sure you are doing so on an Amazon Linux machine and then copy the requirements to your Lambda Function.