📜 ⬆️ ⬇️

January 1, 1904, 1970, Youtube, international conflict and crooked hands

Unfortunately, the topic links have long disappeared, but sometimes extremely interesting things come first hand. I recommend the post of Anatoly Vorobei (he works as a developer in Google).

In the MP4 video format (MPEG-4 standard), it is possible to record the “creation time” of any data stream using a special tag. The value of this label in the standard: the number of seconds elapsed since January 1, 1904, or the so-called “time in the Mac era”, because poppies were the first to use such a countdown. Meanwhile, in modern servers it is much easier to deal with the “time according to the Unix era”, namely the number of seconds since January 1, 1970. As a result, in a variety of programs that run on Linux or other Unix operating systems, there is a piece of code that looks like this:

What is the constant "the difference between the Unix time and the Mac time"? It is exactly equal to the number of seconds elapsed between January 1, 1904 and January 1, 1970. These are 66 years old, of which 17 were leap years (check if you don’t trust me). Total days it turns out: 66 * 365 + 17 = 24,107, and seconds, considering 86,400 seconds per day: 24,107 * 86,400 = 2,082,844,800. This is the correct value of the constant.

But there is a little tiny imperceptible problem. Part of the MPEG-4 standard is the source code for libraries that can read and write mp4 files, so C ++ reference software that everyone can use to borrow or compare with their code. The full title of this part of the standard is ISO / IEC 14496-5. If you're interested, you can download this part of the standard for free from the official site. And if you look at the source code, you will see that another value of this constant is used there, namely 2,082,758,400. This is exactly 86,400 seconds, that is, one day less than the correct value.

How did it happen that the creators of MPEG-4 miscalculated the difference between the two dates? Maybe someone manually considered leap years and was wrong? I do not know. Anyway, the wrong value due to its presence in the standard fell into many libraries for reading and writing video formats. Gradually, in recent years, the correct value begins to replace it; If you search both numbers in Google, you will see several exact descriptions of the problem in the source code of several projects: "The standard suggests using 2,082,758,400, but the correct value is 2,082,844,800." In other projects, the correct value is simply because they themselves considered it based on the definitions of eras, and did not use the source code from the standard.
')
If the wrong value is recorded in the library that creates the MP4 file for you, then what happens when it wants to record the time "now"? It will take the correct number of seconds for Unix, add a constant a day less than necessary, and thereby get the number of seconds, according to the Macintosh era, which corresponds to the time a day earlier. I sent a description of the problem and the solution to the developers of Yutyube, and I hope that this bug will soon disappear.

Everything in this world is interconnected. The curved hands of the authors of the MPEG-4 standard lead to conspiracy theories in the Ukrainian conflict. That's how we live.

Source: https://habr.com/ru/post/230571/


All Articles