- Newest
- Most votes
- Most comments
The issue with the ffprobe command not working is likely due to network restrictions on Lambda. By default, Lambda functions cannot make outbound connections to the internet.
Use the --allowed-extensions AV
option when creating the Lambda layer to enable AV extensions which provide broader network access needed for ffprobe to connect to the remote URL.
Host the video file you want to probe on S3 instead of a remote URL and pass the S3 path to ffprobe instead. This avoids the network restriction.
Use the Lambda Layer with FFmpeg you referenced earlier to wrap the ffprobe command. Some layers are configured to allow broader network access needed for commands like ffprobe to work with remote files.
As an alternative, you could convert the remote video to a local file within your function first using ffmpeg before passing to ffprobe.
Please capture error, run this code.
import { promisify } from 'util'; import { exec } from 'child_process';
const commander = promisify(exec);
export const handler = async (event) => { try { const command = '/opt/ffmpeg/ffprobe -i "https://dwzxneeggli32.cloudfront.net/ad1.mp4" -show_entries format=duration -v quiet -of csv="p=0"'; const { stdout, stderr } = await commander(command); return { statusCode: 200, body: JSON.stringify({ output: stdout }), }; } catch (error) { console.error('Error executing ffprobe:', error); return { statusCode: 500, body: JSON.stringify({ error: error.message, stderr: error.stderr }), }; } };
Relevant content
- asked 4 years ago
- asked a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 4 months ago