[FFmpeg-user] How to reassemble raw packet data back into a new MP4 file?
Alan Chen
ccw at datanumen.org
Sun Sep 22 10:22:29 EEST 2024
Hi, Vincent,
Thank you for your suggestion.
Let me explain the real case: I have many MP4 files which lost some data in
the tail,
which make them not playable. I analyze these files manually and find the
ftyp and
moov boxes and their child boxes are all OK. But part of the data in mdat
box are
lost, which corresponding to some packet data only, which is <= 5% of the
total
packets.
I try to use the following command:
ffmpeg -i old.mp4 -c copy new.mp4
but always get the following result:
ffmpeg version 7.0.2 Copyright (c) 2000-2024 the FFmpeg developers
built with gcc 14.1.0 (Rev3, Built by MSYS2 project)
configuration: --enable-shared
libavutil 59. 8.100 / 59. 8.100
libavcodec 61. 3.100 / 61. 3.100
libavformat 61. 1.100 / 61. 1.100
libavdevice 61. 1.100 / 61. 1.100
libavfilter 10. 1.100 / 10. 1.100
libswscale 8. 1.100 / 8. 1.100
libswresample 5. 1.100 / 5. 1.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 00158b00] stream 1, contradictionary STSC and
STCO
[mov,mp4,m4a,3gp,3g2,mj2 @ 00158b00] error reading header
[in#0 @ 00158840] Error opening input: Invalid data found when processing
input
Error opening input file old.mp4.
Error opening input files: Invalid data found when processing input
So I wrote a Test app to parse all the data in the old.mp4 and read all the
boxes(except for mdat box), and
get all the existing packets. Now I want to reassemble them back into a
valid MP4 file.
More information about the ffmpeg-user
mailing list