shell – 使用mplayer来确定音频/视频文件的长度

以下功能非常好地确定各种音频/视频文件的长度:
mplayer -identify file.ogg 2>/dev/null | grep ID_LENGTH

但是,我想杀死mplayer的输出,所以我可以更有效地确定许多文件的长度.我怎么做?

MPlayer源附带一个名为midentify的示例脚本,如下所示:
#!/bin/sh
#
# This is a wrapper around the -identify functionality.
# It is supposed to escape the output properly,so it can be easily
# used in shellscripts by 'eval'ing the output of this script.
#
# Written by Tobias Diedrich <ranma+mplayer@tdiedrich.de>
# Licensed under GNU GPL.

if [ -z "$1" ]; then
        echo "Usage: midentify.sh <file> [<file> ...]"
        exit 1
fi

mplayer -vo null -ao null -frames 0 -identify "$@" 2>/dev/null |
        sed -ne '/^ID_/ {
                          s/[]()|&;<>`'"'"'\\!$" []/\\&/g;p
                        }'

-frames 0使mplayer立即退出,-vo null -ao null阻止它尝试打开任何视频或音频设备.这些选项都记录在man mplayer中.

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...