Video Recording in C++ using tee

I am trying to video record and video stream , i want to create only one pipeline and using tee i should be able split the pipeline into two, And recording i want to start on a button click and stop the same way