我在 bash 脚本中有以下函数。当我执行它时,我总是从 ffprobe 命令获得一个返回的字符串,其中包含以下形式的错误:
Argument '-' provided as input filename, but '/media/Testing/Sorted/badfile.mp4' was already specified.
我尝试将参数移至文件名的引号内(无法解决问题)。我尝试将参数移至数组并传递“${array[@]}”(无法解决问题)。显然,我在这里忽略了一些显而易见的东西。我哪里做错了?
# ProcessVideo
#
# Takes an input file name (presumably for a video file, but the function doesn't
# actually attempt to verify that), and hands it off to ffprobe to do some basic
# processing of the video stream. We set a flag so that any error encountered will
# cause ffmpeg to exit with an error code set. If ffmpeg sets an error code, we
# log the file name to a file.
#
# ProcessVideo <path to video>
ProcessVideo()
{
local vfn=$1
local ec=0
local oput
echo "Checking video $vfn"
oput=$(ffprobe -loglevel warning "$vfn" - 2>&1)
ec=$?
# if (( ec > 0 ))
# then
# echo "Error exit $ec $vfn"
# LogErr "Error exit $ec $vfn"
# fi
# if [[ "$oput" == *"moov atom"* ]]
if [[ -n "$oput" ]]
then
echo "Error string $vfn"
LogErr "Error string $vfn"
LogErr "$oput"
fi
}
请注意,上面脚本中的 LogErr 是另一个函数 - 它所做的就是获取传递的字符串并将其写入指定的日志文件。如果有人认为这与问题相关,我会发布它,但我认为不是。