简体   繁体   中英

How can I intercept encoded video data using ffmpeg with C?

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 ?

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM