Edit MP4 Header Information In Its Binary

Sac Ko
Sac Ko used Ask the Experts™
on
I have a small MP4 file of duration 10 seconds, less than 1MB. I am able to open the file in HexEdit to view its binary source. But I am not able to figure out where does its header information is in this binary file.
What I basically want to do is change the duration of this MP4 to say like 20 seconds. I know its a read only attribute and thats the reason why I am trying to edit its binary data to update the duration.
Please see attached ffprobe screenshot and screenshot of MP4 file when opened in binary format in HexEdit editor.
mp4-hexedit.png
ffprobe.png
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
MerijnBSr. Software Engineer

Commented:
Now I don't know the mp4 header structure, but there is quite a big change the length is not in there. Often length is calculated from the combination of bit rate an number of bytes in the actual data.

Your question begs a counter question though :p

What are you trying to achieve by this? Even if the length is somewhere in the header, what do you think you accomplish by make it longer?

Author

Commented:
MerijnB -  I basically want to fool the browser into believing that video received from the server is of a longer duration. So if the actual duration is 10 seconds I want the browser to believe its of (say) 20 seconds. Its just an experiment I am trying out checking if it is doable or not. My ultimate goal is to have server send a short video of duration 10 seconds every 10 seconds. The first video will have a long duration so that the browser will assume its just the first video its playing. The reason I am trying to do this is because when I play different videos after every 10 seconds I am getting a small lag/delay between playing of two videos. I want to eliminate this delay.
Sr. Software Engineer
Commented:
Sac Ko - again, without realy experience with this my feeling is that it will be very hard to achieve this, in this particular way. Even if you will be able to manipulate the length in the header (if it is in the header in the first place), you can expect uncontrolled results by the player who is handling this stream.

I think the better way to solve this is on the client side, see if you can hook in there, or make your own video player which knows the format you stream and takes that into account, or don't sent separate videos, but sent it as a stream, so the server is aware of the separate video's, but delivers it to the client as one single stream.

Good luck! :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial