I recorded 13 hours of audio to a wav file (48kHz sampling rate) with the Android App "AudioRec". The file is ~4,2G in size.
I then transfered the file to my gentoo linux and tried to open it with ffmpeg, vlc, mpv and audacity, sox. In all applications the file has a length of exactly 35 minutes.
If I open the file in audacity with Import->Rawdata it indeed reads the whole file as 13 hours sound file. But if I export the file again with same format settings (48kHz,mono,pcm_s16le) to wav still no application is able to read it with 13 hours lenght... So I guess I have to split the file in 34:59 minutes chunks to use them (my intention was to feed the 13 hours to sox to create a spectrogram)...
Is there anyone who has an explanation why there is this 35 minutes restriction?
I maybe found the answer myself:
Well, there is no way to do this right. RIFF/WAVE only uses 32 bits to
store lengths, so anything >4 GiB won't fit. This is comparable to a
paper form that asks for your age, but only offerss two places for the
digits; if you're 102 years old, you might write "02" or "99", but you
can't specify your true age.
https://sourceforge.net/p/sox/bugs/213/#2fc6
https://en.wikipedia.org/wiki/WAV#Limitations
Related
I have multiple videos of same resolution. Each video has a different length. And I also have a fixed length for output file. Let's say 4 minutes. Let's assume there are 4 input files each of 30 seconds but each input file could have different length. I want to put first 30 secs of output file blank and the next 30 secs as 1st input file and next 10 secs as blank and next 30 secs as 2nd input file so on. Basically I have a predetermined start point for each input file and between the gaps there should be black screen. How can I achieve this ? ffmpeg commands are fine but I'm going to have to automate this in nodejs so if you can give me any tips on it that'd be great!
There doesn't seem to be a single ffmpeg command to do this so I had to split the problem into a smaller problems.
First I generated a list of video segments that are going to a part of the final output video. Now some of these segments are already present and some are to be a black video.
So I used an ffmpeg command to generate a black video with silent audio with the desired length. So now I have all the segments I need and it's just a matter of combining them one after another.
I was given an uncompressed .wav audio file (360 mb) which seems to be broken. The file was recorded using a small usb recorder (I don't have more information about the recorder at this moment). It was unreadable by any player and I've tried GSpot (https://www.headbands.com/gspot/) to detect whether it was perhaps of a different format than wav but to no avail. The file is big, which hints at it being in some uncompressed format. It misses the RIFF-WAVE characters at the start of the file though, which can be an indication this is some other format or perhaps (more likely in this case) the header is missing.
I've tried converting the bytes of the file directly to audio and this creates a VERY noisy audio file, though voices could be made out and I was able to determine the sample rate was probably 22050hz (given a sample size of 8-bits) and a file length of about 4 hours and 45 minutes. Running it through some filters in Audition resulted in a file that was understandable in some places, but still way too noisy in others.
Next I tried running the data through some java code that produces an image out of the bytes, and it showed me lots of noise, but also 3 byte separations every 1024 bytes. First a byte close to either 0 or 255 (but not 100%), then a byte representing a number distributed somewhere around 25 (but with some variation), and then a 00000000 (always, 100%). The first 'chunk header' (as I suppose these are) is located at 513 bytes into the file, again close to a 2-power, like the chunk size. Seems a bit too perfect for coincidence, so I'm mentioning it as it could be important. https://imgur.com/a/sgZ0JFS, the first image shows a 1024x1024 image showing the first 1mb of the file (row-wise) and the second image shows the distribution of the 3 'chunk header' bytes.
Next to these headers, the file also has areas that clearly show structure, almost wave-like structures. I suppose this is the actual audio I'm after, but it's riddled with noise: https://imgur.com/a/sgZ0JFS, third image, showing a region of the file with audio structures.
I also created a histogram for the entire file (ignoring the 3-byte 'chunk headers'): https://imgur.com/a/sgZ0JFS, fourth image. I've flipped the lower half of the range as I think audio data should be centered around some mean value, but correct me if I'm wrong. Maybe the non-symmetric nature of the histogram has something to do with signed/unsigned data or two's-complement. Perhaps the data representation is in 8-bit floats or something similar, I don't know.
I've ran into a wall now. I have no idea what else I can try. Is there anyone out there that sees something I missed. Perhaps someone can give me some pointers what else to try. I would really like to extract the audio data out of this file, as it contains some important information.
Sorry for the bother. I've been able to track down the owner of the voice recorder and had him record me a minute of audio with it and send me that file. I was able to determine the audio was IMA 4-bit ADPCM encoded, 16-bit audio at 48000hz. Looking at the structure of the file I realized simple placing the header of the good file in front of the data of the bad file should be possible, and lo and behold I had a working file again :)
I'm still very much interested how that ADPCM works and if I can write my own decoder, but that's for another day when I'm strolling on wikipedia again. Have a great day everyone!
I'm searching on a method that can help me creating an audio file (of known length) composed by mixing some audio chunks at specific time position.
For example:
I want to create song.wav with duration of 5 minutes, composed by:
- chunk1.wav (time 0:02)
- chunk3.wav (time 0.50)
- chunk2.wav (time 1:20)
I think I can create 5 minutes of silence then mixing the wave files but I don't know how.
I try SOX but no solution found yet
I'd like also FFMPEG based solution
This is a question about the file format of MP3s.
I've been hunting for a way to get an MP3 duration. Since I'm using JLayer SPI to decode the MP3 I've discovered that this is possible where the audio source is a file.
AudioFileFormat fileFormat = AudioSystem.getAudioFileFormat(source);
Long microseconds = (Long) fileFormat.properties().get("duration");
System.out.println(microseconds);
However when I take the similar code and the very same MP3 and change the source to a URL, JLayer does not provide the duration:
AudioFileFormat fileFormat = AudioSystem.getAudioFileFormat(source.toURI().toURL());
Long microseconds = (Long) fileFormat.properties().get("duration");
System.out.println(microseconds);
This is an important distinction because some of the music I want to play will be sourced from URLs not local files.
I suspect that this is due to limitations of the file format.
This leads me to a very simple question. Is it possible to know the duration of an MP3 before the entire file has been downloaded?
The answer is no. The mp3 file format doesn't have any information regarding the duration of the file. To compute the duration you would need to divide the length of the file by the bit rate. That would also explain the behavior of your library. As a workaround, if you have control of the files on the server you should be able to embed the duration in an id3 tag.
Yes, for CBR (Constant Bit Rate), you need to download chunk for about 1-2 MBytes* (must be larger than id3 size below)
In the header you normally could find whole file length:
Content-Length: 30079584
next step would be to obtain Audio Bitrate and ID3 Size from this chunk (with exiftool - link)
For example:
...
Audio Bitrate: 272 kbps
ID3 Size : 115419
...
And then just use this formula (example):
(30079584 - 115419) / (272 * 1000 / 8)
~ 881 seconds
where '* 1000 / 8' - is a kbit-to-bytes conversion (https://en.wikipedia.org/wiki/Bit_rate)
I'm currently working on some multi-channel audio recording software. The basic goal is to be able to record every input device on a computer. I noticed that when I record for a "long" time (more than 1 hour), the different mp3 files (which represent the different input devices) have the same length (and bitrate settings), but the filesize is not the same (although it's not a huge difference, about 10 KB at most). I would expect that the files must have the exact same size, though I'm not 100% sure of it. Are there any audio experts here on Stack Overflow with some advice?
How do you measure the length of files? 10KB of filesize difference at the bitrate of 320kbps is about one quarter of a second, so it is the expected behavior if your length measurements have the precision of 1 second.