You need to av_rescale_q into your output context's timebase, not the video stream one. What it appears that you are doing is nothing with av_rescale_q. Try:
av_rescale_q(vpkt.pts, vcodec->time_base, [output context]->time_base);
If you continue having problems, almost always problems with B frames are indicative of a bad DTS value. Consider setting DTS to AV_NOPTS_VALUE and let the demuxer solve it itself.
Remember to decode a B frame you must know the frames on either side of it, thus they must be demuxed first, consider 3 frames:
I B I
The first frame must be decoded first, followed by the third and finally the second. This information is derived from the DTS.
Finally, figure out why you're getting a -22 by following this stack overflow. I would be shocked if it isn't a "non-monotonically increasing PTS/DTS" error.