How does file conversion work?

53 views
0

How do programs convert a file from one format to another?

The answer probably extremely varied so I’m sorry if im asking too broad a question.

​

Converting an file from OGG, which i honestly didnt really know existed, into MP3 takes seconds, but somehow in that time it changes the data around, and now it’s in MP3 format my editing program can use it.
There’s got to be more going on than just changing the suffix!

​

How does this work?

In: 1

For the most part, a filetype is just an instruction on how to read a file. A .txt file and .csv file have little to tell them apart from each other, for example, but they are usually used by different programs.

Of course, it’s a little more complicated than that for most filetypes, since the data in the file needs to be in a specific format for the given/assumed instructions to work. A jpg file, for example, will have a different way of reconstructing an image than a bmp file.

But overall, the principle is the same. Read the file using extension 1’s protocol, “understand” it (depends on image/voice/etc.) rewrite it using extension 2’s protocol. How long that takes depends on the two types and file size.

Files are, at their core just 1s and 0s. Each set of 8 make up a byte which is represented by a 2 character hexadecimal number, 00-FF.

Files consist generally of 2 things, header information which contain a hex code defining its file type known as the magic bytes.

Most of the other data is specific for that file.

There are two types of file converts, one reads the file, converts it to its base values and then rewrites it in the new language.

Think like you speak 3 languages, french, german, and english. In the first method you convert French to english and then the english to german.

The other type of convert is basically the converter knows how to translate directly from French to german so it runs it through just swapping data 1 for 1 without caring about what the data is.

The exact process is different for every conversion, but you can think of it as translation. If you have a paragraph of text, you’ll read it in its original language A, extract its meaning, and then re-write it in language B. It’s the same message, represented differently so speakers of language B can work with it now.

Similarly, .ogg is one way to represent sound, and .mp3 is another. I don’t actually know the technical details of either file format, but ultimately they’re just instructions for a computer to produce music, formatted differently. If you do know those details, then you can translate one format into the other.

The sentences “Yesterday I ate a banana” and “ontem comi uma banana” both convey exactly the same information but some people understand both sentences, some people only understand one and some people understand neither.

File formats are like languages for computer programs. MP3 is like the English of music. Everyone speaks it but there’s some things that are much easier to convey in a different language, so for some specific applications other languages are used instead.

You can also use units of measurement in the analogy. You can make the plans for a house using metric or imperial, but if the house is going to be built on the us you’re better off changing all the measurements to imperial.

Audio and video formats are too complex to ELI5, but using .xlsx and .csv as an example, they are in fact a .zip and a .txt file respectively (just change their extensions and you’ll see you can open them normally). That’s one of the reasons why with xlsx you can use images (the image just goes inside the zip) but with csv you can not. So when converting from xlsx to csv one of the things that is going on behind the scenes is the zip file is being extracted, the images, text formatting, formulas, multiple sheets, and a million other things are being stripped off and just the raw data is being stored on a txt file.

None of these answers are ELI5 enough for me.

#**ELI5**

You see a lovely actress in a news article. And you write her a love letter.

You speak English. You wrote it in English.

But little did you know, that actress only speaks Spanish!

So when she gets the love letter, she can’t understand it.

So she asks her friend who speaks both languages, and he translates the letter into Spanish.

So now there are two love letters, one in English, one in Spanish, but both say the same thing.

**Some people only speak Spanish.**
That’s all they were taught.
**Some people only speak English.**
That’s all they were taught.

**Some audio players/editors only understand OGG.**
That’s all it was programmed to do.
**Some audio players/editors only understand MP3.**
That’s all it was programmed to do.

The actress’s friend knows both English and Spanish, and can convert between the two.

A File Conversion Program knows both MP3 and OGG, and can convert between the two.