I'm struggling to understand how to set AVPacket::duration field. I have done loads of googling, but never found any working answer. When leaving the field with default 0, which is what it is after avcodec_receive_packet() call, for 30 FPS video I get 34.28 reported (by ffprobe as well as Windows file properties tab). All time-stamps printed by "ffprobe -show_frames" however perfectly correspond with 30 FPS.
The encodingContext->time_base is 1/30 and stream->time_base is 1/15360.
Whilst hard-coding the duration = 1 makes the FPS reported correctly, it just can't be right, because hard-coding a value for all possible scenario would mean that the field is unnecessary and also it would be in conflict with the documentation.