Pregunta

I need to find a silence in a mp3 file. Simple as that.

For example:

  • Find a silence GREATER than X seconds in "file.mp3", then send an errorcode 0 if X seconds of silence found, or errorcode 1 if not found the silence.

I can try it in Batch, VBS, Ruby or Python (Cause I have all to practice, but I only know Batch). I have no idea of music libs and that things...

No matter if I need 3rd party software to do that job like CommandLine APPS...

Note: The silence can be in the middle of the mp3 file too. For example in the files called "Hidden tracks" that is: 1 song + 1 large silence of minutes + another song (All in only 1 mp3 file) So I need something to search X selince into the entire file, Not only near the end of the file...

Note 2: I need to do it in Windows.

Any ideas please?

¿Fue útil?

Solución

use sox and it's silence filter

checking output of sox $infile -n stat and sox $infile -n silence 1 0.1 1% -1 0.1 1% stat and comparing the lengths of original and trimmed file should do the trick

Otros consejos

Do this:

  • decode mp3 with some mp3 decoding library, you will get PCM out of it.
  • PCM data is one short after another, which means 16 bit signed numbers
  • you will have to find consecutive amount of shorts which are smaller in absolute to a some small value, say 100 (range is 32767)
  • length of the number of shorts is determined by: your desired silence duration, number of channels in the file, frequency of the sampling
  • if you have this number of shorts that are smaller, you have your silence.

Please use comments to add questions to the areas that you need more information with, or add new questions for that, since there are many steps to the task and I guess that all of them will make this one question too specific.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top