title: Ffmpeg unable to initialize swsContext for H264 frame data received through RTP Payload
body: <p>I am trying to decode H264 video frames received through RTSP streaming.</p>
  
  <p>I followed this post: <a href="https://stackoverflow.com/questions/7665217/how-to-process-raw-udp-packets-so-that-they-can-be-decoded-by-a-decoder-filter-i">How to process raw UDP packets so that they can be decoded by a decoder filter in a directshow source filter</a></p>
  
  <p>I was able to identify start of the frame &amp; end of the frame in RTP packets and reconstructed my Video Frame.</p>
  
  <p>But I <strong>didnt receive</strong> any SPS,PPS data from my RTSP session. I looked for string <strong>"sprop-parameter-sets"</strong> in my <strong>SDP(Session Description Protocol)</strong> and there was none.</p>
  
  <h1><strong>Reconstructing Video Frame from RTP Packets:</strong></h1>
  
  <p>Payload in the first RTP Packet goes like this : <strong>"1c 80 00 00 01 61 9a 03 03 6a 59 ff 97 e0 a9 f6"</strong></p>
  
  <p>This says that its a fragmented data(<strong>"1C"</strong>) and start of the frame(<strong>"80"</strong>). I copied the rest of the <strong>payload data(except the first 2 bytes "1C 80")</strong>.</p>
  
  <p>Following RTP Packets have the "Payload" start with <strong>"1C 00"</strong> which is continuation of the frame data.  I kept adding payload data(except the first 2 bytes <strong>"1C 00"</strong>) into the byte buffer for all the following RTP Packets.</p>
  
  <p>When I get the RTP packet with payload starts with <strong>"1C 40"</strong>, which is end of the frame, I copied the rest of the payload data(except the first 2 bytes <strong>"1C 40"</strong>) of that RTP Packet into the byte buffer. </p>
  
  <p>Thus I reconstructed the Video Frame into the byte buffer.</p>
  
  <p>Then I prepended 4 bytes <strong>[0x00, 0x00 , 0x00, 0x01]</strong> to the byte buffer before sending to the decoder, because I didnt receive any SPS, PPS NAL bytes.</p>
  
  <p>When I send this byte buffer to the decoder, decoder fails when it tries to <strong>initialize sws Context</strong>.</p>
  
  <p>Am I sending the NAL bytes and video frame data correctly?</p>