user17601: I came across this joke mp4 file online. (Warning: direct download link to an 8 mb file.) Media players as well as ffmpeg both list the file as having a length of 596523:14:07.00 (!). My first guess was that the video might have used a very low frame rate, but ffmpeg lists a frame rate of 10 fps, with no frames having a variable frame rate. What is going on in the encoding of this file to give it such a long length?

user4943: There are several things we can note here:

The file stops playing after 0:05:30.
If you remux the file (mkvtools for example) you do have 5:30 displayed as the length.
The original file does in fact show the ridiculous length.

So, although it is a funny joke, it is not as cool as I first thought. Nobody has figured out how to do an infinite loop of frames or anything similar to that. This appears to be just a header of the file that is not matching the data.
How does the player (or most tools) figure out the length of the video? They do not read the whole file, otherwise the load times of files would be impractical. So at the start of the file there is a marker that says the length, and the player just trusts it.
Let's run through the maths:
596523:14:07.00 = ((596523*60)+14)*60+7 = 2147483647 seconds
2147483647 (base 10) = 7FFFFFFF (base 16)

Oh, that's a nice number. Now let's open the file up with a hex editor, right at the start we see
 00000000:  00 00 00 18 66 74 79 70  6d 70 34 32 00 00 00 00  ....ftypmp42....
 00000010:  6d 70 34 32 6d 70 34 31  00 01 69 7b 6d 6f 6f 76  mp42mp41..i{moov
 00000020:  00 00 00 6c 6d 76 68 64  00 00 00 00 dd 69 a6 fb  ...lmvhd.....i..
 00000030:  dd 69 a6 fb 00 00 00 01  7f ff ff ff 00 01 00 00  .i..............

There's our culprit, right at the 0x38 mark. Let's edit it and see what happens. I actually get a funnier "joke" if I change 7f to ff at the start. To understand why it works, please see How the negative numbers are stored in memory?.

17601: <p>I came across <a href="https://cdn.discordapp.com/attachments/642256326826786826/888362096075620362/top29quintillioncheese.mp4" rel="noreferrer">this joke mp4</a> file online. (Warning: direct download link to an 8 mb file.) Media players as well as ffmpeg both list the file as having a length of 596523:14:07.00 (!). My first guess was that the video might have used a very low frame rate, but ffmpeg lists a frame rate of 10 fps, with no frames having a variable frame rate. What is going on in the encoding of this file to give it such a long length?</p>
 4943: <p>There are several things we can note here:</p>
<ol>
<li>The file stops playing after 0:05:30.</li>
<li>If you remux the file (mkvtools for example) you do have 5:30 displayed as the length.</li>
<li>The original file does in fact show the ridiculous length.</li>
</ol>
<p>So, although it is a funny joke, it is not as cool as I first thought. Nobody has figured out how to do an infinite loop of frames or anything similar to that. This appears to be just a header of the file that is not matching the data.</p>
<p>How does the player (or most tools) figure out the length of the video? They do not read the whole file, otherwise the load times of files would be impractical. So at the start of the file there is a marker that says the length, and the player just trusts it.</p>
<p>Let's run through the maths:</p>
<pre><code>596523:14:07.00 = ((596523*60)+14)*60+7 = 2147483647 seconds
2147483647 (base 10) = 7FFFFFFF (base 16)
</code></pre>
<p>Oh, that's a nice number. Now let's open the file up with a hex editor, right at the start we see</p>
<pre><code> 00000000:  00 00 00 18 66 74 79 70  6d 70 34 32 00 00 00 00  ....ftypmp42....
 00000010:  6d 70 34 32 6d 70 34 31  00 01 69 7b 6d 6f 6f 76  mp42mp41..i{moov
 00000020:  00 00 00 6c 6d 76 68 64  00 00 00 00 dd 69 a6 fb  ...lmvhd.....i..
 00000030:  dd 69 a6 fb 00 00 00 01  7f ff ff ff 00 01 00 00  .i..............
</code></pre>
<p>There's our culprit, right at the 0x38 mark. Let's edit it and see what happens. I actually get a funnier &quot;joke&quot; if I change 7f to ff at the start. To understand why it works, please see <a href="https://www.geeksforgeeks.org/how-the-negative-numbers-are-stored-in-memory/" rel="noreferrer">How the negative numbers are stored in memory?</a>.</p>
