On 21-09-2024 04:39, Alan Chen via ffmpeg-user wrote:
I am using ffmpeg.

I use the following command to get all packet info:

ffprobe -print_format json -show_packets -show_streams -show_entries
packet=pts,duration,size,codec_type,pos test.mp4 > test.mp4.info

Then based on each packet info, such as the one below:

         {
             "codec_type": "video",
             "pts": 0,
             "duration": 512,
             "size": "6419",
             "pos": "175"
         }

I extract the raw data of the packet from the test.mp4 file, take the above
packet as a example, I extract the data at offset = 175 and size = 6419,
then save the packet into a new file, video_sample0.dat.

I write an app to write all the packets into different audio and video
files, i.e., audio_sample0.dat, audio_sample1.dat, ..., video_sample0.dat,
video_sample1.dat...

Then I use ffprobe with -show_data option to show the raw data of each
packet, then compare the output with my packet files and confirm they are
identical.

After that, I remove some useless packets. Then try to recreate a new MP4
file with the remaining packets.

I take one packet file as a test:

ffmpeg -f m4v -i video_sample0.dat -c copy output.mp4

But get the following error:

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
[mpeg4 @ 00628400] time_increment_bits 0 is invalid in relation to the
current bitstream, this is likely caused by a missing VOL header
[mpeg4 @ 00628400] time_increment_bits set to 5 bits, based on
bitstream analysis
[mpeg4 @ 00628400] time_increment_bits 4 is invalid in relation to the
current bitstream, this is likely caused by a missing VOL header
[mpeg4 @ 00628400] time_increment_bits set to 5 bits, based on
bitstream analysis
[mpeg4 @ 00628400] looks like this file was encoded with
(divx4/(old)xvid/opendivx) -> forcing low_delay flag
[m4v @ 003e8d00] Could not find codec parameters for stream 0 (Video:
mpeg4, yuv420p): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and
'probesize' (5000000) options
Input #0, m4v, from 'video_sample0.dat':
   Duration: N/A, bitrate: N/A
   Stream #0:0: Video: mpeg4, yuv420p, 25 fps, 1200k tbr, 1200k tbn
File 'output.mp4' already exists. Overwrite? [y/N] y
Stream mapping:
   Stream #0:0 -> #0:0 (copy)
[mp4 @ 00628400] dimensions not set
[out#0/mp4 @ 0062b380] Could not write header (incorrect codec
parameters ?): Invalid argument
Conversion failed!

So, how to reassemble the raw packet data back to a new MP4 file?
_______________________________________________
Start reading and understanding this:https://www.iso.org/standard/55688.html
It is the first of 32 parts to read in order to understand how MPEG-4 works and how to (re)create it. Unfortunately, this information is not free (patented) so you'll have to pay to read it.
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to