Here is my simple using refering above.
mp3_full_path="$HOME/i/want/the/length/of/file.mp3"
ffmpeg -i "$mp3_full_path" 2>&1 | grep Duration | awk -F ' ' '{print $2}' | awk -F '[,|.]' '{print $1}'
10:47:15
I send that value to variable mp3_full_length
mp3_full_path="$HOME/i/want/the/length/of/file.mp3"
read -r mp3_full_length <<< `ffmpeg -i "$mp3_full_path" 2>&1 | grep Duration | awk -F ' ' '{print $2}' | awk -F '[,|.]' '{print $1}'`
# I can use this variable for my own purpose!
echo $mp3_full_length
10:47:15
Thank you above people! I use your ideas and knowledges
Thank you for reading, Have a nice day! ;)
Best answer as it works even with Average or Variable Bitrate MP3! – KrisWebDev – 2016-01-03T22:25:38.363
1Add
\n
to print new line also.> mp3info -p "%S\n" sample.mp3
// total time in seconds – nexayq – 2017-04-16T12:13:18.497yeah, there's no way to get length info in ffmpeg. I already stated there, I use ffmpeg only after I get the length. Anyway, thanks for the heads UP. – ariefbayu – 2009-10-31T03:59:05.467
4Worth noting that this only provides the length as an Integer. So may not be accurate enough for some use cases. – Ross – 2013-05-06T11:30:11.560