Wednesday, December 13, 2017

Get the video time of all video in directory using the shell script

In this shell script we can calculate the video time of all video available in you directory or folder .

for f in *
do
echo -n "video_time = ";
DURATION="$(ffmpeg -i $f 2>&1 | grep "Duration"| cut -d ' ' -f 4 | sed s/,// | sed 's@\..*@@g' | awk '{ split($1, A, ":"); split(A[3], B, "."); print 3600*A[1] + 60*A[2] + B[1] }')";
echo "$DURATION File Name = '$f';";
done



The output for this script is :

video_time = 135 File Name = 'video1.mp4';
video_time = 122 File Name = 'video2.mp4';
video_time = 351 File Name = 'video3.mp4';
video_time = 248 File Name = 'video4.mp4';
video_time = 288 File Name = 'video5.mp4';
video_time = 361 File Name = 'video6.mp4';
video_time = 190 File Name = 'video7.mp4';
video_time = 142 File Name = 'video8.mp4';
video_time = 171 File Name = 'video9.mp4';
video_time = 166 File Name = 'video10.mp4';
video_time = 56 File Name = 'video11.mp4';
video_time = 154 File Name = 'video12.mp4';
video_time = 87 File Name = 'video13.mp4';

No comments:

Post a Comment

Featured Post

What is JavaScript? What is the role of JavaScript engine?

  The JavaScript is a Programming language that is used for converting static web pages to interactive and dynamic web pages. A JavaScript e...