Opened 14 years ago

Closed 12 years ago

#258 closed defect (needs_more_info)

RTP over UDP: doesn't reorder packets

Reported by: Andrew Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: RTP reorder
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

muxonly.c source
...
ic = avformat_alloc_context();
ic->preload = 1000000; 1 sec
ic->max_delay = 3000000;
5 sec
ap.prealloced_context = 1;
ret = av_open_input_file(&ic, argv[1], NULL, 0, &ap);
...
while ()

av_read_frame()

...

libavformat/rtpdec.h
-#define RTP_REORDER_QUEUE_DEFAULT_SIZE 10
+#define RTP_REORDER_QUEUE_DEFAULT_SIZE 50

./muxonly 'rtsp://axis1031:554/axis-media/media.amp?video=1&audio=0&videocodec=mpeg4' mov /tmp/test.mov
SDP:
v=0
o=- 1306917023786450 1306917023786450 IN IP4 axis1031
s=Media Presentation
e=NONE
c=IN IP4 0.0.0.0
b=AS:8000
t=0 0
a=control:rtsp://axis1031:554/axis-media/media.amp?video=1&audio=0&videocodec=mpeg4
a=range:npt=0.000000-
m=video 0 RTP/AVP 96
b=AS:8000
a=framerate:30.0
a=transform:1,0,0;0,1,0;0,0,1
a=control:rtsp://axis1031:554/axis-media/media.amp/trackID=1?video=1&audio=0&videocodec=mpeg4
a=rtpmap:96 MP4V-ES/90000
a=fmtp:96 profile-level-id=245; config=000001B0F5000001B50ECF000001000000012000C88D881F4514043C14103F

video codec set to: mpeg4
hello state=0
RTP: missed 3 packets
RTP: missed 2 packets
RTP: missed 2 packets
RTP: missed 1 packets
RTP: missed 3 packets
RTP: missed 5 packets
RTP: missed 2 packets
RTP: missed 2 packets
RTP: missed 3 packets
RTP: missed 4 packets
RTP: missed 3 packets
RTP: missed 1 packets
RTP: missed 5 packets
RTP: missed 3 packets
RTP: missed 4 packets
RTP: missed 4 packets
RTP: missed 4 packets
RTP: missed 7 packets
RTP: missed 4 packets
RTP: missed 4 packets
RTP: missed 4 packets
RTP: missed 6 packets
RTP: missed 3 packets
RTP: missed 4 packets
RTP: missed 6 packets
RTP: missed 2 packets
RTP: missed 4 packets
RTP: missed 5 packets
RTP: missed 3 packets
RTP: missed 3 packets
RTP: missed 2 packets
RTP: missed 3 packets
RTP: missed 2 packets
RTP: missed 5 packets
RTP: missed 3 packets
RTP: missed 13 packets
RTP: missed 29 packets
RTP: missed 12 packets
RTP: missed 28 packets
RTP: missed 3 packets
RTP: missed 15 packets
RTP: missed 7 packets
RTP: missed 8 packets
RTP: missed 14 packets
RTP: missed 2 packets
RTP: missed 9 packets
RTP: missed 21 packets
RTP: missed 5 packets
RTP: missed 28 packets
RTP: missed 9 packets
RTP: missed 5 packets
RTP: missed 8 packets
RTP: missed 17 packets
RTP: missed 46 packets
RTP: missed 3 packets
RTP: missed 4 packets
RTP: missed 3 packets
RTP: missed 1 packets
RTP: missed 4 packets
RTP: missed 3 packets
RTP: missed 2 packets
RTP: missed 3 packets
RTP: missed 1 packets
RTP: missed 5 packets
All info found
Estimating duration from bitrate, this may be inaccurate
Input #0, rtsp, from 'rtsp://axis1031:554/axis-media/media.amp?video=1&audio=0&videocodec=mpeg4':

Metadata:

title : Media Presentation

Duration: N/A, start: 3.690289, bitrate: N/A

Stream #0.0, 22, 1/90000: Video: mpeg4, yuv420p, 640x480 [PAR 1:1 DAR 4:3], 1k tbr, 90k tbn, 1k tbc

AVFormatContext: start_time = 3690289 (1/1000000) 3.690 sec
AVStream: start_time = 332126 (1/90000) 3.690 sec, first_dts = 332126 3.690 sec

Output #0, mov, to '/tmp/test.mov':

Stream #0.0, 0, 1/90000: Video: mpeg4, yuv420p, 640x480, q=2-31, 90k tbn, 90k tbc

Output #0, mov, to '/tmp/test.mov':

Metadata:

