Custom video source (video generated by code)?

Hi thanks for the wonderful library! I wonder how can I use a custom video source? For simplicity, just consider the custom source as one generated by some code.

Thanks very much!