Home/News | About | Download | Documentation | Forum | Bug Reports | Contact | Donations | Consulting | Projects | Legal | Security | FATE


This forum has not been maintained for a long time and will probably get deleted in the near future.
For faster responses to your questions, please use StackOverflow instead and tag your questions with "FFmpeg".
If you need a backup of the posts from this forum, please contact me directly.

Playing multiple h264 stream with ffplay fails

Who doesn't love them :) But for faster response on your Bug Reports, please visit: http://www.ffmpeg.org/bugreports.html
Forum rules
First of all, please remember that all the developers working on FFmpeg are volunteers, we are not paid for analyzing, debugging, fixing and answering bug reports. While we try our best to create high quality software and be responsive, if you should not get an answer, please consider the above and be aware of the fact that we receive many bug reports and the amount of time it takes to deal with them can be substantial. Nevertheless most issues get resolved, just please understand that there are no guarantees nor promises.

Playing multiple h264 stream with ffplay fails

Postby jeroenz » Tue Jan 12, 2016 12:16 pm

Hello all,
I am working on a project where we have to display multiple RTP video streams coming from different video encoders. We use the ffmpeg library (latest 2.8.4) to accomplish this but experienced some problems with it. Fortunately the problem reproduces with ffplay, so hopefully someone can help me out.
One stream is being multicasted on 239.228.61.15 port 50000, the other stream on 239.240.61.15, port 50000. I have one sdp file for each stream, let's say a.sdp and b.sdp:

Code: Select all
v=0
o=private 996981470386994 996981470386994 IN IP4 10.1.2.3
s=stream_a
e=NONE
b=AS:50000
t=0 0
a=range:npt=0.000000-
m=video 50000 RTP/AVP 96
c=IN IP4 239.228.61.15/5
b=AS:50000
a=framerate:25.0
a=transform:0.916667,0.000000,0.000000;0.000000,1.000000,0.000000;0.000000,0.000000,1.000000
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; profile-level-id=4D0029; sprop-parameter-sets=Z00AKeKQFgJNgScFAQXh4kRU,aO48gA==


and
Code: Select all
v=0
o=private 996981472646738 996981472646738 IN IP4 10.1.2.3
s=stream_b
e=NONE
b=AS:50000
t=0 0
a=range:npt=0.000000-
m=video 50000 RTP/AVP 96
c=IN IP4 239.240.61.15/5
b=AS:50000
a=framerate:25.0
a=transform:0.916667,0.000000,0.000000;0.000000,1.000000,0.000000;0.000000,0.000000,1.000000
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; profile-level-id=4D0029; sprop-parameter-sets=Z00AKeKQFgJNgScFAQXh4kRU,aO48gA==


As can be seen, both are equal, apart from the stream name and the multicast address...

When I start a single instance of ffplay with either sdp file, it works great (either showing the stream defined in a.sdp or b.sdp, depending on which sdp file I supplied as parameter). However, when I first start ffplay with a.sdp (all ok: ffplay is displaying the stream defined in a.sdp), and then start another instance of ffplay with b.sdp, things go wrong. Suddenly both instances display the video stream defined in b.sdp! Also both instances now generate a lot of errors like these:

Code: Select all
[h264 @ 0x7f049c008c00] RTP: missed -44310 packetssq=    0B f=0/0
[h264 @ 0x7f049c008c00] RTP: PT=60: bad cseq 1476 expected=c18c
[h264 @ 0x7f049c008c00] RTP: missed -44310 packetssq=    0B f=0/0
[h264 @ 0x7f049c008c00] RTP: dropping old packet received too late
[h264 @ 0x7f049c008c00] RTP: dropping old packet received too late
[h264 @ 0x7f049c008c00] RTP: dropping old packet received too late


When running a single instance of ffplay with either sdp file, no errors are generated.

It seems to me that there is a problem with the multicast subscription mechanism, as if both streams are fed into both instances of ffplay!

(One more note: With an old version of ffmpeg (0.10, ffplay v0.6.5), all works fine. However, in certain situations we need to also display stream coming in on another NIC. This is not working with this old version, so that's why we're using the newer version now. So it seems that the implementation for 'multiple nic support' somewhere along the line broke something in this respect...)

Can somebody maybe explain what's going on/wrong here? And hopefully, have a solution? Is this a known bug? (I tried to search but couldn't find any similar issues...)

Best regards,
Jeroen
jeroenz
 
Posts: 2
Joined: Tue Jan 12, 2016 11:12 am

Re: Playing multiple h264 stream with ffplay fails

Postby jeroenz » Wed Jan 13, 2016 7:08 am

Hi all,

After digging into this a bit further, I found the cause of the problem myself...

In libavformat/udp.c (function udp_open, line 734 in 2.8.4), we see the following piece of code:

Code: Select all
    if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) {
        bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len);


If I replace this by this code:
Code: Select all
    if (s->is_multicast ) {
        bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len);

, everything works fine. I am then able to run multiple instances of ffplay showing different streams without problems.
So I guess the real problem is that ffplay opens the udp stream in read/write mode, while it should be enough to open it in read-only mode... I didn't look into this further, but I guess it's time for a bug report...
Hopefully this comment is helpfull for others.
Best regards,
Jeroen
jeroenz
 
Posts: 2
Joined: Tue Jan 12, 2016 11:12 am


Return to Bugs, bugs, bugs :)

Who is online

Users browsing this forum: No registered users and 2 guests