如何在ffprobe中省略JSON输出中的错误消息



在使用ffprobe获取流详细信息时,出现Input buffer exhausted before END element found错误。ffprobe提供了请求的信息,但错误包含在输出中,并创建了无效的JSON。

ffprobe -loglevel error -select_streams v:0 -show_entries stream=width,height:stream_tags=rotate -of json testVideo.mp4
{
[aac @ 0x7fc06201cc00] Input buffer exhausted before END element found
"programs": [
],
"streams": [
{
"width": 640,
"height": 640,
"tags": {
}
}
]
}

使用ffprobe时,如何防止JSON输出中出现错误消息?

这是视频链接测试video.mp4

重定向stderr

JSON输出到stdout。错误将输出到stderr。两者都打印在控制台输出中。您可以重定向stderr输出,这样它就不会包含在控制台输出中。

ffprobe -select_streams v:0 -show_entries stream=width,height:stream_tags=rotate -of json testVideo.mp4 2> error.log

忽略错误

此错误不会阻止您获取请求的数据,因此您可以忽略它。请使用-loglevel quiet/-v quiet使错误静音,以防止它们包含在输出中。

ffprobe -loglevel quiet -select_streams v:0 -show_entries stream=width,height:stream_tags=rotate -of json testVideo.mp4

与重定向相比,缺点是您可能会错过重要的错误。

最新更新