gpt4 book ai didi

bash - 如何使用 FFMPEG 将输出和日志文件通过管道传输到 S3

转载 作者:行者123 更新时间:2023-12-04 22:50:17 25 4
gpt4 key购买 nike

我使用以下方法将我的 FFMPEG 输出直接从我的 EC2 保存到 S3:

ffmpeg -i ${input} -f mp4 -movflags frag_keyframe+faststart -hide_banner -y pipe:1 | aws s3 cp - s3://my-bucket/video/output.mp4
-

效果很好,但我想添加我的 ffmpeg.logprogress.log像这样:
ffmpeg -i ${input} -f mp4 -movflags frag_keyframe+faststart -hide_banner -y -progress progress.log pipe:1 | aws s3 cp - s3://my-bucket/video/output.mp4 &> ffmpeg.log
-

但添加日志会引发错误并将日志保存在我的 EC2 上。我敢肯定它甚至不接近我所需要的。我也尝试添加多个管道,但没有任何乐趣。

如何使用 ffmpeg 将我的日志文件与我的输出文件一起添加到 S3?

最佳答案

您的日志将转到当前工作目录。您需要单独上传这些。由于我们对日志感兴趣,我想你可能也想做一些错误检查。如果没有,只需删除 if [...] 之间的内容和 fi .

#!/bin/bash
# This will report an error from ffmpeg to $? in the pipeline.
set -o pipefail

ffmpeg -i ${input} -f mp4 -movflags frag_keyframe+faststart -hide_banner -y pipe:1 2> progress.log | \
aws s3 cp - s3://my-bucket/video/output.mp4 2> ffmpeg.log
if [ $? -ne 0 ]; then
echo "Failed to build /upload output.mp4"
# Do anything else on error here...
fi

aws s3 cp progress.log s3://my-bucket/video/progress.log
if [ $? -ne 0 ]; then
echo "Failed to upload progress.log"
fi

aws s3 cp ffmpeg.log s3://my-bucket/video/ffmpeg.log
if [ $? -ne 0 ]; then
echo "Failed to upload ffmpeg.log"
fi

您还可以将日志与 {...} 合并为一个。 .像这样:
{
ffmpeg -i ${input} -f mp4 -movflags frag_keyframe+faststart -hide_banner -y pipe:1 | \
aws s3 cp - s3://my-bucket/video/output.mp4
} 2> ffmpeg.log

关于bash - 如何使用 FFMPEG 将输出和日志文件通过管道传输到 S3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56550629/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com