質問

I would like to capture video, compress it and mux it as an mpeg2 ts. All of this is quite simple with the ffmpeg libraries, but what I would like to do, instead of writing it to a file, is capture the ts packets in a buffer and using this stream in other ways. Is there a simple way to do this?

To write the encoded frames to file right now, I use av_interleaved_write_frame(oc, &pkt). OC is an output context with a filename and format defined. pkt is an AVPacket containing the compressed frame. The av_interlaced_write_frame is doing the muxing and writing the file.

What I would like to ultimately achieve is to write the same ts stream to multiple files, and to start and stop writing the different files independent of each other. Starting a new muxer for each stream seems inefficient, as a TS stream should not need any header or correct ending to be played back correctly (If what I've read is correct)

I'm kind of lost trying to find good examples in the ffmpeg code, and the libraries are not very well documented. Any input on this subject is appreciated. Thank you!

役に立ちましたか?

解決

Finally got it working. One way to do it is to use avio_alloc_context to set up a callback where you do what you want with the stream. This guy has a good example of it:

https://github.com/EvilTengil/kinect-streamer/blob/master/src/kstreamer/ffv1_depth_encoder.cpp

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top