4

Is there a way to make my mp4 file seem to have a longer or shorter duration than it actually has? I tried playing around with an Hex Editor, but being a noob i couldn't make it work.

2 Answers2

4

So, after looking through the documentation (thanks slhck for the pointer), I found the exact part you're looking for.

Five 4-bytes after the "mvhd" atom (6D 76 68 64 in hex) is the duration in time units. The 4 bytes before that are the time scale. The total time, in seconds, is the duration/time scale. This doesn't seem to change the actual length of the video when played, but changes the duration that is reported when viewed.

mvhd is circled in red, time scale in black, and duration is highlighted:

mvhd is circled in red, time scale in black, and duration is highlighted.

MarianD
  • 2,726
2

Props to Mr. Doom for his answer, and I would like to slightly improve on it. I am doing this in separate answer and not in comments under his reply because my rating is not high enough to leave a comment, but my findings could be useful to some.

I have encountered similar task as OP with after my recording made with VLC acted strange. The advertised length of video (length shown in player) was 40 minutes, while data was for around 5 hours of playtime. I knew that by the fact that video size was too big for its playtime. If the video was opened in VLC player at the end of timeline it would simply keep playing beyond stated playtime. So the issue was in corrupted video metadata.

The problem with the answer of Mr doom is that I have changed duration to FF FF FF FF, but all i was able to achieve is around 1 hour and 11 minutes of playtime. From that on I needed to decrease time scale (4 dex numbers before duration) number in order to get a lengthier playtime. Changing it in HxD however didn't yield any consistent results. Long story short I found a problem to be in me messing up with endianness. Editor default was little, while this one needed a big endian mode. After changing that I was able to set up correct Int64 number and scale total playtime back and forth. It has solved a problem, now I am able to see the complete playback in timeline.

Also Mr. Doon link documentation is slightly off. He talks about mvhd atom, while link points to mdhd. The corrected link to docs is here.