jlayer increasing size of file when convert .mp3 file to .wav file - jlayer

I am using jlayer to convert mp3 file to wav format. The code is working good but the size of wav file is increased about 5 times the size of mp3 file. For converting i have used the jar file provided by the jlayer.
Anyone please tell how to optimize the size of the file.

You cannot optimize the size of a WAV file, its size depends on the audio data written into it. The higher the quality of audio, the larger the file. The longer the length of audio, the larger the file.
WAV files contain PCM encoded digital audio. The reason we use MP3 and other audio encoding formats is to reduce the file size, in exchange of quality.
So when you convert a file from WAV to MP3, you get a smaller file but you lose audio quality.
If you convert the resulting file from MP3 to WAV (which is what you do), you always get a larger file and you never get back to the original audio quality.

Related

Is it possible to write mp3 files from `tuneR::Wave` object in R?

mp3 to WAV is easy by monitoR::readMP3 and tuneR::writeWave. What about Wave object to mp3?
I have done some audio splitting with R tuneR::Wave objects, and want to output them as mp3 files. I don't need the resolution as in WAV file which takes up a lot of unnecessary space.

Qt: Saving an image in intended compression format

I am using Qt and saving a image file out of a QML UI item. Following is what I do
auto screenshot = quick_item->grabToImage();
screenshot->saveToFile("/somepath/filename.jpeg");
// OR sometimes use like png like
screenshot->saveToFile("/somepath/filename.png");
This is works fantastically well on all platforms. I open the file the image is saved as intended.
Now my question is:
I just mentioned .jpeg as file extension while providing the filename as param into saveToFile. This works but, should I need to use QImageWriter to ensure that the image is actually compressed in jpeg/png format ?
What happens when it is a lossy compression like jpeg?
How to control a lossy compression if I want to like in android I can do a image.compress(CompressFormat.JPEG, 80, stream) where 80 is the percentage of quality for Compress ?
You can't do that directly from QQuickItemGrabResult, you have to use QImage::save() for that :
auto screenshot = quick_item->grabToImage();
auto image = screenshot->image();
image.save("/somepath/filename.jpeg", nullptr, 80);
The second parameter of save is the format, but it can be left null and then be guessed based on the filename extension, the third one is the compression quality.
The quality factor has no effect if you use a lossless format like png. You can set it at -1 (the default value), omit the parameter or use a factor that you would use for lossy format.
EDIT: as pointed by #Arsenal, the quality factor maps to compression levels for lossless formats (those that support it). For example in PNG, quality 0 maps to PNG compression level 9 (smallest file size) and 100 to PNG compression level 0 (biggest file size). The default quality for PNG in Qt is 50, mapping to a PNG compression level of 4.

Read a .cdb file into R very slow

I have .cdb files in binary format in sizes of ~630M.
I use read.cdb(file, type='cdb') from library cdb to read them in but it takes for ever to load. (20 min+)
Is this normal for a large file like this?

Is there any java API to play aoudio from an WAV file

I have extracted the data chunk from an WAV file which I want to play in java. The data is in a byte array. Is there any java API that could do this. Also I have sample rate of the file from the from format chunk.

Decompress header of swf file (possible with qUncompress?)

I have some swf files generated with Adobe Flash.
Does anybody know how can I decompress their headers in QT?
I need their size (width and height) , frame rate and frame count.
Thanks
It's not documented if qUncompress requires that all compressed data to be in the QByteArray to decompress it. From the wording of it, it seems to imply that. I would imagine loading some large SWF into memory just to get a few bytes in the header is not practical.
If you can live with loading the whole file into memory, just load the file starting at offset 4 into a QByteArray and flip the byte order of the 1st 4 (SWF is little-endian and qUncompress requires the length to be in big-endian). Subtract 4 from the flipped 32-bit integer. Then call qUncompress.
If loading the whole file is not ideal, you may be better off use the stream functions in zlib directly. That allows you to decompress data piece by piece.

Resources