0
votes

I have video file split into few chunks. Split done and random file positions, but chunks are large enough.

I need to parse every part with different instances of AVFormatContext. Chunks come one after another in right order. I think there are two options here:

  1. Being able to save and restore AVFormatContext state;
  2. Save video file header (from first chunk) and attach it to every chunk.

I tried both but no success. First approach requires to go too deeply beyond public API of ffmpeg. With second approach I am unable to merge header with new chunk so that ffmpeg can handle it.

Can you help me with this?

Thank you.

1

1 Answers

2
votes

It totally depends on the file type. MP4 for example, the header must be completely rewritten, and can not just be copied. Flv the header can probably just be copied, but MUST be split on frame boundary and not randomly. TS could do this, but you would miss a frame at the cut point.

Realistically, the file will need to be reassembled, the split correctly.