I'm currently developing a video streaming software using VP8 and V4L2 but I'm struggling with the key concepts of frame rating.
I have a basic working implementation that fetches frames in a loop, encodes it and sends it over RTP (as fast as it can). However, I don't understand how to control the frame rate of the video or regulate the sampling.
Basically it could be summarized as follows :
while (true) {
ioctl(fd, VIDIOC_DQBUF, buf); // Get the V4L buffer
vpx_codec_encode(...); // VP8 encode using pts and timebase
sendto(); // Send through RTP with the correct timestamp
}
In particular, I don't get how to properly set :
- The V4L2 capture loop (does it need a timer to fetch frames on a regular basis ?)
- The FRAME INTERVAL setting from V4L2 (is it mandatory ?)
- The libvpx timebase (should I use 1/fps ? 1001/30000 ?)
- The pts value (Does it need to be frame num * (1/fps) * 90000 ?)
- The RTP timestamp (Can I use the pts here ?)
- Any other configuration settings that could be taken into account ...