Check if the audio file is valid as MP3 in the shell

I am writing a Bash Shell Script that should determine if the provided MP3 Audio file is valid or invalid. How to do it in Bash?

e.g. fake: > file.mp3ormv file.txt file.mp3

+4
source share
1 answer

It depends on how confident you are.

Just check the extension: You can easily check only the extension of the file provided in Bash with

if [ ${file: -4} == ".mp3" ]

Which essentially takes the last four characters of the string fileand claims to be equal.mp3

: , . Mime- file Bash. , , Mime-Type.

, , . , , . , Bash Script.

: FFMpeg FFProbe . , FFProbe, . , script , .

+6

Source: https://habr.com/ru/post/1584626/


All Articles