以下工作非常好地确定各种音频/视频文件的长度:
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# Licensed under GNU GPL. if [ -z "$1" ]; then echo "Usage: midentify.sh [ ...]" 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
.
FFMPEG可以以不同的格式提供相同的信息(并且不会尝试播放文件):
ffmpeg -i