encoder : Lavf53.2.0
Stream #0.0, 0, 1/90000: Video: mpeg4, yuv420p, 640x480, q=2-31, 90k tbn, 90k tbc

Attachments (2)

rtp_over_tcp.tcpdump.cap (70.6 KB ) - added by Andrew 14 years ago.
rtp_over_udp.tcpdump.cap (377.2 KB ) - added by Andrew 14 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by Andrew, 14 years ago

Camera: Axis M1031, connected to a same switch with my host.
ffmpeg (rtp over tcp or http transport), gstreamer (rtp over udp) - work finelly and stable,
without missing frames and "RTP: ... bad cseq=... expected=..."

comment:2 by Andrew, 14 years ago

I'm add light cseq logging to rtp_parse_packet_internal().

@@ -475,6 +475,9 @@ static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
     /* store the ssrc in the RTPDemuxContext */
     s->ssrc = ssrc;
 
+    av_log(NULL, AV_LOG_ERROR, "RTP: PT=%02x: cseq %d expected=%d, timestamp %u\n",
+          payload_type, seq, ((s->seq + 1) & 0xffff), timestamp);   
+

rtp_over_udp output

ffmpeg av_find_stream_info(): read 47 packets [22642..22748], non_monotonic(!) CSEQs (AVFormat_context->start_time > 4 sec)

tcpdump on host (see rtp_over_udp.tcpdump.cap): camera send 355(!) packets [22393..22749] monotonic(!) CSEQs

% ./muxonly 'rtsp://axis1031:554/axis-media/media.amp?video=1&audio=0&videocodec=mpeg4&udp'
SDP:
v=0
o=- 1306932119581619 1306932119581619 IN IP4 axis1031
s=Media Presentation
e=NONE
c=IN IP4 0.0.0.0
b=AS:8000
t=0 0
a=control:rtsp://axis1031:554/axis-media/media.amp?video=1&audio=0&videocodec=mpeg4
a=range:npt=0.000000-
m=video 0 RTP/AVP 96
b=AS:8000
a=framerate:30.0
a=transform:1,0,0;0,1,0;0,0,1
a=control:rtsp://axis1031:554/axis-media/media.amp/trackID=1?video=1&audio=0&videocodec=mpeg4
a=rtpmap:96 MP4V-ES/90000
a=fmtp:96 profile-level-id=245; config=000001B0F5000001B50ECF000001000000012000C88D881F4514043C14103F

video codec set to: mpeg4
hello state=0
RTP: PT=60: cseq 22642 expected=1, timestamp 3795513460
RTP: PT=60: cseq 22643 expected=22643, timestamp 3795516306
RTP: PT=60: cseq 22648 expected=22644, timestamp 3795522448
RTP: PT=60: cseq 22649 expected=22649, timestamp 3795525295
RTP: PT=60: cseq 22652 expected=22650, timestamp 3795528141
RTP: PT=60: cseq 22653 expected=22653, timestamp 3795531437
RTP: PT=60: cseq 22656 expected=22654, timestamp 3795534283
RTP: PT=60: cseq 22657 expected=22657, timestamp 3795537129
RTP: PT=60: cseq 22660 expected=22658, timestamp 3795540425
RTP: PT=60: cseq 22661 expected=22661, timestamp 3795543272
RTP: PT=60: cseq 22664 expected=22662, timestamp 3795546118
RTP: PT=60: cseq 22665 expected=22665, timestamp 3795549414
RTP: PT=60: cseq 22668 expected=22666, timestamp 3795552260
RTP: PT=60: cseq 22669 expected=22669, timestamp 3795555106
RTP: PT=60: cseq 22672 expected=22670, timestamp 3795558403
RTP: PT=60: cseq 22673 expected=22673, timestamp 3795561249
RTP: PT=60: cseq 22676 expected=22674, timestamp 3795564095
RTP: PT=60: cseq 22677 expected=22677, timestamp 3795567391
RTP: PT=60: cseq 22680 expected=22678, timestamp 3795570237
RTP: PT=60: cseq 22681 expected=22681, timestamp 3795573083
RTP: PT=60: cseq 22684 expected=22682, timestamp 3795576379
RTP: PT=60: cseq 22685 expected=22685, timestamp 3795579226
RTP: PT=60: cseq 22688 expected=22686, timestamp 3795582072
RTP: PT=60: cseq 22689 expected=22689, timestamp 3795585368
RTP: PT=60: cseq 22692 expected=22690, timestamp 3795588214
RTP: PT=60: cseq 22693 expected=22693, timestamp 3795591060
RTP: PT=60: cseq 22696 expected=22694, timestamp 3795594356
RTP: PT=60: cseq 22697 expected=22697, timestamp 3795597203
RTP: PT=60: cseq 22700 expected=22698, timestamp 3795600049
RTP: PT=60: cseq 22701 expected=22701, timestamp 3795603345
RTP: PT=60: cseq 22714 expected=22702, timestamp 3795603345
RTP: PT=60: cseq 22715 expected=22715, timestamp 3795603345
RTP: PT=60: cseq 22716 expected=22716, timestamp 3795606191
RTP: PT=60: cseq 22719 expected=22717, timestamp 3795609037
RTP: PT=60: cseq 22720 expected=22720, timestamp 3795611884
RTP: PT=60: cseq 22723 expected=22721, timestamp 3795615180
RTP: PT=60: cseq 22724 expected=22724, timestamp 3795618026
RTP: PT=60: cseq 22729 expected=22725, timestamp 3795624168
RTP: PT=60: cseq 22730 expected=22730, timestamp 3795627015
RTP: PT=60: cseq 22735 expected=22731, timestamp 3795633157
RTP: PT=60: cseq 22736 expected=22736, timestamp 3795636003
RTP: PT=60: cseq 22739 expected=22737, timestamp 3795638849
RTP: PT=60: cseq 22740 expected=22740, timestamp 3795642145
RTP: PT=60: cseq 22743 expected=22741, timestamp 3795644992
RTP: PT=60: cseq 22744 expected=22744, timestamp 3795647838
RTP: PT=60: cseq 22747 expected=22745, timestamp 3795651134
RTP: PT=60: cseq 22748 expected=22748, timestamp 3795653980
All info found
Estimating duration from bitrate, this may be inaccurate
Input #0, rtsp, from 'rtsp://axis1031:554/axis-media/media.amp?video=1&audio=0&videocodec=mpeg4&udp':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 4.058156, bitrate: N/A
    Stream #0.0, 22, 1/90000: Video: mpeg4, yuv420p, 640x480 [PAR 1:1 DAR 4:3], 1k tbr, 90k tbn, 1k tbc

