python - 如何在 lambda python 中正确运行 ffmpeg 命令
问题描述
此代码在 lambda 中无法正常运行。我应该先从s3下载资源吗?然后在 ffmpeg 中调用它?或者直接s3调用是可能的?我得到的错误是
{“errorMessage”:“调用 HeadObject 操作时发生错误(404):未找到”,“errorType”:“ClientError”,
“stackTrace”:[“文件”/var/task/lambda_function.py”,第 18 行, 在 lambda_handler\n
s3_client.download_file('sourceff1-ffmpeg.s3.amazonaws.com', 'list.txt', '/tmp/list.txt')\n", "文件"/var/runtime/boto3/s3/inject.py ",第 171 行,在 download_file\n 中返回 transfer.download_file(\n"," 文件 "/var/runtime/boto3/s3/transfer.py",第 307 行,在 download_file\n future.result()\n" , " 文件 "/var/runtime/s3transfer/futures.py", 第 106 行, 结果\n 返回 self._coordinator.result()\n", " 文件 "/var/runtime/s3transfer/futures.py",第 265 行,结果\n 引发 self._exception\n"," 文件 "/var/runtime/s3transfer/tasks.py",第 255 行,在 _main\n self._submit(transfer_future=transfer_future, **kwargs)\ n","文件"/var/runtime/s3transfer/download.py",第 340 行,在 _submit\n 响应 = client.head_object(\n", " 文件 "/var/runtime/botocore/client.py", 第 386 行,在 _api_call\n 中返回 self._make_api_call(operation_name, kwargs)\n", "文件“/var/runtime/botocore/client.py”,第 705 行,在 _make_api_call\n raise error_class(parsed_response, operation_name)\n" ] }
import json
import os
import subprocess
import shlex
import boto3
import subprocess
S3_DESTINATION_BUCKET = "ugc-destination-bucket-ff1"
def lambda_handler(event, context):
s3_client = boto3.client('s3')
S3_DESTINATION_BUCKET = "ugc-destination-bucket-ff1"
s3_destination_filename="output77.mp4"
s3_client.download_file('sourceff1-ffmpeg.s3.amazonaws.com', 'list.txt', '/tmp/list.txt')
s3_client.download_file('sourceff1-ffmpeg.s3.amazonaws.com', '2.mp4', '/tmp/2.mp4')
s3_client.download_file("sourceff1-ffmpeg.s3.amazonaws.com", "list.txt", "/tmp/list.txt")
ffmpeg_cmd = "/opt/bin/ffmpeg -f concat -safe 0 -i sourceff1-ffmpeg.s3.amazonaws.com/list.txt -c copy /tmp/output.mp4"
command1 = shlex.split(ffmpeg_cmd)
return {
'statusCode': 200,
'body': json.dumps('Processing complete successfully')
}
解决方案
推荐阅读
- python-3.x - Snakefile 中的多个命名输入
- c - 如果我有一个 f = 50,000 的浮点数,然后我执行 f*f,返回的值是否为负数?
- python - count() 是计算对象数量的最有效方法吗?
- python - 如何让 python 3.7 打印出彩色文本?
- javascript - 如何替换一个前 15 个字符的字母?
- php - 转换字符串但将字符包裹在大括号中
- c# - 异步代码似乎仅在插入断点时才有效
- fullcalendar - 以角度 6 刷新 PrimeNG 计划中的事件
- database - 如何为具有用户进度的游戏设计数据库
- netsuite - 源状态记录到子列表字段