I'm afraid I don't know good answers to your questions, but you do say that you're manipulating the pos, PTS, etc fields. Maybe your manipulation of them is causing the presentation order/buffering that you mention.
On Sun, 29 Sept 2024, 13:16 Wodzu, <[email protected]> wrote: > Hello, > > I am decoding a raw h264 stream based on example from: > https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/decode_video.c > > The problem is that I need to somehow tie up a custom information to > AVPacket and receive it in AVFrame. Because it is raw h264, I am sure that > one AVPacket sent is equal to one AVFrame received. > > I've tried the following: AVPacket->opaque but this field is not passed to > AVFrame->opaque. > So I've tried some ugly hacks and use one of these fields: > > av_packet->duration = > av_packet->pts = > av_packet->dts = > av_packet->pos = > > These can be read from frame after calling: > avcodec_receive_frame(codec_context, frame); > > However, there are two strange things that are occurring: > > > 1. When I am sending the very first IFrame (which also contains PPS > and SPS) via avcodec_send_packet(codec_context, packet) and then I want to > receive a corresponding frame via avcodec_receive_frame(), the function > will return me AVERROR(EAGAIN). I don't understand why it needs more data > if what it got is a full IFrame?. I need to send two more packets (each > containing exactly one frame) to get first frame out of > avcodec_receive_frame(). Why the decoder decides to store two frames in its > buffer before sending me anything. > 2. Even though the frames are received in correct order (I've saved > them as images and checked them), the fields like av_packet->pos which was > passed to frame and can be read through frame->pkt_pos are in not correct > order. Take a look: > > > avcodec_send_packet - (av_packet->pos): 0 > avcodec_send_packet - (av_packet->pos): 1 > avcodec_send_packet - (av_packet->pos): 2 > avcodec_receive_frame - (frame->pkt_pos): 0 <- first frame received after > sending three packets, each containing one frame. > avcodec_send_packet - (av_packet->pos): 3 > avcodec_receive_frame - (frame->pkt_pos): 2 <- mixed order, pkt_pos should > be 1? > avcodec_send_packet - (av_packet->pos): 4 > avcodec_receive_frame - (frame->pkt_pos): 1 > avcodec_send_packet - (av_packet->pos): 5 > avcodec_receive_frame - (frame->pkt_pos): 3 > avcodec_send_packet - (av_packet->pos): 6 > avcodec_receive_frame - (frame->pkt_pos): 4 > avcodec_send_packet - (av_packet->pos): 7 > avcodec_receive_frame - (frame->pkt_pos): 5 > avcodec_send_packet - (av_packet->pos): 8 > avcodec_receive_frame - (frame->pkt_pos): 6 > avcodec_send_packet - (av_packet->pos): 9 > flush called > avcodec_receive_frame - (frame->pkt_pos): 8 <- again mixed order, should > be 7. > avcodec_receive_frame - (frame->pkt_pos): 7 > avcodec_receive_frame - (frame->pkt_pos): 9 > > I would be grateful if you could: > 1. Show me how can I force decoder to send me a frame immediately rather > thanb keeping it in its buffer. > 2. Show me how to fix that strange ordering. > 3. Given any other advice how could I pass information in AVPacket and > receive it in corresponding AVFrame. > > Thank you. > > _______________________________________________ > Libav-user mailing list > [email protected] > https://ffmpeg.org/mailman/listinfo/libav-user > > To unsubscribe, visit link above, or email > [email protected] with subject "unsubscribe". >
_______________________________________________ Libav-user mailing list [email protected] https://ffmpeg.org/mailman/listinfo/libav-user To unsubscribe, visit link above, or email [email protected] with subject "unsubscribe".
