-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
更新videolen.sh文件:新增数个批量计算视频文件时长的辅助函数;新增_videolen.sh:作为子shell调用计算单个视频文件…
…的时长,供外部批量函数来调用。
- Loading branch information
Showing
2 changed files
with
249 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
#通过ffmpeg/ffprobe查看视频文件时长,单位为秒 | ||
|
||
:<<EOF | ||
ffprobe获取视频时长,单位:秒 | ||
ffprobe -i some_video -show_entries format=duration -v quiet -of csv="p=0" | ||
ffprobe -i input.file -show_format | grep duration | ||
ffprobe -i input.file -show_format -v quiet | sed -n 's/duration=//p' | ||
ffmpeg -i file.mp4 2>&1 | grep Duration | sed 's/Duration: \(.*\), start/\1/g | ||
ffmpeg -i file.mp4 2>&1 | grep Duration | awk '{print $2}' | tr -d , | ||
EOF | ||
|
||
file="$1" | ||
|
||
if [ ! -f "$file" ]; | ||
then | ||
echo "文件 \"$file\" 不存在!" | ||
exit 1 | ||
else | ||
inputFile=$(cygpath -am "$file") | ||
#echo $inputFile | ||
fi | ||
|
||
#下面这个方式输出浮点数,以秒为单位:eg:6678.744000 | ||
IFS=$(echo -e "\n") PATH="/v/mediadeps/ffmpeg/bin:/v/mediadeps/rtmpdump:$PATH" ffprobe -i "$inputFile" -show_entries format=duration -v quiet -of csv="p=0" | ||
#IFS=$(echo -e "\n") PATH="/v/mediadeps/ffmpeg/bin:/v/mediadeps/rtmpdump:$PATH" ffprobe -i $inputFile -show_entries format=duration | ||
|
||
#下面的方式,输出为人类可读的时间格式:eg:01:51:18.74 | ||
#IFS=$(echo -e "\n") PATH="/v/mediadeps/ffmpeg/bin:/v/mediadeps/rtmpdump:$PATH" ffmpeg -i "$inputFile" 2>&1 | grep Duration | awk '{print $2}' | tr -d , |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters