bitstream details of wav, mp3 file - file

I would like to know about the meaning of each byte in a wav / mp3 files.
But find nth from google...anyone knows where i can find such information?
(Infact I would like to know all types of multimedia files in the bitstream level)

MP3 files are divided into frames, each begins with a sequence of FRAMESYNC bits so hardware can find the beginning of each frame. More here.
Some info about WAV is here.

Related

What is the difference between .bin and .dat file?

When writing to a binary file, when should I use .bin vs .dat? If I'm just trying to store information not meant to be read by humans, like item description/serial number pair, does it matter which one I pick if I'm just trying to make it unreadable from a text editor?
Let me give you some brief details about these files :
.BIN File : The BIN file type is primarily associated with 'Binary File'. Binary files are used for a wide variety of content and can be associated with a great many different programs. In general, a .BIN file will look like garbage when viewed in a file editor.
.DAT File : The DAT file type is primarily associated with 'Data'. Can be just about anything: text, graphic, or general binary data. Data file in special format or ASCII.
Reference:
Abhijit Banerjee answered that question on quora
.dat is a more frequently used suffix for binary data. It doesn't matter what extension you pick, as long as you are on Unix or Linux based systems.
Sufixes can mean whatever you want them to mean... Those rules are more like guidelines than actual rules...
However, BIN seems like a short to binary, so a BIN file will likely hold data in binary form. DAT seems like a short to data, so a DAT file will contain information in whatever format the developer of the program that reads that file seems fit (ASCII, Binary, a mix of them, something else entirely)
On a UNIX system, there is no difference. The extensions are interchangeable.
If you do not put any extension, it makes it kinda hard for someone not knowing what the file's extension should be, to open the file. Additionally, with Unix or Linux, if you place a dot (period) before the file name, the file hides itself.

Load wave into array + Subtract channels + Save as wave/mp3

I have a raw stereo audio file.
It is part of a noise cancellation system on the raspberry pi, Microphone 1 records the main voice to the left channel, Microphone 2 the surrounding noises to the right channel. Goal is to subtract the right channel from the left channel. I am going to write what I tried but I don't want you to stick to it and meddle with it if another way is much easier.
Recording takes place using a modified http://freedesktop.org/software/pulseaudio/doxygen/parec-simple_8c-example.html version. I output it to the raw audio file, which is a valid raw file. Advantage of stereo is that they are in sync. See my other question on How to find the right RAW format.
To summarize: How do I
Load a wave file into an array? ( I am asking this because in my other question the wave format never seems right)
Subtract the right channel from the left channel? (I presume sample_left minus sample_right)
Save it as raw or even better mp3 mono. ( I could pipe to lame )
If you are3 giving raw audio file as input or reading raw audio samples from audio device file, You can do following
1.Open raw audio file in binary format and read raw data in to a buffer,if you are using a file to give raw audio data. (or) Read Raw audio samples from audio device fire in to a buffer.
2.We know that Right audio channel is always followed by left audio channel in stereo audio format. So you can simply separate left and right audio channels. For example, if your device is giving 16-bit pcm pulses, that means, first 16-bits are left channel and next 16-bits are right channel.
3.You can simply open a normal binary file and you can make it as a wav file by defining wav header at the stating of the file. Define a wav header and write audio data in to wav file.
For wav file references see here

SDL_Mixer set sound position

I was wondering if there is a functionality in the SDL_Mixer lib to skip to a certain position in a wav file. I've found out the there is a function called Mix_SetMusicPosition but it won't work with .wav files and it won't let you choose a channel.
Any suggestions would be greatly appreciated.
EDIT:
I figured out how to do it. Instead of calling an additional function I just changed the start pointer of the abuf variable located in Mix_Chunk structure. I calculated how many bytes are in a second in a 16 bit .wav file playing at 44khz and changed the starting pointer of abuf with that number times how many seconds I want to skip. And then changed the length of alen, also a variable located in the Mix_Chunk struct, with the same number of bytes.
I just read the docs for SDL Music and apparently Mix_SetMusicPosition only supports OGG, MP3 and MOD files.
Link: http://jcatki.no-ip.org:8080/SDL_mixer/SDL_mixer_65.html#SEC65
Obvious solution; convert your wav. files to your favorite previously mentioned file format.

Save video encoded by libavcodec to an AVI file format

I am able to encode video frames using libavcodec, by calling avcodec_encode_video function. How do I save these encoded frames into an AVI file?
Check this out:
http://forum.doom9.org/archive/index.php/t-112286.html
You must open file for binary write, write header in it, and simultaniosly put binary frames in it, I think.

jpg file transfer using a socket_stream in C

I was wondering if sending a file with a jpg extension through a socket_stream, this automatically makes the transformation of bytes to jpg ? or need to implement some algorithm to transform the lot of bytes to image... Please could somebody explain me the way to do?
JPEG images are nothing but a bunch of bytes organized according to the JPEG format. A network socket isn't going to organize random bytes into the JPEG format. You can send the bytes that make up a JPEG formatted image across a socket as a binary blob, receive it on the other end, and write it to a file with a .jpg extension. An application can interpret this file as a JPEG image based on the extension and try to display it. But you are still responsible for providing a set of bytes that are organized as a JPEG image.

Resources