<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><br><div><br><blockquote type="cite"><div>On 24. 3. 2023., at 10:59, Michael Wood <mornwood23@gmail.com> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 24, 2023 at 10:28 AM Strahinja Radman <<a href="mailto:dr.strashni@gmail.com">dr.strashni@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><br><br><blockquote type="cite">On 23. 3. 2023., at 20:19, Michael Wood <<a href="mailto:mornwood23@gmail.com" target="_blank">mornwood23@gmail.com</a>> wrote:<br><br><br><br>On Thu, Mar 23, 2023 at 8:06 PM Strahinja Radman <<a href="mailto:dr.strashni@gmail.com" target="_blank">dr.strashni@gmail.com</a>> wrote:<br><br><br>On Thu, 23 Mar 2023 at 20:05, Michael Wood <<a href="mailto:mornwood23@gmail.com" target="_blank">mornwood23@gmail.com</a>> wrote:<br><br><br>On Thu, Mar 23, 2023 at 6:20 PM Michael Wood <<a href="mailto:mornwood23@gmail.com" target="_blank">mornwood23@gmail.com</a>> wrote:<br>Hi,<br><br>I'm having a weird issue with the decoding of H265 4K stream where 1/3 of the frame is rendered normally and the other 2/3 is in green (<a href="https://ibb.co/C8yFygm" target="_blank">https://ibb.co/C8yFygm</a>). This only happens if i try to decode 4K stream, for non 4K streams everything works as expected.<br><br>I'm using live555 library to get stream from RTSP server after which packets are sent to the ffmpeg to be decoded and later rendered<br><br>DESCRIBE response contains all required VPS,SPS,PPS fields that are passed as extra data to the codec context.<br><br>This is what is returned from DESCRIBE:<br><br>v=0<br>o=- 1679598602413481 1679598602413481 IN IP4 192.168.1.212<br>s=Media Presentation<br>e=NONE<br>b=AS:5050<br>t=0 0<br>a=control:rtsp://<a href="http://192.168.1.212/Streaming/Channels/101/?transportmode=unicast&profile=Profile_1" target="_blank">192.168.1.212/Streaming/Channels/101/?transportmode=unicast&profile=Profile_1</a><br>m=video 0 RTP/AVP 96<br>c=IN IP4 0.0.0.0<br>b=AS:5000<br>a=recvonly<br>a=x-dimensions:3840,2160<br>a=control:rtsp://<a href="http://192.168.1.212/Streaming/Channels/101/trackID=1?transportmode=unicast&profile=Profile_1" target="_blank">192.168.1.212/Streaming/Channels/101/trackID=1?transportmode=unicast&profile=Profile_1</a><br>a=rtpmap:96 H265/90000<br>a=fmtp:96 sprop-vps=QAEMA///AWAAAAMAgAAAAwAAAwCWAAC94Eg=; sprop-sps=QgEDAWAAAAMAgAAAAwAAAwCWAACgAeAgAhx/jb33am7uS/YC3AQEBBAAAD6AAALuByHe5RAAmRgACsPgAEyMAAVh8EACZGAAKw+AATIwABWHwg==; sprop-pps=RAHBcrCcCgFGZA==<br>a=Media_header:MEDIAINFO=494D4B48010300000400050000000000000000000000000081000000000000000000000000000000;<br>a=appversion:1.0<br><br>When trying to decode packets i'm getting this output from hevc, the ffplay/VLC works normally with the incoming stream.<br><br>[hevc @ 0x14ac15600] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0<br>[hevc @ 0x14ac15600] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0<br>[hevc @ 0x14ac15600] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0<br>[hevc @ 0x14ac15600] Decoding VPS<br>[hevc @ 0x14ac15600] Main profile bitstream<br>[hevc @ 0x14ac15600] Decoding SPS<br>[hevc @ 0x14ac15600] Main profile bitstream<br>[hevc @ 0x14ac15600] Decoding VUI<br>[hevc @ 0x14ac15600] Decoding PPS<br>[hevc @ 0x14ac15600] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0<br>[hevc @ 0x14ac15600] Decoding VPS<br>[hevc @ 0x14ac15600] Main profile bitstream<br>[hevc @ 0x14ac15600] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0<br>[hevc @ 0x14ac15600] Decoding SPS<br>[hevc @ 0x14ac15600] Main profile bitstream<br>[hevc @ 0x14ac15600] Decoding VUI<br>[hevc @ 0x14ac15600] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0<br>[hevc @ 0x14ac15600] Decoding PPS<br>[hevc @ 0x14ac15600] nal_unit_type: 19(IDR_W_RADL), nuh_layer_id: 0, temporal_id: 0<br>[hevc @ 0x14ac15600] Format yuvj420p chosen by get_format().<br>[hevc @ 0x14ac15600] Output frame with POC 0.<br>[hevc @ 0x14ac15600] nal_unit_type: 19(IDR_W_RADL), nuh_layer_id: 0, temporal_id: 0<br>[hevc @ 0x14ac15600] First slice in a frame missing.<br>[hevc @ 0x14ac15600] nal_unit_type: 19(IDR_W_RADL), nuh_layer_id: 0, temporal_id: 0<br>[hevc @ 0x14ac15600] First slice in a frame missing.<br>[hevc @ 0x14ac15600] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0<br>[hevc @ 0x14ac15600] Decoding VPS<br>[hevc @ 0x14ac15600] Main profile bitstream<br>[hevc @ 0x14ac15600] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0<br>[hevc @ 0x14ac15600] Decoding SPS<br>[hevc @ 0x14ac15600] Main profile bitstream<br>[hevc @ 0x14ac15600] Decoding VUI<br>[hevc @ 0x14ac15600] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0<br>[hevc @ 0x14ac15600] Decoding PPS<br>[hevc @ 0x14ac15600] nal_unit_type: 19(IDR_W_RADL), nuh_layer_id: 0, temporal_id: 0<br>[hevc @ 0x14ac15600] Output frame with POC 0.<br>[hevc @ 0x14ac15600] nal_unit_type: 19(IDR_W_RADL), nuh_layer_id: 0, temporal_id: 0<br>[hevc @ 0x14ac15600] First slice in a frame missing.<br>[hevc @ 0x14ac15600] nal_unit_type: 19(IDR_W_RADL), nuh_layer_id: 0, temporal_id: 0<br>[hevc @ 0x14ac15600] First slice in a frame missing.<br>[hevc @ 0x14ac15600] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 2<br>[hevc @ 0x14ac15600] Output frame with POC 1.<br>[hevc @ 0x14ac15600] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 2<br>[hevc @ 0x14ac15600] First slice in a frame missing.<br>[hevc @ 0x14ac15600] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 2<br>[hevc @ 0x14ac15600] First slice in a frame missing.<br>[hevc @ 0x14ac15600] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 2<br>[hevc @ 0x14ac15600] Output frame with POC 2.<br>[hevc @ 0x14ac15600] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 2<br>[hevc @ 0x14ac15600] First slice in a frame missing.<br>[hevc @ 0x14ac15600] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 2<br>[hevc @ 0x14ac15600] First slice in a frame missing.<br><br>If I write the stream to the file and play that file either through ffplay or VLC the frames are rendered normally. <br><br>Any suggestion would be welcomed.<br><br>Thanks,<br>Milos<br><br> Hey Strahinja,<br><br>Thanks for the answer,<br><br>Can you provide more info on how to do it ?<br><br>Best,<br>Milos<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
Hey Milos,<br><br>In AVFrame structure, check width, height and stride variables. <br><br><br>-- <br><br>Regards<br>Strahinja Radman<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br><br>Hey Strahinja,<br><br>It seems that both width & height are set correctly. I can't find stride, i don't see any reference to it in the AVFrame header.<br><br>Thanks,<br>Milos<br>
_______________________________________________<br>Libav-user mailing list<br><a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br><a href="https://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br><br>To unsubscribe, visit link above, or email<br><a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe”.<br></blockquote><br>Hey Milos,<br><br>What does a parameter linesize say?<br><br><font size="2">AVFrame->linesize[0]</font><div><font size="2"><br></font></div><div><font size="2">Kind regards,</font></div><div><font size="2">Strahinja<br></font><br><br></div></div></blockquote><div><br></div><div>Hi Strahinja,</div><div><br></div><div>The linesize looks good and corresponds to frame size</div><div><br></div><div>frame->linesize[0] = 3840</div><div>frame->linesize[1] = 1920<br></div><div>frame->linesize[2] = 1920</div><div><br></div><div>Best,</div><div>Milos</div><div><br></div><div><br></div><div> <br></div></div></div>
</div></blockquote><br></div><div>Hey Milos,</div><div><br></div><div>Can you use this method to save one frame to the PGM file and check its contents right after you receive an AVFrame</div><div><br></div><div>static void pgm_save(unsigned char* buf, int wrap, int xsize, int ysize, const char* filename) </div><div><span> {</span><span> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>FILE* f; </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>int i;</div><div><span> f = fopen(filename, "w");</span><span> </span></div><div><span><span class="Apple-tab-span" style="white-space:pre"> </span>fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255);</span><span> </span></div><div><span><span class="Apple-tab-span" style="white-space:pre"> </span>for (i = 0; i < ysize; i++)</span><span> </span></div><div><span><span class="Apple-tab-span" style="white-space:pre"> </span>fwrite(buf + i * wrap, 1, xsize, f);</span><span> </span></div><div><span><span class="Apple-tab-span" style="white-space:pre"> </span>fclose(f);</span><span> </span></div><div><span>}</span><div></div></div><div><br></div><div>buf is frame->data[0]</div><div>wrap is frame->linesize[0]</div><div>xsize is width and ysize is height</div><div><br></div><div>Kind regards,</div><div>Strahinja</div><br></body></html>