我使用以下命令将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.log和progress.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?
发布于 2019-06-12 04:00:04
您的日志将转到当前工作目录。您需要单独上传这些文件。既然我们对日志感兴趣,我想您可能也想做一些错误检查。如果没有,只需删除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.loghttps://stackoverflow.com/questions/56550629
复制相似问题