title: ffmpeg udp/tcp stream receive frame not same as sent
body: <p>I am streaming a video on raspberrypi using command:</p>
  
  <pre><code>ffmpeg -re -threads 2 -i sample_video.m2v -f mpegts - | \
  ffmpeg -f mpegts -i - -c copy -f mpegts udp://192.168.1.100:12345
  </code></pre>
  
  <p>The remote PC with 192.168.1.100 uses ffmpeg library to listen to the input stream. For example:</p>
  
  <pre><code>informat = ffmpeg::av_find_input_format("mpegts");
  avformat_open_input(&amp;pFormatCtx, "udp://192.168.1.100:12345", informat, options);
  </code></pre>
  
  <p>However, when I compute the hash value of each decoded frame on two sides (i.e. raspberrypi and PC), they DON'T MATCH at all. A weird thing is, among ~2000 frames, there are in total ~10 frames whose hash value are the same on the sender and receiver side. The match result look like this: </p>
  
  <pre><code>00000....00011000...00011110000...000
  </code></pre>
  
  <p>where 0 indicates non-match and 1 indicates match. The matched frame appeared 2~6 in sequence and appeared rarely while most of the other frames has different hash value.</p>
  
  <p>The hash is computed on the frame data buffer extracted using <a href="https://stackoverflow.com/questions/19377938/how-to-get-raw-frame-data-from-avframe-data-and-avframe-linesize-without-spe"><code>avpicture_layout()</code></a>. On the Pi side, I just stream the video to a local port and there's a local process using the same code to decode and hash the frames:</p>
  
  <pre><code>ffmpeg -re -threads 2 -i sample_video.m2v -f mpegts - | \
  ffmpeg -f mpegts -i - -c copy -f mpegts udp://localhost:12345
  ...
  </code></pre>
  
  <p>The streaming source raspberry pi, is connected directly to the PC using cable. I don't think it is a packet loss problem. Because, first, I rerun the same process several times and the hash value of the received frames are the same (otherwise the result should be different because packet loss is probabilistic). Secondly, I even try to stream on tcp://192.168.1.100:12345 (and "tcp://192.168.1.100:12345?listen" on PC), and the received frame hash are still the same - different than the hash result on the Pi.</p>
  
  <p>So, does anyone know why the streaming to a remote address will yield different decoded frames? Maybe I am missing some details.</p>
  
  <p>Thanks in advance!!</p>