你好我有以下poc要开发
给定两个 S3 路径,起点和终点,我需要从起点下载应用转换并上传到目标。
如果您知道的话,我们的想法是不使用临时本地文件夹并使用流数据作为另一个更好的选择。
为了做到这一点,我有以下代码:
import ffmpeg
import boto3
from io import BytesIO
origin = 'ah/a.mkv'
destination = 'av/a.mp4'
s3_client = boto3.client('s3')
f = BytesIO()
s3_client.download_fileobj('bucket', origin, f)
stream = ffmpeg.input(f)
stream = ffmpeg.output(stream, 'a.mp4', codec='copy')
(stream.run())
问题是输入没有这个库看起来这个操作是不可能的。
https://kkroening.github.io/ffmpeg-python/
TypeError: expected str, bytes or os.PathLike object, not _io.BytesIO
但是当另一个图书馆喜欢
https://github.com/aminyazdanpanah/python-ffmpeg-video-streaming#opening-a-resource
我也不知道怎么转换。
那么你知道有什么方法吗?
谢谢
最佳答案
最后,图书馆与
s3_client = boto3.client('s3')
f = BytesIO()
s3_client.download_fileobj('bucket', 'path', f)
process = (
ffmpeg
.input('pipe:') \
.output('aa.mp4') \
.overwrite_output() \
.run_async(pipe_stdin=True) \
)
process.communicate(input=f.getbuffer())
合作。
关于python - 使用 BytesIO 进入 python-ffmpeg 或其他,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72100457/