FFmpegH264Provider can help you quickly create an H264 Stream. It supports setting the cache size and the cache duration in milliseconds. You can use it for live broadcasts or video recordings. FFmpegH264Provider is dependent on FFmpegVideoSource and FFmpegH264Encoder. It gets YUV data through FFmpegVideoSource and then sends YUV data to FFmpegH264Encoder. H264 data generated by FFmpegH264Encoder will be cached in the queue of FFmpegH264Provider. All of its APIs are thread-safe.
...
Set encoding parameters. Create FFmpegH264Encoder and initialize it. Create FFmpegVideoProvider to get yuv frame. Initialize the queue for cache the h264 frame. You can only getFrame/getAllFrames after preparing.
...
You can also refer to the Sample of FFmpegAVMuxer.
the flow of encode h264:
...