serverlesspub / ffmpeg-aws-lambda-layer Goto Github PK
View Code? Open in Web Editor NEWFFmpeg/FFprobe AWS Lambda layer
License: Other
FFmpeg/FFprobe AWS Lambda layer
License: Other
I'm aware this doesn't have the MP3 module, but how would I be able to implement that with yours? Or would I need to start from scratch?
Currently I'm trying to convert a .webm
file using this layer on my Lambda function, but it fails when it tries to fetch the probe of my input file.
Here's the error output:
2020-07-06 16: 27: 51.363 (-03: 00) 287bc4c2-75be-42e0-a3d5-39343ccb9793 ERROR Unhandled Promise Rejection {
"errorType": "Runtime.UnhandledPromiseRejection",
"errorMessage": "Error: ffprobe exited with code 1\nffprobe version 4.2.2-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2007-2019 the FFmpeg developers\n built with gcc 8 (Debian 8.3.0-6)\n configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg\n libavutil 56. 31.100 / 56. 31.100\n libavcodec 58. 54.100 / 58. 54.100\n libavformat 58. 29.100 / 58. 29.100\n libavdevice 58. 8.100 / 58. 8.100\n libavfilter 7. 57.100 / 7. 57.100\n libswscale 5. 5.100 / 5. 5.100\n libswresample 3. 5.100 / 3. 5.100\n libpostproc 55. 5.100 / 55. 5.100\n[mpegts @ 0x7274c40] Format mpegts detected only with low score of 2, misdetection possible!\n[mpegts @ 0x7274c40] Could not detect TS packet size, defaulting to non-FEC/DVHS\n/tmp/c69847bd-9c0e-4f13-84ac-1a447939907e.webm: End of file\n",
"reason": {
"errorType": "Error",
"errorMessage": "ffprobe exited with code 1\nffprobe version 4.2.2-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2007-2019 the FFmpeg developers\n built with gcc 8 (Debian 8.3.0-6)\n configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg\n libavutil 56. 31.100 / 56. 31.100\n libavcodec 58. 54.100 / 58. 54.100\n libavformat 58. 29.100 / 58. 29.100\n libavdevice 58. 8.100 / 58. 8.100\n libavfilter 7. 57.100 / 7. 57.100\n libswscale 5. 5.100 / 5. 5.100\n libswresample 3. 5.100 / 3. 5.100\n libpostproc 55. 5.100 / 55. 5.100\n[mpegts @ 0x7274c40] Format mpegts detected only with low score of 2, misdetection possible!\n[mpegts @ 0x7274c40] Could not detect TS packet size, defaulting to non-FEC/DVHS\n/tmp/c69847bd-9c0e-4f13-84ac-1a447939907e.webm: End of file\n",
"stack": [
"Error: ffprobe exited with code 1",
"ffprobe version 4.2.2-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2007-2019 the FFmpeg developers",
" built with gcc 8 (Debian 8.3.0-6)",
" configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg",
" libavutil 56. 31.100 / 56. 31.100",
" libavcodec 58. 54.100 / 58. 54.100",
" libavformat 58. 29.100 / 58. 29.100",
" libavdevice 58. 8.100 / 58. 8.100",
" libavfilter 7. 57.100 / 7. 57.100",
" libswscale 5. 5.100 / 5. 5.100",
" libswresample 3. 5.100 / 3. 5.100",
" libpostproc 55. 5.100 / 55. 5.100",
"[mpegts @ 0x7274c40] Format mpegts detected only with low score of 2, misdetection possible!",
"[mpegts @ 0x7274c40] Could not detect TS packet size, defaulting to non-FEC/DVHS",
"/tmp/c69847bd-9c0e-4f13-84ac-1a447939907e.webm: End of file",
"",
" at ChildProcess.<anonymous> (/var/task/node_modules/fluent-ffmpeg/lib/ffprobe.js:233:22)",
" at ChildProcess.emit (events.js:198:13)",
" at ChildProcess.EventEmitter.emit (domain.js:448:20)",
" at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)"
]
},
"promise": {},
"stack": [
"Runtime.UnhandledPromiseRejection: Error: ffprobe exited with code 1",
"ffprobe version 4.2.2-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2007-2019 the FFmpeg developers",
" built with gcc 8 (Debian 8.3.0-6)",
" configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg",
" libavutil 56. 31.100 / 56. 31.100",
" libavcodec 58. 54.100 / 58. 54.100",
" libavformat 58. 29.100 / 58. 29.100",
" libavdevice 58. 8.100 / 58. 8.100",
" libavfilter 7. 57.100 / 7. 57.100",
" libswscale 5. 5.100 / 5. 5.100",
" libswresample 3. 5.100 / 3. 5.100",
" libpostproc 55. 5.100 / 55. 5.100",
"[mpegts @ 0x7274c40] Format mpegts detected only with low score of 2, misdetection possible!",
"[mpegts @ 0x7274c40] Could not detect TS packet size, defaulting to non-FEC/DVHS",
"/tmp/c69847bd-9c0e-4f13-84ac-1a447939907e.webm: End of file",
"",
" at process.on (/var/runtime/index.js:37:15)",
" at process.emit (events.js:198:13)",
" at process.EventEmitter.emit (domain.js:448:20)",
" at emitPromiseRejectionWarnings (internal/process/promises.js:140:18)",
" at process._tickCallback (internal/process/next_tick.js:69:34)"
]
}
When I run ffprobe in my machine, it works:
ffprobe "Best Camera for IGTV (9x16 vertical video examples).webm"
ffprobe version 4.2.2-1ubuntu1~16.04.york0 Copyright (c) 2007-2019 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
configuration: --prefix=/usr --extra-version='1ubuntu1~16.04.york0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, matroska,webm, from 'Best Camera for IGTV (9x16 vertical video examples).webm':
Metadata:
encoder : google/video-file
Duration: 00:01:45.44, start: 0.000000, bitrate: 3458 kb/s
Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709), 1080x1920, SAR 1:1 DAR 9:16, 23.98 fps, 23.98 tbr, 1k tbn, 1k tbc (default)
Should I make any modifications in order for this to work? Installing additional plugins maybe?
If I just need to use ffmpeg, is there any difference between deploying lambda code with ffmpeg binary and using an ffmpeg layer?
I am getting this error on a particular ffmpeg command I am calling in lambda. I have various other commands that are working fine. I have copied the exact command I use from ECS where it works fine as well. In this particular function I am using fluent-ffmpeg to concat a series of clips from a txt file. Do you have any idea why I would get this error?
I'm getting the below error
Fontconfig error: Cannot load default config file [Parsed_subtitles_0 @ 0x5c39300] No usable fontconfig configuration file found, using fallback. Fontconfig error: Cannot load default config file
I'm guessing libass
is not enabled by default, any idea on how to resolve this?
I'm trying to convert a .webm file to .mp3 running the following command within my lambda function.
os.system('/opt/bin/ffmpeg -acodec libopus -i /tmp/audioFile.{} -y -map 0 /tmp/output.mp3'.format(event['audioFormat']))
As long as the original audio file is bellow more or less 5 seconds, it gets transcoded correctly. However, if the file's longer, for some reason ffmpeg truncates it, and only convert the first seconds of the file. I've noticed that when truncating, the new file is always either 38.9, 39.4 or 39.8 KB in size.
Any Idea what might be going on???
Here are the logs:
ffmpeg version 4.1.3-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, matroska,webm, from '/tmp/audioFile.webm':
Metadata:
encoder : Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0(eng): Audio: opus, 48000 Hz, mono, s16 (default)
Stream mapping:
Stream #0:0 -> #0:0 (opus (libopus) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, mp3, to '/tmp/output.mp3':
Metadata:
TSSE : Lavf58.20.100
Stream #0:0(eng): Audio: mp3 (libmp3lame), 48000 Hz, mono, s16p (default)
Metadata:
encoder : Lavc58.35.100 libmp3lame
Truncating packet of size 669363911 to 31787
size= 40kB time=00:00:05.05 bitrate= 64.5kbits/s speed=31.9x
video:0kB audio:40kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.585012%
Hello,
I just tried to run your cli with make deploy DEPLOYMENT_BUCKET={bucket_name}
When I try to associate the layer to a fresh new Lambda, I got the following message :
Function code combined with layers exceeds the maximum allowed size of 262144000 bytes. The actual size is 349762174 bytes.
Do you have any idea of how I could handle that ?
I created a lambda function (Node.js 10.x) and in the AWS web console added the following layer:
arn:aws:lambda:us-east-1:145266761615:layer:ffmpeg:4
When I try to save, I get the error :
"You are not authorized to perform: lambda:GetLayerVersion."
Is this layer made to be used from any AWS account?
What do I need to do to allow this function to use the layer?
The ffmpeg layer is currently limited to the following runtimes:
It is therefore not possible to use it with other runtimes like dotnetcore*
or python3.8
. Would it be possible to include more runtimes or remove the runtimes limitation? Since the binaries included in the layer are self contained, I guess that it could run in any runtime.
Hi Gojko et al,
I think you have the license wrong for this project. You've listed GPLv2, however you say you build on Johan Van Sickle's work and he states that he builds his ffmpeg binaries as GPLv3 packages.
I think your LICENSE file should note this.
AWS is deprecating the nodejs.10 runtime.
Will this lambda layer keep working for lambda functions with nodejs.12 runtimes?
I tried to use this layer and I added it to my function, but when I check if there exists about file /opt/ffmpeg/ffmpeg, I got not exists. may I have to do anything else except to add layer to my lambda function?
python 3.6 is end of life. To continue supporting python, support for more recent versions should be added.
I am using this layer on one lambda function absolutely fine. But no matter what I try if I setup another lambda function with the exact same layers attached (my node_modules and this layer) it fails silently on any call. It just completely ignores the fluent-ffmpeg functions as if they are not there. I am completely baffled. I can see ffmpeg and ffprobe are there using fs readDirSync. I have tried deploying it as a second application so it gets a new arn and it still fails with 0 errors. Can anyone help me?
I am trying to just do a hello world test with this layer. I deployed to my account successfully and am attempting to use the layer in a python3.6 runtime.
I know this might not be appropriate for this forum but could you point me in the right direction for how to call the binary?
Your layer is used v4.1.3 that is fewer old, can you create a new layer with the newest ffmpeg static version?
For the project I'm working on, I'm mainly just taking mp4s recorded by users in a web browser and trying to transcode them to be manageable sizes as well as playable in all device/browser combos. I was using AWS MediaConvert for this but later found out that mobile Safari records video in a "fragmented" mp4 which is not supported by MediaConvert so I'm turning to replacing MC with an ffmpeg layer.
I've deployed the ffmpeg lambda layer from the SAR and copied most of the code from the example but for some reason all the output videos are significantly sped up. When I run the same commands with my local ffmpeg, everything works fine. Any help is appreciated!
export const onVideoUpload: Handler = Sentry.AWSLambda.wrapHandler(async (event: S3Event, context: Context) => {
const EXTENSION = '.mp4',
MIME_TYPE = 'video/mp4';
const eventRecord = event.Records && event.Records[0],
inputBucket = eventRecord.s3.bucket.name,
key = eventRecord.s3.object.key,
id = context.awsRequestId,
resultKey = key.replace(/\.[^.]+$/, EXTENSION),
workdir = os.tmpdir(),
inputFile = path.join(workdir, id + path.extname(key)),
outputFile = path.join(workdir, 'out_' + id + EXTENSION);
console.log('converting', inputBucket, key, 'using', inputFile);
// ffmpeg -i 2254.webm -c copy output.webm
// ffmpeg -i input.mp4 -b:v 1M -b:a 192k output.avi
return downloadFileFromS3(inputBucket, key, inputFile)
.then(() => childProcess(
'/opt/bin/ffmpeg',
['-i', inputFile, '-b:v', '1M', '-b:a', '192k', '-nostdin', outputFile],
{env: process.env, cwd: workdir}
))
.then(() => uploadFileToS3(process.env['DestinationBucket']!, resultKey, outputFile, MIME_TYPE));
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.