i'm developing video streaming software using vp8 , v4l2 i'm struggling key concepts of frame rating.
i have basic working implementation fetches frames in loop, encodes , sends on rtp (as fast can). however, don't understand how control frame rate of video or regulate sampling.
basically summarized follows :
while (true) { ioctl(fd, vidioc_dqbuf, buf); // v4l buffer vpx_codec_encode(...); // vp8 encode using pts , timebase sendto(); // send through rtp correct timestamp } in particular, don't how set :
- the v4l2 capture loop (does need timer fetch frames on regular basis ?)
- the frame interval setting v4l2 (is mandatory ?)
- the libvpx timebase (should use 1/fps ? 1001/30000 ?)
- the pts value (does need frame num * (1/fps) * 90000 ?)
- the rtp timestamp (can use pts here ?)
- any other configuration settings taken account ...
the v4l2 capture loop (does need timer fetch frames on regular basis ?)
either that, or find way block thread until new data arrives (e.g. using select())
the frame interval setting v4l2 (is mandatory ?)
it's not mandatory. when setting frame_interval, tell device sample data @ specified interval. device might ignore request (e.g. because cannot capture @ given samplerate). note, internal clock of device might inaccurate and/or different other clocks on system.
the libvpx timebase (should use 1/fps ? 1001/30000 ?)
obviously depends on framerate.
the vpx-documentation quite clear here:
indicates smallest interval of time, in seconds, used stream. fixed frame rate material, or variable frame rate material frames timed @ multiple of given clock (ex: video capture), recommended method set timebase reciprocal of frame rate (ex: 1001/30000 29.970 hz ntsc). allows pts correspond frame number, can handy. re-encoding video containers absolute time timestamps, recommended method set timebase of parent container or multimedia framework (ex: 1/1000 ms, in flv).
since timebase of type vpx_rational, need express ratio between 2 integers. e.g. cannot use 1/fps ntsc's weirdo rate.
the pts value (does need frame num * (1/fps) * 90000 ?)
no not (see above). can simple frame_num.
the rtp timestamp (can use pts here ?)
yes.
Comments
Post a Comment