[FFmpeg-user] How to reassemble raw packet data back into a new MP4

Alan Chen ccw at datanumen.org
Sat Sep 21 17:12:59 EEST 2024


>
>
>
>  > So, how to reassemble the raw packet data back to a new MP4 file?
>
> That's not possible in general, because your raw packets do not
> contain sufficient information to create an MP4 file.
>
> I suggest that you explain why you are actually doing all of that.
> What is the purpose, what do you want to achieve actually, on a
> higher level?  There's probable a *much* easier way than trying
> to dissect the video on the packet level.
>
>
> Thank you. I have the other information from the different boxes of the
MP4 file,
but I just don't know how to use them together with the raw packets to
reassemble
a new valid MP4 file.

The stream is in MPEG4 format, based on the ffprobe result:

    "streams": [
        {
            "index": 0,
            "codec_name": "mpeg4",
            "codec_long_name": "MPEG-4 part 2",
            "profile": "Simple Profile",
            "codec_type": "video",
            "codec_tag_string": "mp4v",
            "codec_tag": "0x7634706d",
            "width": 352,
            "height": 288,
            "coded_width": 352,
            "coded_height": 288,
            "closed_captions": 0,
            "film_grain": 0,
            "has_b_frames": 0,
            "sample_aspect_ratio": "1:1",
            "display_aspect_ratio": "11:9",
            "pix_fmt": "yuv420p",
            "level": 1,
            "chroma_location": "left",
            "refs": 1,
            "quarter_sample": "false",
            "divx_packed": "false",
            "id": "0x1",
            "r_frame_rate": "25/1",
            "avg_frame_rate": "251/10",
            "time_base": "1/12800",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 128000,
            "duration": "10.000000",
            "bit_rate": "544953",
            "nb_frames": "251",
            "nb_read_packets": "251",
            "extradata_size": 46,
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "non_diegetic": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "language": "und",
                "handler_name": "VideoHandler",
                "vendor_id": "[0][0][0][0]"
            }
        },


More information about the ffmpeg-user mailing list