[FFmpeg-user] How to reassemble raw packet data back into a new MP4 file?
Ferdi Scholten
ferdi at sttc-nlp.nl
Sat Sep 21 14:44:24 EEST 2024
On 21-09-2024 12:32, Alan Chen via ffmpeg-user wrote:
> What I remove is the last video and audio packet in each stream. All the
> meta data are still there, together with all remaining packet data as
> separate files. But I don't know how to utilize them in the commandline to
> reassemble the packets.
> _______________________________________________
>
Analogy
You demolished a brick house and want to rebuild it, leaving some of the
material out, without changing the material you have.
That does not work, because the hardened cement holding the bricks
cannot be re-used as is. You either have to use new cement on the
cleaned bricks (rather easy) or process the hardened cement to make it
usable as fresh cement again (rather difficult, needs expertise and a
big processing plant)
Your extracted packets are bricks including the hardened cement used to
hold them together, specific to the file they were extracted from. That
is why usually if you want to recreate an mp4 that has some packets left
out, you do not extract and reassemble packets from the file, but only
the desired video and audio, either raw or compressed in some format
(only the cleaned bricks) and recreate the mp4 with those (using new
cement).
If you insist on recreating a different mp4 file from only these
extracted packets you will have to change interrelated data inside
(some/all) of the packets in order to make the modified file work.
Sure it can be done, but it needs expertise, is difficult, time
consuming and inefficient. (but you will learn how to hand build mp4
containers from scratch).
More information about the ffmpeg-user
mailing list