0

I am streaming a video on raspberrypi using command:

ffmpeg -re -threads 2 -i sample_video.m2v -f mpegts - | \
ffmpeg -f mpegts -i - -c copy -f mpegts udp://192.168.1.100:12345

The remote PC with 192.168.1.100 uses ffmpeg library to listen to the input stream. For example:

informat = ffmpeg::av_find_input_format("mpegts");
avformat_open_input(&pFormatCtx, "udp://192.168.1.100:12345", informat, options);

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:

00000....00011000...00011110000...000

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.

The hash is computed on the frame data buffer extracted using avpicture_layout(). 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:

ffmpeg -re -threads 2 -i sample_video.m2v -f mpegts - | \
ffmpeg -f mpegts -i - -c copy -f mpegts udp://localhost:12345
...

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.

So, does anyone know why the streaming to a remote address will yield different decoded frames? Maybe I am missing some details.

Thanks in advance!!

Community
  • 1
  • 1
vivienlwt
  • 163
  • 1
  • 1
  • 7
  • Why are you using two ffmpeg processes instead of just one? – llogan Nov 21 '13 at 19:48
  • @LordNeckbeard: some historical reasons. This is part of the original command, which is to pipe the video to two destinations at the same time. And at two ends, they both read the stream and execute the same procedure. Later on, I tried on two PCs and the result are identical. The hash is just not identical on one PC and one RaspberryPi. Indeed the Pi was quite slow when processing the frames. I don't know if it is this reason, that ffmpeg adjust the frames automatically based on the processing capability. – vivienlwt Dec 11 '13 at 15:44
  • Perhaps the [tee muxer](http://ffmpeg.org/ffmpeg-formats.html#tee) would be useful for you. – llogan Dec 11 '13 at 17:13
  • Yes, I did. But that is not what causes the problem. Thanks any way :) – vivienlwt Dec 13 '13 at 09:17

0 Answers0