obazna
obazna

Reputation: 68

How to add a new stream after avformat_write_header function is called?

I have several video sources that produce video frames. Each video source should be represented as the separate video stream inside an output video file(mp4 or mpegts). The problem is that I should specify the exact number of streams and create them before avformat_write_header function is called. If I try to add the stream after, I will get crash inside av_interleaved_write_frame. Is any way to add a stream on the fly? Maybe there are some muxer options that I should specify? Thanks in advance for your answers.

Upvotes: 1

Views: 389

Answers (1)

Gyan
Gyan

Reputation: 93261

No, new streams can't be added after the header is written. libavformat checks if incoming packet for writing has a stream index outside of [0,nb_streams-1] and will fail if it does.

A MPEG-TS like container could be made to incorporate new streams, but ffmpeg doesn't support that.

Upvotes: 3

Related Questions