0

First of all, I hope you'll understand my poor english skill. I'll do my best to write question about it.

I'm currently developing some application. That application will captures desktop and encodes to MP4 video and send mp4 video data/chunks to another clients (all this process should run in memory not file). so another client should can play mp4 video/data/chunks that received from server.

so I used avio = avio_open(...) and reassigned write function as like avio->write_packet = some_function. but this way seems not "generate" mp4 file/chunk correctly. and It seems the original write_packet callback having actual logic that write packet to a file. but I don't want to write to a file. so I was thinking about it for a week but I did't getting any of idea about it.

so my question is: How can I intercept "encoded" video data that should processed by avio->write_packet?

1 Answer 1

1

Don't hijack avio_open-provided aviocontext, that's bound to cause you troubles. If you want to provide custom AVIOContext, do so - use avio_alloc_context and provide your callbacks there. Use flag AVFMT_FLAG_CUSTOM_IO to indicate that you did so (so this AVIOcontext won't be destroyed automatically when muxer closes).

Sign up to request clarification or add additional context in comments.

2 Comments

I already tried to use avio_alloc_context too. but It won't provide correct video data. It won't even play with regular video player if I just do fwrite(...) to destination file. should I write extra data to destination file?
And it writes correct video file if you just use avio_open with some filename, right? If that's the case then maybe you just need to call avio_flush on your custom AVIOContext (instead of avio_close you'd usually call for avio_opened context)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.