微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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中.

原文地址:https://www.jb51.cc/bash/383724.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