'''capture.py''' import cv, sys cap = cv.CaptureFromCAM(0) # 0 is for /dev/video0 while True : if not cv.GrabFrame(cap) : break frame = cv.RetrieveFrame(cap) sys.stdout.write( frame.tostring() )
Then I am piping it into ffmpeg and starting a mpegts server
python capture.py | ffmpeg -f rawvideo -pixel_format bgr24 -video_size 1440x1080 -framerate 10 -an -i - -c:v h264_nvenc -preset llhp -b:v 3000k -profile:v high -g 1 -vsync 0 -an -f mpegts tcp://localhost:5000?listen&overrun_nonfatal=1&ttl=10&pkt_size=188&buffer_size=8000k
Then as a test, I am reading the stream from ffplay as a client
I am seeing a 6-8 second delay of the stream using this on localhost, but I expect it could be much faster. Can anyone please advise on how to make this pipeline faster but still use openCV from Python to capture frames and send them to ffmpeg?