rtp_over_tcp

ffmpeg av_find_stream_info(): read 58 packets [54144..54201], monotonic CSEQs

tcpdump on host (see rtp_over_tcp.tcpdump.cap): camera send 59 packets [54144..54202], monotonic CSEQs

% ./muxonly 'rtsp://axis1031:554/axis-media/media.amp?video=1&audio=0&videocodec=mpeg4&tcp'
SDP:
v=0
o=- 1306932351978434 1306932351978434 IN IP4 axis1031
s=Media Presentation
e=NONE
c=IN IP4 0.0.0.0
b=AS:8000
t=0 0
a=control:rtsp://axis1031:554/axis-media/media.amp?video=1&audio=0&videocodec=mpeg4
a=range:npt=0.000000-
m=video 0 RTP/AVP 96
b=AS:8000
a=framerate:30.0
a=transform:1,0,0;0,1,0;0,0,1
a=control:rtsp://axis1031:554/axis-media/media.amp/trackID=1?video=1&audio=0&videocodec=mpeg4
a=rtpmap:96 MP4V-ES/90000
a=fmtp:96 profile-level-id=245; config=000001B0F5000001B50ECF000001000000012000C88D881F4514043C14103F

video codec set to: mpeg4
hello state=0
RTP: PT=60: cseq 54144 expected=1, timestamp 3175731840
RTP: PT=60: cseq 54145 expected=54145, timestamp 3175731840
RTP: PT=60: cseq 54146 expected=54146, timestamp 3175731840
RTP: PT=60: cseq 54147 expected=54147, timestamp 3175731840
RTP: PT=60: cseq 54148 expected=54148, timestamp 3175731840
RTP: PT=60: cseq 54149 expected=54149, timestamp 3175731840
RTP: PT=60: cseq 54150 expected=54150, timestamp 3175731840
RTP: PT=60: cseq 54151 expected=54151, timestamp 3175731840
RTP: PT=60: cseq 54152 expected=54152, timestamp 3175731840
RTP: PT=60: cseq 54153 expected=54153, timestamp 3175731840
RTP: PT=60: cseq 54154 expected=54154, timestamp 3175731840
RTP: PT=60: cseq 54155 expected=54155, timestamp 3175731840
RTP: PT=60: cseq 54156 expected=54156, timestamp 3175731840
RTP: PT=60: cseq 54157 expected=54157, timestamp 3175731840
RTP: PT=60: cseq 54158 expected=54158, timestamp 3175731840
RTP: PT=60: cseq 54159 expected=54159, timestamp 3175744124
RTP: PT=60: cseq 54160 expected=54160, timestamp 3175744124
RTP: PT=60: cseq 54161 expected=54161, timestamp 3175753112
RTP: PT=60: cseq 54162 expected=54162, timestamp 3175753112
RTP: PT=60: cseq 54163 expected=54163, timestamp 3175762101
RTP: PT=60: cseq 54164 expected=54164, timestamp 3175762101
RTP: PT=60: cseq 54165 expected=54165, timestamp 3175771090
RTP: PT=60: cseq 54166 expected=54166, timestamp 3175771090
RTP: PT=60: cseq 54167 expected=54167, timestamp 3175780078
RTP: PT=60: cseq 54168 expected=54168, timestamp 3175780078
RTP: PT=60: cseq 54169 expected=54169, timestamp 3175789067
RTP: PT=60: cseq 54170 expected=54170, timestamp 3175789067
RTP: PT=60: cseq 54171 expected=54171, timestamp 3175798055
RTP: PT=60: cseq 54172 expected=54172, timestamp 3175798055
RTP: PT=60: cseq 54173 expected=54173, timestamp 3175807044
RTP: PT=60: cseq 54174 expected=54174, timestamp 3175807044
RTP: PT=60: cseq 54175 expected=54175, timestamp 3175816032
RTP: PT=60: cseq 54176 expected=54176, timestamp 3175816032
RTP: PT=60: cseq 54177 expected=54177, timestamp 3175824571
RTP: PT=60: cseq 54178 expected=54178, timestamp 3175824571
RTP: PT=60: cseq 54179 expected=54179, timestamp 3175827867
RTP: PT=60: cseq 54180 expected=54180, timestamp 3175827867
RTP: PT=60: cseq 54181 expected=54181, timestamp 3175830714
RTP: PT=60: cseq 54182 expected=54182, timestamp 3175830714
RTP: PT=60: cseq 54183 expected=54183, timestamp 3175833560
RTP: PT=60: cseq 54184 expected=54184, timestamp 3175833560
RTP: PT=60: cseq 54185 expected=54185, timestamp 3175836856
RTP: PT=60: cseq 54186 expected=54186, timestamp 3175836856
RTP: PT=60: cseq 54187 expected=54187, timestamp 3175839702
RTP: PT=60: cseq 54188 expected=54188, timestamp 3175839702
RTP: PT=60: cseq 54189 expected=54189, timestamp 3175842548
RTP: PT=60: cseq 54190 expected=54190, timestamp 3175842548
RTP: PT=60: cseq 54191 expected=54191, timestamp 3175845844
RTP: PT=60: cseq 54192 expected=54192, timestamp 3175845844
RTP: PT=60: cseq 54193 expected=54193, timestamp 3175848691
RTP: PT=60: cseq 54194 expected=54194, timestamp 3175848691
RTP: PT=60: cseq 54195 expected=54195, timestamp 3175851537
RTP: PT=60: cseq 54196 expected=54196, timestamp 3175851537
RTP: PT=60: cseq 54197 expected=54197, timestamp 3175854833
RTP: PT=60: cseq 54198 expected=54198, timestamp 3175854833
RTP: PT=60: cseq 54199 expected=54199, timestamp 3175857679
RTP: PT=60: cseq 54200 expected=54200, timestamp 3175857679
RTP: PT=60: cseq 54201 expected=54201, timestamp 3175860525
All info found
Estimating duration from bitrate, this may be inaccurate
Input #0, rtsp, from 'rtsp://axis1031:554/axis-media/media.amp?video=1&audio=0&videocodec=mpeg4&tcp':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 0.136489, bitrate: N/A
    Stream #0.0, 22, 1/90000: Video: mpeg4, yuv420p, 640x480 [PAR 1:1 DAR 4:3], 1k tbr, 90k tbn, 1k tbc

by Andrew, 14 years ago

Attachment: rtp_over_tcp.tcpdump.cap added

by Andrew, 14 years ago

Attachment: rtp_over_udp.tcpdump.cap added

comment:3 by Luke Clemens, 13 years ago

hey guys, I think this problem is related to the same bug described in ticket 285. I have made some progress on it and have come up with at least a temporary "solution". Go to https://ffmpeg.org/trac/ffmpeg/ticket/285#comment:12 for the info.

--luke

comment:4 by Michael Niedermayer, 13 years ago

is this problem still reproduceable ?

comment:5 by Carl Eugen Hoyos, 12 years ago

Resolution: needs_more_info
Status: newclosed

Please reopen this ticket if it is still reproducible.

Note: See TracTickets for help on using tickets.