<div>No that is not it, the same goes for opaque field (I've managed to get it copied via AV_CODEC_FLAG_COPY_OPAQUE) but thanks anyway.<br></div><div><br></div><div><br></div><div class="nh_extra"><p>Dnia 30 września 2024 09:36 Ben Harper <rogojin@gmail.com> napisał(a):<br></p><blockquote class="nh_quote" style="border-left: 2px solid #999; padding-left: 8px; margin: 0;"><div id="gwpbeea5177"><div id="gwpbeea5177h"><div data-message-body="true" class="gwpbeea5177b"><div dir="auto"><div><div>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.<br></div><div><br></div><div class="gwpbeea5177_gmail_quote"><div class="gwpbeea5177_gmail_attr" dir="ltr">On Sun, 29 Sept 2024, 13:16 Wodzu, <<a rel="noopener noreferrer" target="_blank" href="mailto:brucedickinson@wp.pl">brucedickinson@wp.pl</a>> wrote:<br></div><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" class="gwpbeea5177_gmail_quote"><div>Hello,<br></div><div><br></div><div>I am decoding a raw h264 stream based on example from: <a ="" target="_blank" rel="noreferrer" href="https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/decode_video.c">https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/decode_video.c</a><br></div><div><br></div><div>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.<br></div><div><br></div><div>I've tried the following: AVPacket->opaque but this field is not passed to AVFrame->opaque.<br></div><div>So I've tried some ugly hacks and use one of these fields:<br></div><div><br></div><div>av_packet->duration = <br></div><div>av_packet->pts = <br></div><div>av_packet->dts = <br></div><div>av_packet->pos = <br></div><div><br></div><div>These can be read from frame after calling: avcodec_receive_frame(codec_context, frame);<br></div><div><br></div><div>However, there are two strange things that are occurring:<br></div><div><br></div><ol><li>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.<br></li><li>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:<br></li></ol><div><br></div><div>avcodec_send_packet - (av_packet->pos): 0<br></div><div>avcodec_send_packet - (av_packet->pos): 1<br></div><div>avcodec_send_packet - (av_packet->pos): 2<br></div><div>avcodec_receive_frame - (frame->pkt_pos): 0 <- first frame received after sending three packets, each containing one frame.<br></div><div>avcodec_send_packet - (av_packet->pos): 3<br></div><div>avcodec_receive_frame - (frame->pkt_pos): 2 <- mixed order, pkt_pos should be 1?<br></div><div>avcodec_send_packet - (av_packet->pos): 4<br></div><div>avcodec_receive_frame - (frame->pkt_pos): 1<br></div><div>avcodec_send_packet - (av_packet->pos): 5<br></div><div>avcodec_receive_frame - (frame->pkt_pos): 3<br></div><div>avcodec_send_packet - (av_packet->pos): 6<br></div><div>avcodec_receive_frame - (frame->pkt_pos): 4<br></div><div>avcodec_send_packet - (av_packet->pos): 7<br></div><div>avcodec_receive_frame - (frame->pkt_pos): 5<br></div><div>avcodec_send_packet - (av_packet->pos): 8<br></div><div>avcodec_receive_frame - (frame->pkt_pos): 6<br></div><div>avcodec_send_packet - (av_packet->pos): 9<br></div><div>flush called<br></div><div>avcodec_receive_frame - (frame->pkt_pos): 8 <- again mixed order, should be 7.<br></div><div>avcodec_receive_frame - (frame->pkt_pos): 7<br></div><div>avcodec_receive_frame - (frame->pkt_pos): 9<br></div><div><br></div><div><div>I would be grateful if you could:<br></div><div>1. Show me how can I force decoder to send me a frame immediately rather thanb keeping it in its buffer.<br></div></div><div>2. Show me how to fix that strange ordering.<br></div><div>3. Given any other advice how could I pass information in AVPacket and receive it in corresponding AVFrame.<br></div><div><br></div><div>Thank you.<br></div><div><br></div><div>_______________________________________________<br></div><div> Libav-user mailing list<br></div><div> <a target="_blank" rel="noreferrer" href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br></div><div> <a ="" target="_blank" rel="noreferrer noreferrer" href="https://ffmpeg.org/mailman/listinfo/libav-user">https://ffmpeg.org/mailman/listinfo/libav-user</a><br></div><div> <br></div><div> To unsubscribe, visit link above, or email<br></div><div> <a target="_blank" rel="noreferrer" href="mailto:libav-user-request@ffmpeg.org">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br></div></blockquote></div></div></div></div></div></div><div id="gwp03a541a1"><div>_______________________________________________<br></div><div>Libav-user mailing list<br></div><div>Libav-user@ffmpeg.org<br></div><div><a target="_blank" ="" href="https://ffmpeg.org/mailman/listinfo/libav-user">https://ffmpeg.org/mailman/listinfo/libav-user</a><br></div><div><br></div><div>To unsubscribe, visit link above, or email<br></div><div>libav-user-request@ffmpeg.org with subject "unsubscribe".<br></div></div></blockquote></div><div><br></div>