2

I need MP3 file consiting of literally 2 (two) complete frames @ 44100/16 bit/stereo, without any metadata. The issue here is that I need to be able to create it myself as cutting 2 frames from larger file will cause artifacts in my decoder processing.

I tried the following

  • windows sound recorder - can record only up to 24 kHz, I need 44100, my decoder can not handle it;
  • VLC seems not understanding such small files - I tried to feed 0.02 second WAV file to it, and it refuses to convert (generates output file of size of 0);
  • there's an application called FFMPEG, I have it on PC, but can not make it working, too complicated for me. Not sure if it can take fractional input for -t key though.

I am sure those who deal with electronic music can help me. Thank you in advance.

Update: my question really seems to be offtopic here, and DSP (digital signal processing) is not about music, but about technology, however I was hoping that musicians use technology and must know how analog and digital works relating to making a sound.

I found out that I, most probably, need more than 2 frames to fill 2048 bytes of decoder's buffer for decoder to start processing. The main issue I am solving that decoder does not have option to reset (zero) its intermediate buffers, and the only way to reset them is to push several frames of silence through them.

Thus it is just down to the understanding MP3 format, and I even will not need frames, I will need algorithm how to construct data within the frame so that they would decode to all zeros (silence).

3
  • 1
    maybe a different stack for what you are looking for? stackoverflow.com/questions/39734057/… Commented Oct 15, 2017 at 20:21
  • @AlphonsoBalvenie thank you, I saw this question, but for specific reason decided to post question here to get more options from music technologists. I not only needed to insert silence, I must have understood how to create it myself. I know how to do it now without any utility.
    – Anonymous
    Commented Oct 16, 2017 at 21:53
  • There used to be a program called MP3DirectCut that allowed you to do some operations directly on mp3 files without re-encoding. ... seems to be still around en.wikipedia.org/wiki/Mp3DirectCut Commented Sep 18, 2019 at 21:36

4 Answers 4

8

This question may not be on topic here, but in Audacity if you create a new (empty) project and then go to Generate > Silence... you can generate whatever length of silence you want in units of seconds, samples, frames and more.

Then go to File > Export audio, and choose MP3.

1
  • Sound file creating using the above method still has some background noise. I want to create an absolute silent mp3. Commented Aug 13, 2021 at 11:57
5

Just to be sure others will be able to find solution to this question. Silent MP3 frame consists of the header, side info and data comprised of just one type of byte. Here're two headers - first to be used for the first frame, and second for all subsequent frames:

Header (including side info) of the first frame

FF FB 90 64-00 0F F0 00-00 69 00 00-00 08 00 00
0D 20 00 00-01 00 00 01-A4 00 00 00-20 00 00 34
80 00 00 04

Header (including side info) of following frames

FF FB 90 64-40 8F F0 00-00 69 00 00-00 08 00 00
0D 20 00 00-01 00 00 01-A4 00 00 00-20 00 00 34
80 00 00 04

Size of data following the header and side info is 381 bytes, and consists of 381 copies of byte 'U' (0x55). It decodes to all zeros using respective Huffman table. Thus in total frame size is 417 bytes. Each frame (to my understanding) will decode into 1152 16-bit stereo samples, performing at 44100 Hz (thus lasts for ~26.122 ms).

3
  • For some reason audacity does not show second frame: If only the first frame is used, it is shown with correct duration. If two frames are used, the same duration (~26.122 ms) is used, and if N frames are used (N>2), total duration is 26.122*(N-1). What may be the cause of this? Where can one find the description of this headers byte-by-byte? Commented Jan 17, 2018 at 6:52
  • There're a number of websites showing this information, but the best explanation I found is this one mp3-tech.org/programmer/docs/mp3_theory.pdf. I suspect it uses N-1 frames dropping last frame, thinking that 26 ms is not actually much audible and does not affect quality of listening. Why? this is good question to the developers of the Audacity. Could be feature or bug :)
    – Anonymous
    Commented Jan 17, 2018 at 7:55
  • 1
    The 0x55 are there because hardware prefers to have a number such as 0x55 or 0xAA rather than 0x00. The code you show result in a size of 0 bytes for the data, which means no data (or more precisely, all zeroes, which is the default). Commented Sep 18, 2019 at 20:54
3

To complement and answer your question about why 1 frame of data doesn't work, I wanted to add that the MP3 format (and most certainly many others) require training the compressor. For that reason a library such as LAME will add some silence at the beginning.

Similarly, to get the last bit of data, it adds yet more silence at the end of the stream. This is usually the job of the Flush() function. In some situations, when you can't call the Flush() function, you have to provide the silence yourself. (i.e. when creating a live feed or running with multiple threads.)

Also for those interested in doing a silencing of an existing frame, you can do so by setting all the side info values to zero like so:

FF FB 90 64-00 00 00 00-00 00 00 00-00 00 00 00
00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00
00 00 00 00

WARNING: The size of the side info varies depending on the version (MPEG-1 or not) and whether you have single channel or not.

This is how the Info or Xing tag are defined and if a player doesn't recognize the tag, it will just add an extra ~26ms of silence.

You can actually void the Info or Xing by replacing these character by U or some other value. These would appear right after the header and side info bytes:

FF FB 90 64-00 00 00 00-00 00 00 00-00 00 00 00
00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00
00 00 00 00-55 55 55 55

Info would be 49 6E 66 6F and Xing would be 58 69 6E 67. This method allows you to edit an MP3 file in place without having to move all the content which can be huge or while streaming.

3

Learned that when concatenating silent wav file with other music wav files, the channels, sample rate, etc. have to be compatible. A simple way to do this with ffmpeg is to simply copy an existing music wav file and turn the volume to 0. Command line example of a 4 second silent file is as follows:

ffmpeg -i existing_music_file.wav -t 4 -filter:a "volume=0.0001" silent.wav

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.