Answer the question
In order to leave comments, you need to log in
How to display the duration of an audio/video file?
Good afternoon. There is a task - to write a script that goes through all the files in the directory and displays the duration of the name, size and duration, if it is an audio or video file.
Everything except duration
local file1=$1;
for file in $file1/*
do
if [ -f "$file" ]
then
for (( i=1; i <= $count; i++ ))
do
printf "║ "
done
local filesize=$(stat -c%s "$file")
filesize=$(echo "scale=4; $filesize / 1024 / 1024" | bc)
local dateModify=$(date +"%d.%m.%Y в %H:%M" --reference="$file")
local time=$(ffmpeg -t -i $file)
printf "╠═ ${file##*/}, ${filesize} MB, изменено ${dateModify}, \t${time}\n"
fi
done
Answer the question
In order to leave comments, you need to log in
ffprobe is more convenient for this. In one project, I define the duration in a bash script into a variable like this:
local MUSIC_LENGTH=$(ffprobe \
-v quiet \
-print_format ini \
-show_format \
"$MUSIC_PCM" | grep duration | sed s/duration=//)
$MUSIC_PCM
– path to the media file.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question