Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Any help would be greatly appreciated. Thanks..!!

See binary source in HexEdit screenshot[^]

See ffprobe output[^]
Posted
Updated 5-Jun-15 19:27pm
v3
Comments
Sergey Alexandrovich Kryukov 5-Jun-15 15:09pm    
Sorry for not answering the question, but you are not asking about something certain. There is not "just" MP4 file. Surprised? Instead, there a two levels: media container of some type, which houses one, two or more muxed streams in it, and each stream type uses its own standard the codecs work with. "MPEG4" is actually an umbrella term covering a whole family of standards, but stream standards not containers. And different container standards support only some subset of available standards for the streams (codecs). As I know, presently only Matroska, sometimes referred to as the "king of containers" support them all in all combinations.
—SA

1 solution

Please see my comment to the question, where I already tried to explain to you the essence of things. Due to the complicated character of the problem, I certainly cannot give you the whole solution; I only can tell you what to start with: you have to start with finding out what you are dealing with. "MP4" does not tell anything certain on what it is.

But this step is pretty easy. The best tool to find is FFmpeg or libavcodec utility. More exactly, this is one of the provided utilities: ffProbe.exe. There is analogous utility based on libav build. Please see:
http://en.wikipedia.org/wiki/Ffmpeg[^],
http://ffmpeg.org/[^],
http://en.wikipedia.org/wiki/Libavcodec[^],
http://libav.org/[^].

Media Player Classic (for Windows, a must-have player, in my opinion) also copes with this problem pretty well:
http://en.wikipedia.org/wiki/Media_Player_Classic[^],
http://mpc-hc.org/[^].

After you find out what is it, you will need to find out the documentation of the file format of the respective container, and then the documentation on the streams used, as well as and muxing. And only then you can consider solving your problem itself. The difficulty of it depends on what it is.

See also:
http://en.wikipedia.org/wiki/Digital_container_format[^],
http://en.wikipedia.org/wiki/Codec[^],
http://en.wikipedia.org/wiki/MPEG-4[^],
http://en.wikipedia.org/wiki/Demultiplexer_%28media_file%29[^].

[EDIT]

By the way, as FFMpeg and libav are available in source code, you can read the code and find out how to work with nearly all formats and standards. That approach can solve any problems with those headers, like yours. However, I cannot say it will be easy.

—SA
 
Share this answer
 
v2
Comments
Sackos 6-Jun-15 1:47am    
Sergey thanks a lot for your inputs. I have attached screenshots of Mp4 binary source and ffprobe output. I have little experience dealing with ffmpeg. Let me tell you what exactly I am trying to achieve here. 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 and I know it sounds foolish but its a first step towards an idea I am trying to figure out is doable or not. If you know there's any other tool I can use to change the duration, let me know.
Sergey Alexandrovich Kryukov 6-Jun-15 1:52am    
(Sigh...) How can you reference bitmaps where you need to provide some text? Always take text output and post it in your questions, not on some other site. Images can help if you want to show some picture.

The trick you are trying to achieve would be very dirty. Different players behave differently in such situations (I know by my experience), some may even crash/hang. Instead of (or in addition to) explaining you rather weird idea, you could better explain your ultimate goals. That probably you could get better advice.

—SA
Sackos 6-Jun-15 2:11am    
Sorry I just joined this site and its my first question. But will keep in mind your advice in future.
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.
Sergey Alexandrovich Kryukov 6-Jun-15 5:43am    
Here is what I would do: use the same very FFMpeg, in the form of library or even the utility to read the metadata (what is the duration, and so on), to extract fragments of video or separate frames, to transcode this media fragment in whatever format you many need. Nothing else can do better and nothing else can support so many standards. For you, it will be transparent.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900