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).

  • 1
    maybe a different stack for what you are looking for? stackoverflow.com/questions/39734057/… – Alphonso Balvenie Oct 15 '17 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 Oct 16 '17 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 – piiperi Sep 18 at 21:36
5

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.

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).

  • 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? – Igor Liferenko Jan 17 '18 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 Jan 17 '18 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). – Alexis Wilke Sep 18 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.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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